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

Unified Diff: components/sessions/ios/ios_serialized_navigation_driver.cc

Issue 869613006: Move referrer policy to a different field when serializing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: components/sessions/ios/ios_serialized_navigation_driver.cc
diff --git a/components/sessions/ios/ios_serialized_navigation_driver.cc b/components/sessions/ios/ios_serialized_navigation_driver.cc
index f6324ab35fb00a1e3413c2ea6a0362798f418380..9a3cb40098f7345196f6d1f6d855ae11beb017a4 100644
--- a/components/sessions/ios/ios_serialized_navigation_driver.cc
+++ b/components/sessions/ios/ios_serialized_navigation_driver.cc
@@ -32,6 +32,41 @@ int IOSSerializedNavigationDriver::GetDefaultReferrerPolicy() const {
return web::ReferrerPolicyDefault;
}
+bool ContentSerializedNavigationDriver::MapReferrerPolicyToOldValues(
marja 2015/01/29 10:54:20 Why does this code have to be in both drivers - is
jochen (gone - plz use gerrit) 2015/01/29 10:59:30 it's not! One uses web::ReferrerPolicy*, the othe
+ int referrer_policy,
+ int* mapped_referrer_policy) const {
+ // "always" and "default" are the same value in all versions.
+ if (referrer_policy == web::ReferrerPolicyAlways ||
+ referrer_policy == web::ReferrerPolicyDefault) {
+ *mapped_referrer_policy = referrer_policy;
+ return true;
+ }
+
+ // "origin" exists in the old encoding.
+ if (referrer_policy == web::ReferrerPolicyOrigin) {
+ *mapped_referrer_policy = 3;
+ return true;
+ }
+
+ // Everything else is mapped to never.
+ *mapped_referrer_policy = 2;
+ return false;
+}
+
+bool ContentSerializedNavigationDriver::MapReferrerPolicyToNewValues(
+ int referrer_policy,
+ int* mapped_referrer_policy) const {
+ // "always" and "default" are the same value in all versions.
+ if (referrer_policy == 0 || referrer_policy == 1) {
+ *mapped_referrer_policy = referrer_policy;
+ return true;
+ }
+
+ // Since we don't know what encoding was used, we map the rest to "never".
+ *mapped_referrer_policy = web::ReferrerPolicyNever;
+ return false;
+}
+
std::string
IOSSerializedNavigationDriver::GetSanitizedPageStateForPickle(
const SerializedNavigationEntry* navigation) const {
@@ -48,13 +83,20 @@ void IOSSerializedNavigationDriver::Sanitize(
!referrer.url.SchemeIsHTTPOrHTTPS()) {
referrer.url = GURL();
} else {
+ if (referrer.policy < 0 || referrer.policy > web::ReferrerPolicyLast) {
+ NOTREACHED();
+ referrer.policy = web::ReferrerPolicyNever;
+ }
+ bool is_downgrade = referrer.url.SchemeIsSecure() &&
+ !navigation->virtual_url_.SchemeIsSecure();
switch (referrer.policy) {
case web::ReferrerPolicyDefault:
- if (referrer.url.SchemeIsSecure() &&
- !navigation->virtual_url_.SchemeIsSecure()) {
+ if (is_downgrade)
referrer.url = GURL();
- }
break;
+ case web::ReferrerPolicyNoReferrerWhenDowngrade:
+ if (is_downgrade)
+ referrer.url = GURL();
case web::ReferrerPolicyAlways:
break;
case web::ReferrerPolicyNever:
@@ -63,8 +105,9 @@ void IOSSerializedNavigationDriver::Sanitize(
case web::ReferrerPolicyOrigin:
referrer.url = referrer.url.GetOrigin();
break;
- default:
- NOTREACHED();
+ case web::ReferrerPolicyOriginWhenCrossOrigin:
marja 2015/01/29 10:54:20 Why no default case anymore?
jochen (gone - plz use gerrit) 2015/01/29 10:59:30 so the compiler catches the case when an enum valu
+ if (navigation.virtual_url_.GetOrigin() != referrer.url.GetOrigin())
+ referrer.url = referrer.url.GetOrigin();
break;
}
}
« no previous file with comments | « components/sessions/ios/ios_serialized_navigation_driver.h ('k') | components/sessions/serialized_navigation_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698