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

Unified Diff: android_webview/native/state_serializer.cc

Issue 1497743005: Allow huge data: URIs only via WebView.loadDataWithBaseUrl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the test Created 5 years 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: android_webview/native/state_serializer.cc
diff --git a/android_webview/native/state_serializer.cc b/android_webview/native/state_serializer.cc
index 22139a279e1367a1e56e8d69ec4a3ae3938e7977..fc9cf9bd5ef62d5c1485071ea18e1b80956aab4f 100644
--- a/android_webview/native/state_serializer.cc
+++ b/android_webview/native/state_serializer.cc
@@ -34,7 +34,7 @@ namespace {
// Sanity check value that we are restoring from a valid pickle.
// This can potentially used as an actual serialization version number in the
// future if we ever decide to support restoring from older versions.
-const uint32 AW_STATE_VERSION = 20130814;
+const uint32 AW_STATE_VERSION = 20151204;
} // namespace
@@ -179,6 +179,20 @@ bool WriteNavigationEntryToPickle(const content::NavigationEntry& entry,
if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec()))
return false;
+ {
+ const char* data = nullptr;
+ size_t size = 0;
+ scoped_refptr<const base::RefCountedString> s = entry.GetDataURLAsString();
+ if (s) {
+ data = s->front_as<char>();
+ size = s->size();
+ }
+ // Even when |entry.GetDataForDataURL()| is null we still need to write a
+ // zero-length entry to ensure the fields all line up when read back in.
+ if (!pickle->WriteData(data, size))
+ return false;
+ }
+
if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent())))
return false;
@@ -261,6 +275,18 @@ bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator,
}
{
+ const char* data;
+ int size;
+ if (!iterator->ReadData(&data, &size))
+ return false;
+ if (size > 0) {
+ scoped_refptr<base::RefCountedString> ref = new base::RefCountedString();
+ ref->data().assign(data, size);
+ entry->SetDataURLAsString(ref);
+ }
+ }
+
+ {
bool is_overriding_user_agent;
if (!iterator->ReadBool(&is_overriding_user_agent))
return false;

Powered by Google App Engine
This is Rietveld 408576698