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

Unified Diff: chrome/browser/prerender/prerender_origin.cc

Issue 1854643002: Implement PrerenderManager::AddPrerenderForOffline() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses pasko' comments Created 4 years, 8 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: chrome/browser/prerender/prerender_origin.cc
diff --git a/chrome/browser/prerender/prerender_origin.cc b/chrome/browser/prerender/prerender_origin.cc
index 3c9b7b692492c76636cefcc609a118eac0914329..d222dea5c41f5455b7ae93011f87583e9f628a1c 100644
--- a/chrome/browser/prerender/prerender_origin.cc
+++ b/chrome/browser/prerender/prerender_origin.cc
@@ -27,6 +27,7 @@ const char* kOriginNames[] = {
"Instant",
"Link Rel Next",
"External Request Forced Cellular",
+ "Offline",
"Max",
};
static_assert(arraysize(kOriginNames) == ORIGIN_MAX + 1,
@@ -40,4 +41,28 @@ const char* NameFromOrigin(Origin origin) {
return kOriginNames[origin];
}
+bool IsAlwaysPrerenderedOrigin(Origin origin) {
+ DCHECK(static_cast<int>(origin) >= 0 &&
+ origin < ORIGIN_MAX);
+ // <link rel=prerender> origins ignore the network state and the privacy
+ // settings. Web developers should be able prefetch with all possible privacy
+ // settings and with all possible network types. This would avoid web devs
+ // coming up with creative ways to prefetch in cases they are not allowed to
+ // do so.
+ //
+ // Offline originated prerenders also ignore the network state and privacy
+ // settings because want to be able to snapshot webpages independently of
+ // these former settings.
+ return origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN ||
+ origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN ||
+ origin == ORIGIN_OFFLINE;
+}
+
+bool IsCellularForcedOrigin(Origin origin) {
+ DCHECK(static_cast<int>(origin) >= 0 &&
+ origin < ORIGIN_MAX);
+ return origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR ||
+ IsAlwaysPrerenderedOrigin(origin);
+}
+
} // namespace prerender

Powered by Google App Engine
This is Rietveld 408576698