Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/search/search.cc

Issue 1131493004: Switch //chrome functions to use SchemeIsCryptographic() instead of SchemeIsSecure(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use inner URL for a filesystem calculation. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return false; 168 return false;
169 } 169 }
170 170
171 171
172 172
173 // |url| should either have a secure scheme or have a non-HTTPS base URL that 173 // |url| should either have a secure scheme or have a non-HTTPS base URL that
174 // the user specified using --google-base-url. (This allows testers to use 174 // the user specified using --google-base-url. (This allows testers to use
175 // --google-base-url to point at non-HTTPS servers, which eases testing.) 175 // --google-base-url to point at non-HTTPS servers, which eases testing.)
176 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { 176 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) {
177 return template_url->HasSearchTermsReplacementKey(url) && 177 return template_url->HasSearchTermsReplacementKey(url) &&
178 (url.SchemeIsSecure() || 178 (url.SchemeIsCryptographic() ||
179 google_util::StartsWithCommandLineGoogleBaseURL(url)); 179 google_util::StartsWithCommandLineGoogleBaseURL(url));
180 } 180 }
181 181
182 // Returns true if |url| can be used as an Instant URL for |profile|. 182 // Returns true if |url| can be used as an Instant URL for |profile|.
183 bool IsInstantURL(const GURL& url, Profile* profile) { 183 bool IsInstantURL(const GURL& url, Profile* profile) {
184 if (!IsInstantExtendedAPIEnabled()) 184 if (!IsInstantExtendedAPIEnabled())
185 return false; 185 return false;
186 186
187 if (!url.is_valid()) 187 if (!url.is_valid())
188 return false; 188 return false;
189 189
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return true; 257 return true;
258 } 258 }
259 259
260 // Returns whether |new_tab_url| can be used as a URL for the New Tab page. 260 // Returns whether |new_tab_url| can be used as a URL for the New Tab page.
261 // NEW_TAB_URL_VALID means a valid URL; other enum values imply an invalid URL. 261 // NEW_TAB_URL_VALID means a valid URL; other enum values imply an invalid URL.
262 NewTabURLState IsValidNewTabURL(Profile* profile, const GURL& new_tab_url) { 262 NewTabURLState IsValidNewTabURL(Profile* profile, const GURL& new_tab_url) {
263 if (profile->IsOffTheRecord()) 263 if (profile->IsOffTheRecord())
264 return NEW_TAB_URL_INCOGNITO; 264 return NEW_TAB_URL_INCOGNITO;
265 if (!new_tab_url.is_valid()) 265 if (!new_tab_url.is_valid())
266 return NEW_TAB_URL_NOT_SET; 266 return NEW_TAB_URL_NOT_SET;
267 if (!new_tab_url.SchemeIsSecure()) 267 if (!new_tab_url.SchemeIsCryptographic())
268 return NEW_TAB_URL_INSECURE; 268 return NEW_TAB_URL_INSECURE;
269 if (!IsURLAllowedForSupervisedUser(new_tab_url, profile)) 269 if (!IsURLAllowedForSupervisedUser(new_tab_url, profile))
270 return NEW_TAB_URL_BLOCKED; 270 return NEW_TAB_URL_BLOCKED;
271 return NEW_TAB_URL_VALID; 271 return NEW_TAB_URL_VALID;
272 } 272 }
273 273
274 // Used to look up the URL to use for the New Tab page. Also tracks how we 274 // Used to look up the URL to use for the New Tab page. Also tracks how we
275 // arrived at that URL so it can be logged with UMA. 275 // arrived at that URL so it can be logged with UMA.
276 struct NewTabURLDetails { 276 struct NewTabURLDetails {
277 NewTabURLDetails(const GURL& url, NewTabURLState state) 277 NewTabURLDetails(const GURL& url, NewTabURLState state)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 GURL instant_url = TemplateURLRefToGURL( 474 GURL instant_url = TemplateURLRefToGURL(
475 template_url->instant_url_ref(), UIThreadSearchTermsData(profile), 475 template_url->instant_url_ref(), UIThreadSearchTermsData(profile),
476 true, force_instant_results); 476 true, force_instant_results);
477 if (!instant_url.is_valid() || 477 if (!instant_url.is_valid() ||
478 !template_url->HasSearchTermsReplacementKey(instant_url)) 478 !template_url->HasSearchTermsReplacementKey(instant_url))
479 return GURL(); 479 return GURL();
480 480
481 // Extended mode requires HTTPS. Force it unless the base URL was overridden 481 // Extended mode requires HTTPS. Force it unless the base URL was overridden
482 // on the command line, in which case we allow HTTP (see comments on 482 // on the command line, in which case we allow HTTP (see comments on
483 // IsSuitableURLForInstant()). 483 // IsSuitableURLForInstant()).
484 if (!instant_url.SchemeIsSecure() && 484 if (!instant_url.SchemeIsCryptographic() &&
485 !google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) { 485 !google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) {
486 GURL::Replacements replacements; 486 GURL::Replacements replacements;
487 replacements.SetSchemeStr(url::kHttpsScheme); 487 replacements.SetSchemeStr(url::kHttpsScheme);
488 instant_url = instant_url.ReplaceComponents(replacements); 488 instant_url = instant_url.ReplaceComponents(replacements);
489 } 489 }
490 490
491 if (!IsURLAllowedForSupervisedUser(instant_url, profile)) 491 if (!IsURLAllowedForSupervisedUser(instant_url, profile))
492 return GURL(); 492 return GURL();
493 493
494 if (ShouldUseAltInstantURL()) { 494 if (ShouldUseAltInstantURL()) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 kUseAltInstantURL, false, flags); 696 kUseAltInstantURL, false, flags);
697 } 697 }
698 698
699 bool ShouldUseSearchPathForInstant() { 699 bool ShouldUseSearchPathForInstant() {
700 FieldTrialFlags flags; 700 FieldTrialFlags flags;
701 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 701 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
702 kUseSearchPathForInstant, false, flags); 702 kUseSearchPathForInstant, false, flags);
703 } 703 }
704 704
705 } // namespace chrome 705 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater_unittest.cc ('k') | chrome/browser/signin/signin_header_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698