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

Unified Diff: components/omnibox/autocomplete_match.cc

Issue 1098843004: Omnibox - Do Not Allow HTTP/HTTPS Equivalence if User Explicitly Entered A Scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new approach Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/omnibox/autocomplete_match.cc
diff --git a/components/omnibox/autocomplete_match.cc b/components/omnibox/autocomplete_match.cc
index d0b4c71e0f4f4ab2ac7737a3dd0f829dbe7f36d2..ec658075516ead65e24cee4b3bf0fa6ca29eb02f 100644
--- a/components/omnibox/autocomplete_match.cc
+++ b/components/omnibox/autocomplete_match.cc
@@ -374,6 +374,7 @@ TemplateURL* AutocompleteMatch::GetTemplateURLWithKeyword(
// static
GURL AutocompleteMatch::GURLToStrippedGURL(
const GURL& url,
+ const bool scheme_explicitly_entered,
TemplateURLService* template_url_service,
const base::string16& keyword) {
if (!url.is_valid())
@@ -419,8 +420,9 @@ GURL AutocompleteMatch::GURLToStrippedGURL(
needs_replacement = true;
}
- // Replace https protocol with http protocol.
- if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) {
+ // Possibly replace https protocol with http protocol.
+ if (!scheme_explicitly_entered &&
+ stripped_destination_url.SchemeIs(url::kHttpsScheme)) {
replacements.SetScheme(url::kHttpScheme,
url::Component(0, strlen(url::kHttpScheme)));
needs_replacement = true;
@@ -433,19 +435,23 @@ GURL AutocompleteMatch::GURLToStrippedGURL(
}
void AutocompleteMatch::ComputeStrippedDestinationURL(
+ const bool scheme_explicitly_entered,
TemplateURLService* template_url_service) {
- stripped_destination_url =
- GURLToStrippedGURL(destination_url, template_url_service, keyword);
+ stripped_destination_url = GURLToStrippedGURL(
+ destination_url, scheme_explicitly_entered,template_url_service, keyword);
}
void AutocompleteMatch::EnsureUWYTIsAllowedToBeDefault(
const GURL& canonical_input_url,
+ const bool scheme_explicitly_entered,
TemplateURLService* template_url_service) {
if (!allowed_to_be_default_match) {
const GURL& stripped_canonical_input_url =
AutocompleteMatch::GURLToStrippedGURL(
- canonical_input_url, template_url_service, base::string16());
- ComputeStrippedDestinationURL(template_url_service);
+ canonical_input_url, scheme_explicitly_entered,
+ template_url_service, base::string16());
+ ComputeStrippedDestinationURL(scheme_explicitly_entered,
+ template_url_service);
allowed_to_be_default_match =
stripped_canonical_input_url == stripped_destination_url;
}

Powered by Google App Engine
This is Rietveld 408576698