| OLD | NEW |
| 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_field_trial.h" | 5 #include "chrome/browser/prerender/prerender_field_trial.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } else if (trial_group == experiment_match_complete_group) { | 190 } else if (trial_group == experiment_match_complete_group) { |
| 191 PrerenderManager::SetMode( | 191 PrerenderManager::SetMode( |
| 192 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP); | 192 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP); |
| 193 } else { | 193 } else { |
| 194 NOTREACHED(); | 194 NOTREACHED(); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // end namespace | 198 } // end namespace |
| 199 | 199 |
| 200 void ConfigurePrerender(const CommandLine& command_line) { | 200 void ConfigurePrerender(const base::CommandLine& command_line) { |
| 201 enum PrerenderOption { | 201 enum PrerenderOption { |
| 202 PRERENDER_OPTION_AUTO, | 202 PRERENDER_OPTION_AUTO, |
| 203 PRERENDER_OPTION_DISABLED, | 203 PRERENDER_OPTION_DISABLED, |
| 204 PRERENDER_OPTION_ENABLED, | 204 PRERENDER_OPTION_ENABLED, |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 PrerenderOption prerender_option = PRERENDER_OPTION_AUTO; | 207 PrerenderOption prerender_option = PRERENDER_OPTION_AUTO; |
| 208 if (command_line.HasSwitch(switches::kPrerenderMode)) { | 208 if (command_line.HasSwitch(switches::kPrerenderMode)) { |
| 209 const string switch_value = | 209 const string switch_value = |
| 210 command_line.GetSwitchValueASCII(switches::kPrerenderMode); | 210 command_line.GetSwitchValueASCII(switches::kPrerenderMode); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool IsOmniboxEnabled(Profile* profile) { | 244 bool IsOmniboxEnabled(Profile* profile) { |
| 245 if (!profile) | 245 if (!profile) |
| 246 return false; | 246 return false; |
| 247 | 247 |
| 248 if (!PrerenderManager::IsPrerenderingPossible()) | 248 if (!PrerenderManager::IsPrerenderingPossible()) |
| 249 return false; | 249 return false; |
| 250 | 250 |
| 251 // Override any field trial groups if the user has set a command line flag. | 251 // Override any field trial groups if the user has set a command line flag. |
| 252 if (CommandLine::ForCurrentProcess()->HasSwitch( | 252 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 253 switches::kPrerenderFromOmnibox)) { | 253 switches::kPrerenderFromOmnibox)) { |
| 254 const string switch_value = | 254 const string switch_value = |
| 255 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 255 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 256 switches::kPrerenderFromOmnibox); | 256 switches::kPrerenderFromOmnibox); |
| 257 | 257 |
| 258 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled) | 258 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled) |
| 259 return true; | 259 return true; |
| 260 | 260 |
| 261 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) | 261 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) |
| 262 return false; | 262 return false; |
| 263 | 263 |
| 264 DCHECK_EQ(switches::kPrerenderFromOmniboxSwitchValueAuto, switch_value); | 264 DCHECK_EQ(switches::kPrerenderFromOmniboxSwitchValueAuto, switch_value); |
| 265 } | 265 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 295 return service && service->GetOpenTabsUIDelegate() && | 295 return service && service->GetOpenTabsUIDelegate() && |
| 296 !service->EncryptEverythingEnabled(); | 296 !service->EncryptEverythingEnabled(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Indicates whether the Local Predictor is enabled based on field trial | 299 // Indicates whether the Local Predictor is enabled based on field trial |
| 300 // selection. | 300 // selection. |
| 301 bool IsLocalPredictorEnabled() { | 301 bool IsLocalPredictorEnabled() { |
| 302 #if defined(OS_ANDROID) || defined(OS_IOS) | 302 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 303 return false; | 303 return false; |
| 304 #endif | 304 #endif |
| 305 return | 305 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 306 !CommandLine::ForCurrentProcess()->HasSwitch( | 306 switches::kDisablePrerenderLocalPredictor) && |
| 307 switches::kDisablePrerenderLocalPredictor) && | 307 GetLocalPredictorSpecValue(kLocalPredictorKeyName) == kEnabledGroup; |
| 308 GetLocalPredictorSpecValue(kLocalPredictorKeyName) == kEnabledGroup; | |
| 309 } | 308 } |
| 310 | 309 |
| 311 bool ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(Profile* profile) { | 310 bool ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(Profile* profile) { |
| 312 return | 311 return |
| 313 GetLocalPredictorSpecValue(kLocalPredictorUnencryptedSyncOnlyKeyName) == | 312 GetLocalPredictorSpecValue(kLocalPredictorUnencryptedSyncOnlyKeyName) == |
| 314 kEnabledGroup && | 313 kEnabledGroup && |
| 315 !IsUnencryptedSyncEnabled(profile); | 314 !IsUnencryptedSyncEnabled(profile); |
| 316 } | 315 } |
| 317 | 316 |
| 318 bool ShouldDisableLocalPredictorDueToPreferencesAndNetwork(Profile* profile) { | 317 bool ShouldDisableLocalPredictorDueToPreferencesAndNetwork(Profile* profile) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 return GetLocalPredictorSpecValue(kDisableSessionStorageNamespaceMerging) != | 484 return GetLocalPredictorSpecValue(kDisableSessionStorageNamespaceMerging) != |
| 486 kDisabledGroup; | 485 kDisabledGroup; |
| 487 } | 486 } |
| 488 | 487 |
| 489 bool IsPrerenderCookieStoreEnabled() { | 488 bool IsPrerenderCookieStoreEnabled() { |
| 490 return GetLocalPredictorSpecValue(kPrerenderCookieStore) != kDisabledGroup && | 489 return GetLocalPredictorSpecValue(kPrerenderCookieStore) != kDisabledGroup && |
| 491 FieldTrialList::FindFullName(kPrerenderCookieStore) != kDisabledGroup; | 490 FieldTrialList::FindFullName(kPrerenderCookieStore) != kDisabledGroup; |
| 492 } | 491 } |
| 493 | 492 |
| 494 } // namespace prerender | 493 } // namespace prerender |
| OLD | NEW |