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

Side by Side Diff: components/omnibox/autocomplete_match.h

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: revise test cases to be correct Created 5 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ 5 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_
6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 // Returns |url| altered by stripping off "www.", converting https protocol 178 // Returns |url| altered by stripping off "www.", converting https protocol
179 // to http, and stripping excess query parameters. These conversions are 179 // to http, and stripping excess query parameters. These conversions are
180 // merely to allow comparisons to remove likely duplicates; these URLs are 180 // merely to allow comparisons to remove likely duplicates; these URLs are
181 // not used as actual destination URLs. If |template_url_service| is not 181 // not used as actual destination URLs. If |template_url_service| is not
182 // NULL, it is used to get a template URL corresponding to this match. If 182 // NULL, it is used to get a template URL corresponding to this match. If
183 // the match's keyword is known, it can be passed in. Otherwise, it can be 183 // the match's keyword is known, it can be passed in. Otherwise, it can be
184 // left empty and the template URL (if any) is determined from the 184 // left empty and the template URL (if any) is determined from the
185 // destination's hostname. The template URL is used to strip off query args 185 // destination's hostname. The template URL is used to strip off query args
186 // other than the search terms themselves that would otherwise prevent doing 186 // other than the search terms themselves that would otherwise prevent doing
187 // proper deduping. 187 // proper deduping. |input| is used to decide if the scheme is allowed to
188 // be altered during stripping. If this URL, minus the scheme and separator,
189 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we
190 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ
191 // only by these schemes won't be marked as dupes, since the distinction
192 // seems to matter to the user.
188 static GURL GURLToStrippedGURL(const GURL& url, 193 static GURL GURLToStrippedGURL(const GURL& url,
194 const AutocompleteInput& input,
189 TemplateURLService* template_url_service, 195 TemplateURLService* template_url_service,
190 const base::string16& keyword); 196 const base::string16& keyword);
191 197
192 // Computes the stripped destination URL (via GURLToStrippedGURL()) and 198 // Computes the stripped destination URL (via GURLToStrippedGURL()) and
193 // stores the result in |stripped_destination_url|. 199 // stores the result in |stripped_destination_url|.
194 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); 200 void ComputeStrippedDestinationURL(
201 const AutocompleteInput& input,
202 TemplateURLService* template_url_service);
195 203
196 // Sets |allowed_to_be_default_match| to true if this match is effectively 204 // Sets |allowed_to_be_default_match| to true if this match is effectively
197 // the URL-what-you-typed match (i.e., would be dupped against the UWYT 205 // the URL-what-you-typed match (i.e., would be dupped against the UWYT
198 // match when AutocompleteResult merges matches). |canonical_input_url| is 206 // match when AutocompleteResult merges matches).
199 // the AutocompleteInput interpreted as a URL (i.e., 207 void EnsureUWYTIsAllowedToBeDefault(
200 // AutocompleteInput::canonicalized_url()). 208 const AutocompleteInput& input,
201 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, 209 TemplateURLService* template_url_service);
202 TemplateURLService* template_url_service);
203 210
204 // Gets data relevant to whether there should be any special keyword-related 211 // Gets data relevant to whether there should be any special keyword-related
205 // UI shown for this match. If this match represents a selected keyword, i.e. 212 // UI shown for this match. If this match represents a selected keyword, i.e.
206 // the UI should be "in keyword mode", |keyword| will be set to the keyword 213 // the UI should be "in keyword mode", |keyword| will be set to the keyword
207 // and |is_keyword_hint| will be set to false. If this match has a non-NULL 214 // and |is_keyword_hint| will be set to false. If this match has a non-NULL
208 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" 215 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___"
209 // hint and allow the user to toggle into keyword mode, |keyword| will be set 216 // hint and allow the user to toggle into keyword mode, |keyword| will be set
210 // to the associated keyword and |is_keyword_hint| will be set to true. Note 217 // to the associated keyword and |is_keyword_hint| will be set to true. Note
211 // that only one of these states can be in effect at once. In all other 218 // that only one of these states can be in effect at once. In all other
212 // cases, |keyword| will be cleared, even when our member variable |keyword| 219 // cases, |keyword| will be cleared, even when our member variable |keyword|
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 const base::string16& text, 401 const base::string16& text,
395 const ACMatchClassifications& classifications) const; 402 const ACMatchClassifications& classifications) const;
396 #endif 403 #endif
397 }; 404 };
398 405
399 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; 406 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification;
400 typedef std::vector<ACMatchClassification> ACMatchClassifications; 407 typedef std::vector<ACMatchClassification> ACMatchClassifications;
401 typedef std::vector<AutocompleteMatch> ACMatches; 408 typedef std::vector<AutocompleteMatch> ACMatches;
402 409
403 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ 410 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698