Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / common / page_state.h
blobc38f961bb24d4bccdca34465292cbe130ca36c1f
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_COMMON_PAGE_STATE_H_
6 #define CONTENT_PUBLIC_COMMON_PAGE_STATE_H_
8 #include <string>
9 #include <vector>
11 #include "content/common/content_export.h"
13 class GURL;
15 namespace base {
16 class FilePath;
19 namespace content {
21 // The PageState class represents the information needed by the rendering
22 // engine to reconstruct a web page (and its tree of frames), including for
23 // example the URLs of the documents and the values of any form fields. This
24 // information is used when navigating back & forward through session history.
26 // The format of the encoded data is not exposed by the content API.
27 class CONTENT_EXPORT PageState {
28 public:
29 static PageState CreateFromEncodedData(const std::string& data);
30 static PageState CreateFromURL(const GURL& url);
32 static PageState CreateForTesting(
33 const GURL& url,
34 bool body_contains_password_data,
35 const char* optional_body_data,
36 const base::FilePath* optional_body_file_path);
38 PageState();
40 bool IsValid() const;
41 bool Equals(const PageState& page_state) const;
42 const std::string& ToEncodedData() const;
44 std::vector<base::FilePath> GetReferencedFiles() const;
45 PageState RemovePasswordData() const;
46 PageState RemoveScrollOffset() const;
47 PageState RemoveReferrer() const;
49 private:
50 PageState(const std::string& data);
52 std::string data_;
55 // Support DCHECK_EQ(a, b), etc.
56 inline bool operator==(const PageState& a, const PageState& b) {
57 return a.Equals(b);
59 inline bool operator!=(const PageState& a, const PageState& b) {
60 return !(a == b);
63 } // namespace content
65 #endif // CONTENT_PUBLIC_COMMON_PAGE_STATE_H_