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; |
samarth
2013/05/02 21:57:18
Test for this change too please.
David Black
2013/05/02 23:30:01
Done.
| |
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) || | 481 command_line->HasSwitch(switches::kEnableLocalOnlyInstantExtendedAPI)) { |
483 command_line->HasSwitch(switches::kEnableLocalOnlyInstantExtendedAPI) || | |
484 command_line->HasSwitch(switches::kDisableLocalOnlyInstantExtendedAPI)) { | |
485 return false; | 482 return false; |
486 } | 483 } |
487 | 484 |
488 FieldTrialFlags flags; | 485 FieldTrialFlags flags; |
489 if (GetFieldTrialInfo( | 486 if (GetFieldTrialInfo( |
490 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | 487 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
491 &flags, NULL)) { | 488 &flags, NULL)) { |
492 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, | 489 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, |
493 flags); | 490 flags); |
494 } | 491 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 | 599 |
603 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), | 600 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), |
604 kDisableStartMargin); | 601 kDisableStartMargin); |
605 // Extended mode instant requires a search terms replacement key. | 602 // Extended mode instant requires a search terms replacement key. |
606 return instant_url.is_valid() && | 603 return instant_url.is_valid() && |
607 (!IsInstantExtendedAPIEnabled() || | 604 (!IsInstantExtendedAPIEnabled() || |
608 template_url->HasSearchTermsReplacementKey(instant_url)); | 605 template_url->HasSearchTermsReplacementKey(instant_url)); |
609 } | 606 } |
610 | 607 |
611 } // namespace chrome | 608 } // namespace chrome |
OLD | NEW |