Give names to all utility processes.
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_field_trial.cc
blob54d3c3801cec1c567d686fc035122ee450a3bc5c
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
3 // found in the LICENSE file.
5 #include "chrome/browser/prerender/prerender_field_trial.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "chrome/browser/net/prediction_options.h"
10 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
11 #include "chrome/browser/prerender/prerender_manager.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/profile_sync_service.h"
14 #include "chrome/browser/sync/profile_sync_service_factory.h"
15 #include "chrome/common/chrome_switches.h"
17 using std::string;
19 namespace prerender {
21 namespace {
23 const char kDefaultPrerenderServiceURLPrefix[] =
24 "https://clients4.google.com/prerenderservice/?q=";
25 const int kDefaultPrerenderServiceTimeoutMs = 1000;
26 const int kDefaultPrefetchListTimeoutSeconds = 300;
28 } // end namespace
30 void ConfigurePrerender(const base::CommandLine& command_line) {
31 PrerenderManager::PrerenderManagerMode mode =
32 PrerenderManager::PRERENDER_MODE_ENABLED;
33 if (command_line.HasSwitch(switches::kPrerenderMode)) {
34 const string switch_value =
35 command_line.GetSwitchValueASCII(switches::kPrerenderMode);
37 if (switch_value == switches::kPrerenderModeSwitchValueDisabled) {
38 mode = PrerenderManager::PRERENDER_MODE_DISABLED;
39 } else if (switch_value.empty() ||
40 switch_value == switches::kPrerenderModeSwitchValueEnabled) {
41 // The empty string means the option was provided with no value, and that
42 // means enable.
43 mode = PrerenderManager::PRERENDER_MODE_ENABLED;
44 } else {
45 mode = PrerenderManager::PRERENDER_MODE_DISABLED;
46 LOG(ERROR) << "Invalid --prerender option received on command line: "
47 << switch_value;
48 LOG(ERROR) << "Disabling prerendering!";
52 PrerenderManager::SetMode(mode);
55 bool IsOmniboxEnabled(Profile* profile) {
56 if (!profile)
57 return false;
59 if (!PrerenderManager::IsPrerenderingPossible())
60 return false;
62 // Override any field trial groups if the user has set a command line flag.
63 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
64 switches::kPrerenderFromOmnibox)) {
65 const string switch_value =
66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
67 switches::kPrerenderFromOmnibox);
69 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled)
70 return true;
72 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled)
73 return false;
75 DCHECK_EQ(switches::kPrerenderFromOmniboxSwitchValueAuto, switch_value);
78 return (base::FieldTrialList::FindFullName("PrerenderFromOmnibox") !=
79 "OmniboxPrerenderDisabled");
82 bool IsUnencryptedSyncEnabled(Profile* profile) {
83 ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
84 GetForProfile(profile);
85 return service && service->GetOpenTabsUIDelegate() &&
86 !service->EncryptEverythingEnabled();
89 // Indicates whether the Local Predictor is enabled based on field trial
90 // selection.
91 bool IsLocalPredictorEnabled() {
92 return false;
95 bool ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(Profile* profile) {
96 return false;
99 bool ShouldDisableLocalPredictorDueToPreferencesAndNetwork(Profile* profile) {
100 return false;
103 bool IsLoggedInPredictorEnabled() {
104 return IsLocalPredictorEnabled();
107 bool IsSideEffectFreeWhitelistEnabled() {
108 return IsLocalPredictorEnabled();
111 bool IsLocalPredictorPrerenderLaunchEnabled() {
112 return true;
115 bool IsLocalPredictorPrerenderAlwaysControlEnabled() {
116 // If we prefetch rather than prerender, we automatically also prerender
117 // as a control group only.
118 return IsLocalPredictorPrerenderPrefetchEnabled();
121 bool IsLocalPredictorPrerenderPrefetchEnabled() {
122 return false;
125 bool ShouldQueryPrerenderService(Profile* profile) {
126 return false;
129 bool ShouldQueryPrerenderServiceForCurrentURL() {
130 return true;
133 bool ShouldQueryPrerenderServiceForCandidateURLs() {
134 return true;
137 string GetPrerenderServiceURLPrefix() {
138 return kDefaultPrerenderServiceURLPrefix;
141 int GetPrerenderServiceBehaviorID() {
142 return 0;
145 int GetPrerenderServiceFetchTimeoutMs() {
146 return kDefaultPrerenderServiceTimeoutMs;
149 int GetPrerenderPrefetchListTimeoutSeconds() {
150 return kDefaultPrefetchListTimeoutSeconds;
153 int GetLocalPredictorTTLSeconds() {
154 // Use a default value of 180s.
155 return 180;
158 int GetLocalPredictorPrerenderPriorityHalfLifeTimeSeconds() {
159 return 0;
162 int GetLocalPredictorMaxConcurrentPrerenders() {
163 return 1;
166 int GetLocalPredictorMaxLaunchPrerenders() {
167 return 1;
170 bool SkipLocalPredictorFragment() {
171 return false;
174 bool SkipLocalPredictorHTTPS() {
175 return false;
178 bool SkipLocalPredictorWhitelist() {
179 return false;
182 bool SkipLocalPredictorServiceWhitelist() {
183 return false;
186 bool SkipLocalPredictorLoggedIn() {
187 return false;
190 bool SkipLocalPredictorDefaultNoPrerender() {
191 return false;
194 bool SkipLocalPredictorLocalCandidates() {
195 return false;
198 bool SkipLocalPredictorServiceCandidates() {
199 return false;
202 } // namespace prerender