Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1348)

Unified Diff: content/public/common/page_state_webkit.cc

Issue 16162003: Introduce content::PageState (again). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/common/page_state_webkit.cc
diff --git a/content/public/common/page_state_webkit.cc b/content/public/common/page_state_webkit.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a52b61e8277ceb576ab5da82dc24f07cbce9c472
--- /dev/null
+++ b/content/public/common/page_state_webkit.cc
@@ -0,0 +1,59 @@
+// 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.
+
+#include "content/public/common/page_state.h"
+
+#include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPBody.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
+#include "webkit/base/file_path_string_conversions.h"
+#include "webkit/glue/glue_serialize_deprecated.h"
+
+namespace content {
+
+// static
+PageState PageState::CreateFromURL(const GURL& url) {
+ return PageState(webkit_glue::CreateHistoryStateForURL(url));
+}
+
+// static
+PageState PageState::CreateForTesting(
+ const GURL& url,
+ bool body_contains_password_data,
+ const char* optional_body_data,
+ const base::FilePath* optional_body_file_path) {
+ WebKit::WebHistoryItem history_item;
+ history_item.initialize();
+ history_item.setURLString(
+ WebKit::WebString::fromUTF8(url.possibly_invalid_spec()));
+ if (optional_body_data || optional_body_file_path) {
+ WebKit::WebHTTPBody http_body;
+ http_body.initialize();
+ http_body.setContainsPasswordData(body_contains_password_data);
+ if (optional_body_data) {
+ http_body.appendData(
+ WebKit::WebData(optional_body_data, strlen(optional_body_data)));
+ }
+ if (optional_body_file_path) {
+ http_body.appendFile(
+ webkit_base::FilePathToWebString(*optional_body_file_path));
+ }
+ history_item.setHTTPBody(http_body);
+ }
+ return PageState(webkit_glue::HistoryItemToString(history_item));
+}
+
+std::vector<base::FilePath> PageState::GetReferencedFiles() const {
+ return webkit_glue::FilePathsFromHistoryState(data_);
+}
+
+PageState PageState::RemovePasswordData() const {
+ return PageState(webkit_glue::RemovePasswordDataFromHistoryState(data_));
+}
+
+PageState PageState::RemoveScrollOffset() const {
+ return PageState(webkit_glue::RemoveScrollOffsetFromHistoryState(data_));
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698