page_state_serialization.h revision 58537e28ecd584eab876aee8be7156509866d23a
1// Copyright 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.
4
5#ifndef CONTENT_COMMON_PAGE_STATE_SERIALIZATION_H_
6#define CONTENT_COMMON_PAGE_STATE_SERIALIZATION_H_
7
8#include <vector>
9
10#include "base/strings/nullable_string16.h"
11#include "content/common/content_export.h"
12#include "third_party/WebKit/public/platform/WebHTTPBody.h"
13#include "ui/gfx/point.h"
14#include "url/gurl.h"
15
16namespace content {
17
18struct CONTENT_EXPORT ExplodedHttpBodyElement {
19  WebKit::WebHTTPBody::Element::Type type;
20  std::string data;
21  base::NullableString16 file_path;
22  GURL filesystem_url;
23  int64 file_start;
24  int64 file_length;
25  double file_modification_time;
26  GURL deprecated_blob_url;
27
28  ExplodedHttpBodyElement();
29  ~ExplodedHttpBodyElement();
30};
31
32struct CONTENT_EXPORT ExplodedHttpBody {
33  base::NullableString16 http_content_type;
34  std::vector<ExplodedHttpBodyElement> elements;
35  int64 identifier;
36  bool contains_passwords;
37  bool is_null;
38
39  ExplodedHttpBody();
40  ~ExplodedHttpBody();
41};
42
43struct CONTENT_EXPORT ExplodedFrameState {
44  base::NullableString16 url_string;
45  base::NullableString16 original_url_string;
46  base::NullableString16 referrer;
47  base::NullableString16 target;
48  base::NullableString16 parent;
49  base::NullableString16 title;
50  base::NullableString16 alternate_title;
51  base::NullableString16 state_object;
52  std::vector<base::NullableString16> document_state;
53  gfx::Point scroll_offset;
54  int64 item_sequence_number;
55  int64 document_sequence_number;
56  int visit_count;
57  double visited_time;
58  double page_scale_factor;
59  bool is_target_item;
60  ExplodedHttpBody http_body;
61  std::vector<ExplodedFrameState> children;
62
63  ExplodedFrameState();
64  ~ExplodedFrameState();
65};
66
67struct CONTENT_EXPORT ExplodedPageState {
68  std::vector<base::NullableString16> referenced_files;
69  ExplodedFrameState top;
70
71  ExplodedPageState();
72  ~ExplodedPageState();
73};
74
75CONTENT_EXPORT bool DecodePageState(const std::string& encoded,
76                                    ExplodedPageState* exploded);
77CONTENT_EXPORT bool EncodePageState(const ExplodedPageState& exploded,
78                                    std::string* encoded);
79
80#if defined(OS_ANDROID)
81CONTENT_EXPORT bool DecodePageStateWithDeviceScaleFactorForTesting(
82    const std::string& encoded,
83    float device_scale_factor,
84    ExplodedPageState* exploded);
85#endif
86
87}  // namespace content
88
89#endif  // CONTENT_COMMON_PAGE_STATE_SERIALIZATION_H_
90