Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 bool IsInstantURL(const GURL& url, Profile* profile) { | 153 bool IsInstantURL(const GURL& url, Profile* profile) { |
| 154 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 154 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
| 155 if (!template_url) | 155 if (!template_url) |
| 156 return false; | 156 return false; |
| 157 | 157 |
| 158 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); | 158 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); |
| 159 const bool extended_api_enabled = IsInstantExtendedAPIEnabled(); | 159 const bool extended_api_enabled = IsInstantExtendedAPIEnabled(); |
| 160 GURL effective_url = url; | 160 GURL effective_url = url; |
| 161 | 161 |
| 162 if (IsCommandLineInstantURL(url)) | 162 if (IsCommandLineInstantURL(url)) |
| 163 effective_url = CoerceCommandLineURLToTemplateURL(url, instant_url_ref, | 163 return true; |
|
sreeram
2013/05/03 23:17:31
This bypasses the secure & espv checks. I understa
David Black
2013/05/04 00:49:23
As discussed in person, I maintain the logic here
| |
| 164 kDisableStartMargin); | |
| 165 | 164 |
| 166 if (!effective_url.is_valid()) | 165 if (!effective_url.is_valid()) |
| 167 return false; | 166 return false; |
| 168 | 167 |
| 169 if (extended_api_enabled && !effective_url.SchemeIsSecure()) | 168 if (extended_api_enabled && !effective_url.SchemeIsSecure()) |
| 170 return false; | 169 return false; |
| 171 | 170 |
| 172 if (extended_api_enabled && | 171 if (extended_api_enabled && |
| 173 !template_url->HasSearchTermsReplacementKey(effective_url)) | 172 !template_url->HasSearchTermsReplacementKey(effective_url)) |
| 174 return false; | 173 return false; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 | 471 |
| 473 bool IsInstantEnabled(Profile* profile) { | 472 bool IsInstantEnabled(Profile* profile) { |
| 474 return GetInstantURL(profile, kDisableStartMargin).is_valid(); | 473 return GetInstantURL(profile, kDisableStartMargin).is_valid(); |
| 475 } | 474 } |
| 476 | 475 |
| 477 bool ShouldPreferRemoteNTPOnStartup() { | 476 bool ShouldPreferRemoteNTPOnStartup() { |
| 478 // Check the command-line/about:flags setting first, which should have | 477 // Check the command-line/about:flags setting first, which should have |
| 479 // precedence and allows the trial to not be reported (if it's never queried). | 478 // precedence and allows the trial to not be reported (if it's never queried). |
| 480 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 479 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 481 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || | 480 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || |
| 482 command_line->HasSwitch(switches::kEnableInstantExtendedAPI) || | |
| 483 command_line->HasSwitch(switches::kEnableLocalOnlyInstantExtendedAPI) || | 481 command_line->HasSwitch(switches::kEnableLocalOnlyInstantExtendedAPI) || |
| 484 command_line->HasSwitch(switches::kDisableLocalOnlyInstantExtendedAPI)) { | 482 command_line->HasSwitch(switches::kDisableLocalFirstLoadNTP)) { |
| 485 return false; | 483 return false; |
| 486 } | 484 } |
| 485 if (command_line->HasSwitch(switches::kEnableLocalFirstLoadNTP)) | |
| 486 return true; | |
|
sreeram
2013/05/03 23:17:31
This is inverted. kEnableLocalFirstLoadNTP should
David Black
2013/05/04 00:49:23
Whoops. Fixed.
| |
| 487 | 487 |
| 488 FieldTrialFlags flags; | 488 FieldTrialFlags flags; |
| 489 if (GetFieldTrialInfo( | 489 if (GetFieldTrialInfo( |
| 490 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | 490 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 491 &flags, NULL)) { | 491 &flags, NULL)) { |
| 492 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, | 492 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, |
| 493 flags); | 493 flags); |
| 494 } | 494 } |
| 495 return false; | 495 return false; |
| 496 } | 496 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 | 602 |
| 603 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), | 603 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), |
| 604 kDisableStartMargin); | 604 kDisableStartMargin); |
| 605 // Extended mode instant requires a search terms replacement key. | 605 // Extended mode instant requires a search terms replacement key. |
| 606 return instant_url.is_valid() && | 606 return instant_url.is_valid() && |
| 607 (!IsInstantExtendedAPIEnabled() || | 607 (!IsInstantExtendedAPIEnabled() || |
| 608 template_url->HasSearchTermsReplacementKey(instant_url)); | 608 template_url->HasSearchTermsReplacementKey(instant_url)); |
| 609 } | 609 } |
| 610 | 610 |
| 611 } // namespace chrome | 611 } // namespace chrome |
| OLD | NEW |