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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prerender/prerender_origin.h" 5 #include "chrome/browser/prerender/prerender_origin.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/prerender/prerender_manager.h" 9 #include "chrome/browser/prerender/prerender_manager.h"
10 10
11 namespace prerender { 11 namespace prerender {
12 12
13 namespace { 13 namespace {
14 14
15 const char* kOriginNames[] = { 15 const char* kOriginNames[] = {
16 "[Deprecated] Link Rel Prerender (original)", 16 "[Deprecated] Link Rel Prerender (original)",
17 "[Deprecated] Omnibox (original)", 17 "[Deprecated] Omnibox (original)",
18 "GWS Prerender", 18 "GWS Prerender",
19 "[Deprecated] Omnibox (conservative)", 19 "[Deprecated] Omnibox (conservative)",
20 "[Deprecated] Omnibox (exact)", 20 "[Deprecated] Omnibox (exact)",
21 "Omnibox", 21 "Omnibox",
22 "None", 22 "None",
23 "Link Rel Prerender (same domain)", 23 "Link Rel Prerender (same domain)",
24 "Link Rel Prerender (cross domain)", 24 "Link Rel Prerender (cross domain)",
25 "Local Predictor", 25 "Local Predictor",
26 "External Request", 26 "External Request",
27 "Instant", 27 "Instant",
28 "Link Rel Next", 28 "Link Rel Next",
29 "External Request Forced Cellular", 29 "External Request Forced Cellular",
30 "Offline",
30 "Max", 31 "Max",
31 }; 32 };
32 static_assert(arraysize(kOriginNames) == ORIGIN_MAX + 1, 33 static_assert(arraysize(kOriginNames) == ORIGIN_MAX + 1,
33 "prerender origin name count mismatch"); 34 "prerender origin name count mismatch");
34 35
35 } // namespace 36 } // namespace
36 37
37 const char* NameFromOrigin(Origin origin) { 38 const char* NameFromOrigin(Origin origin) {
38 DCHECK(static_cast<int>(origin) >= 0 && 39 DCHECK(static_cast<int>(origin) >= 0 &&
39 origin <= ORIGIN_MAX); 40 origin <= ORIGIN_MAX);
40 return kOriginNames[origin]; 41 return kOriginNames[origin];
41 } 42 }
42 43
44 bool IsAlwaysPrerenderedOrigin(Origin origin) {
45 DCHECK(static_cast<int>(origin) >= 0 &&
46 origin < ORIGIN_MAX);
47 // <link rel=prerender> origins ignore the network state and the privacy
48 // settings. Web developers should be able prefetch with all possible privacy
49 // settings and with all possible network types. This would avoid web devs
50 // coming up with creative ways to prefetch in cases they are not allowed to
51 // do so.
52 //
53 // Offline originated prerenders also ignore the network state and privacy
54 // settings because want to be able to snapshot webpages independently of
55 // these former settings.
56 return origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN ||
57 origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN ||
58 origin == ORIGIN_OFFLINE;
59 }
60
61 bool IsCellularForcedOrigin(Origin origin) {
62 DCHECK(static_cast<int>(origin) >= 0 &&
63 origin < ORIGIN_MAX);
64 return origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR ||
65 IsAlwaysPrerenderedOrigin(origin);
66 }
67
43 } // namespace prerender 68 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698