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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return GURL(); | 133 return GURL(); |
134 | 134 |
135 return TemplateURLRefToGURL(template_url->new_tab_url_ref(), | 135 return TemplateURLRefToGURL(template_url->new_tab_url_ref(), |
136 kDisableStartMargin, false); | 136 kDisableStartMargin, false); |
137 } | 137 } |
138 | 138 |
139 bool MatchesOrigin(const GURL& my_url, const GURL& other_url) { | 139 bool MatchesOrigin(const GURL& my_url, const GURL& other_url) { |
140 return my_url.host() == other_url.host() && | 140 return my_url.host() == other_url.host() && |
141 my_url.port() == other_url.port() && | 141 my_url.port() == other_url.port() && |
142 (my_url.scheme() == other_url.scheme() || | 142 (my_url.scheme() == other_url.scheme() || |
143 (my_url.SchemeIs(chrome::kHttpsScheme) && | 143 (my_url.SchemeIs(content::kHttpsScheme) && |
144 other_url.SchemeIs(chrome::kHttpScheme))); | 144 other_url.SchemeIs(chrome::kHttpScheme))); |
145 } | 145 } |
146 | 146 |
147 bool MatchesAnySearchURL(const GURL& url, TemplateURL* template_url) { | 147 bool MatchesAnySearchURL(const GURL& url, TemplateURL* template_url) { |
148 GURL search_url = | 148 GURL search_url = |
149 TemplateURLRefToGURL(template_url->url_ref(), kDisableStartMargin, false); | 149 TemplateURLRefToGURL(template_url->url_ref(), kDisableStartMargin, false); |
150 if (search_url.is_valid() && MatchesOriginAndPath(url, search_url)) | 150 if (search_url.is_valid() && MatchesOriginAndPath(url, search_url)) |
151 return true; | 151 return true; |
152 | 152 |
153 // "URLCount() - 1" because we already tested url_ref above. | 153 // "URLCount() - 1" because we already tested url_ref above. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 !template_url->HasSearchTermsReplacementKey(instant_url)) | 423 !template_url->HasSearchTermsReplacementKey(instant_url)) |
424 return GURL(); | 424 return GURL(); |
425 | 425 |
426 // Extended mode requires HTTPS. Force it unless the base URL was overridden | 426 // Extended mode requires HTTPS. Force it unless the base URL was overridden |
427 // on the command line, in which case we allow HTTP (see comments on | 427 // on the command line, in which case we allow HTTP (see comments on |
428 // IsSuitableURLForInstant()). | 428 // IsSuitableURLForInstant()). |
429 if (instant_url.SchemeIsSecure() || | 429 if (instant_url.SchemeIsSecure() || |
430 google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) | 430 google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) |
431 return instant_url; | 431 return instant_url; |
432 GURL::Replacements replacements; | 432 GURL::Replacements replacements; |
433 const std::string secure_scheme(chrome::kHttpsScheme); | 433 const std::string secure_scheme(content::kHttpsScheme); |
434 replacements.SetSchemeStr(secure_scheme); | 434 replacements.SetSchemeStr(secure_scheme); |
435 return instant_url.ReplaceComponents(replacements); | 435 return instant_url.ReplaceComponents(replacements); |
436 } | 436 } |
437 | 437 |
438 GURL GetLocalInstantURL(Profile* profile) { | 438 GURL GetLocalInstantURL(Profile* profile) { |
439 return GURL(chrome::kChromeSearchLocalNtpUrl); | 439 return GURL(chrome::kChromeSearchLocalNtpUrl); |
440 } | 440 } |
441 | 441 |
442 bool ShouldPreferRemoteNTPOnStartup() { | 442 bool ShouldPreferRemoteNTPOnStartup() { |
443 // Check the command-line/about:flags setting first, which should have | 443 // Check the command-line/about:flags setting first, which should have |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 bool default_value, | 713 bool default_value, |
714 const FieldTrialFlags& flags) { | 714 const FieldTrialFlags& flags) { |
715 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 715 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
716 } | 716 } |
717 | 717 |
718 void ResetInstantExtendedOptInStateGateForTest() { | 718 void ResetInstantExtendedOptInStateGateForTest() { |
719 instant_extended_opt_in_state_gate = false; | 719 instant_extended_opt_in_state_gate = false; |
720 } | 720 } |
721 | 721 |
722 } // namespace chrome | 722 } // namespace chrome |
OLD | NEW |