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

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: possible fix for mac code (cannot compile mac code myself) 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. |languages| is used to format punycoded
193 // domain names to UTF-8 for the aforementioned duplicate detection.
188 static GURL GURLToStrippedGURL(const GURL& url, 194 static GURL GURLToStrippedGURL(const GURL& url,
195 const AutocompleteInput& input,
196 const std::string& languages,
189 TemplateURLService* template_url_service, 197 TemplateURLService* template_url_service,
190 const base::string16& keyword); 198 const base::string16& keyword);
191 199
192 // Computes the stripped destination URL (via GURLToStrippedGURL()) and 200 // Computes the stripped destination URL (via GURLToStrippedGURL()) and
193 // stores the result in |stripped_destination_url|. 201 // stores the result in |stripped_destination_url|.
Peter Kasting 2015/06/29 05:04:59 Nit: For this function and the next, I would proba
Mark P 2015/06/30 04:23:17 Done.
194 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); 202 void ComputeStrippedDestinationURL(
203 const AutocompleteInput& input,
204 const std::string& languages,
205 TemplateURLService* template_url_service);
195 206
196 // Sets |allowed_to_be_default_match| to true if this match is effectively 207 // 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 208 // the URL-what-you-typed match (i.e., would be dupped against the UWYT
198 // match when AutocompleteResult merges matches). |canonical_input_url| is 209 // match when AutocompleteResult merges matches).
199 // the AutocompleteInput interpreted as a URL (i.e., 210 void EnsureUWYTIsAllowedToBeDefault(
200 // AutocompleteInput::canonicalized_url()). 211 const AutocompleteInput& input,
201 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, 212 const std::string& languages,
202 TemplateURLService* template_url_service); 213 TemplateURLService* template_url_service);
203 214
204 // Gets data relevant to whether there should be any special keyword-related 215 // 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. 216 // 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 217 // 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 218 // 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 ___" 219 // |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 220 // 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 221 // 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 222 // 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| 223 // 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, 405 const base::string16& text,
395 const ACMatchClassifications& classifications) const; 406 const ACMatchClassifications& classifications) const;
396 #endif 407 #endif
397 }; 408 };
398 409
399 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; 410 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification;
400 typedef std::vector<ACMatchClassification> ACMatchClassifications; 411 typedef std::vector<ACMatchClassification> ACMatchClassifications;
401 typedef std::vector<AutocompleteMatch> ACMatches; 412 typedef std::vector<AutocompleteMatch> ACMatches;
402 413
403 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ 414 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698