summaryrefslogtreecommitdiff
path: root/chromium/content/public/common/page_state.h
blob: c630e6bcf30d2b8b7d34c51e86207b4976274623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_COMMON_PAGE_STATE_H_
#define CONTENT_PUBLIC_COMMON_PAGE_STATE_H_

#include <string>
#include <vector>

#include "content/common/content_export.h"

class GURL;

namespace base {
class FilePath;
}

namespace content {

// The PageState class represents the information needed by the rendering
// engine to reconstruct a web page (and its tree of frames), including for
// example the URLs of the documents and the values of any form fields.  This
// information is used when navigating back & forward through session history.
//
// The format of the encoded data is not exposed by the content API.
class CONTENT_EXPORT PageState {
 public:
  static PageState CreateFromEncodedData(const std::string& data);
  static PageState CreateFromURL(const GURL& url);

  static PageState CreateForTesting(
      const GURL& url,
      bool body_contains_password_data,
      const char* optional_body_data,
      const base::FilePath* optional_body_file_path);

  // Creates an encoded page state from the |url|, |item_sequence_mnumber| and
  // |document_sequence_number| parameters.
  static PageState CreateForTestingWithSequenceNumbers(
      const GURL& url,
      int64_t item_sequence_number,
      int64_t document_sequence_number);

  PageState();

  bool IsValid() const;
  bool Equals(const PageState& page_state) const;
  const std::string& ToEncodedData() const;

  std::vector<base::FilePath> GetReferencedFiles() const;
  PageState RemovePasswordData() const;
  PageState RemoveScrollOffset() const;
  PageState RemoveReferrer() const;

  // Support DCHECK_EQ(a, b), etc.
  bool operator==(const PageState& other) const { return this->Equals(other); }
  bool operator!=(const PageState& other) const {
    return !(this->Equals(other));
  }

 private:
  PageState(const std::string& data);

  std::string data_;
};

}  // namespace content

#endif  // CONTENT_PUBLIC_COMMON_PAGE_STATE_H_