| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/common/autocomplete_match_type.h" | 13 #include "chrome/common/autocomplete_match_type.h" |
| 14 #include "components/search_engines/template_url.h" | 14 #include "components/search_engines/template_url.h" |
| 15 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 class AutocompleteProvider; | 18 class AutocompleteProvider; |
| 19 class Profile; |
| 19 class TemplateURL; | 20 class TemplateURL; |
| 20 class TemplateURLService; | |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class Time; | 23 class Time; |
| 24 } // namespace base | 24 } // namespace base |
| 25 | 25 |
| 26 const char kACMatchPropertyInputText[] = "input text"; | 26 const char kACMatchPropertyInputText[] = "input text"; |
| 27 const char kACMatchPropertyContentsPrefix[] = "match contents prefix"; | 27 const char kACMatchPropertyContentsPrefix[] = "match contents prefix"; |
| 28 const char kACMatchPropertyContentsStartIndex[] = "match contents start index"; | 28 const char kACMatchPropertyContentsStartIndex[] = "match contents start index"; |
| 29 | 29 |
| 30 // AutocompleteMatch ---------------------------------------------------------- | 30 // AutocompleteMatch ---------------------------------------------------------- |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Convenience function to check if |type| is a special search suggest type - | 167 // Convenience function to check if |type| is a special search suggest type - |
| 168 // like entity, personalized, profile or postfix. | 168 // like entity, personalized, profile or postfix. |
| 169 static bool IsSpecializedSearchType(Type type); | 169 static bool IsSpecializedSearchType(Type type); |
| 170 | 170 |
| 171 // Copies the destination_url with "www." stripped off to | 171 // Copies the destination_url with "www." stripped off to |
| 172 // |stripped_destination_url| and also converts https protocol to | 172 // |stripped_destination_url| and also converts https protocol to |
| 173 // http. These two conversions are merely to allow comparisons to | 173 // http. These two conversions are merely to allow comparisons to |
| 174 // remove likely duplicates; these URLs are not used as actual | 174 // remove likely duplicates; these URLs are not used as actual |
| 175 // destination URLs. This method is invoked internally by the | 175 // destination URLs. This method is invoked internally by the |
| 176 // AutocompleteResult and does not normally need to be invoked. | 176 // AutocompleteResult and does not normally need to be invoked. |
| 177 // If |template_url_service| is not NULL, it is used to get a template URL | 177 // If |profile| is not NULL, it is used to get a template URL corresponding |
| 178 // corresponding to this match. The template is used to strip off query args | 178 // to this match. The template is used to strip off query args other than |
| 179 // other than the search terms themselves that would otherwise prevent from | 179 // the search terms themselves that would otherwise prevent from proper |
| 180 // proper deduping. | 180 // deduping. |
| 181 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 181 void ComputeStrippedDestinationURL(Profile* profile); |
| 182 | 182 |
| 183 // Gets data relevant to whether there should be any special keyword-related | 183 // Gets data relevant to whether there should be any special keyword-related |
| 184 // UI shown for this match. If this match represents a selected keyword, i.e. | 184 // UI shown for this match. If this match represents a selected keyword, i.e. |
| 185 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 185 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
| 186 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 186 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
| 187 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 187 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
| 188 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 188 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
| 189 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 189 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
| 190 // that only one of these states can be in effect at once. In all other | 190 // that only one of these states can be in effect at once. In all other |
| 191 // cases, |keyword| will be cleared, even when our member variable |keyword| | 191 // cases, |keyword| will be cleared, even when our member variable |keyword| |
| 192 // is non-empty -- such as with non-substituting keywords or matches that | 192 // is non-empty -- such as with non-substituting keywords or matches that |
| 193 // represent searches using the default search engine. See also | 193 // represent searches using the default search engine. See also |
| 194 // GetSubstitutingExplicitlyInvokedKeyword(). | 194 // GetSubstitutingExplicitlyInvokedKeyword(). |
| 195 void GetKeywordUIState(TemplateURLService* template_url_service, | 195 void GetKeywordUIState(Profile* profile, |
| 196 base::string16* keyword, | 196 base::string16* keyword, |
| 197 bool* is_keyword_hint) const; | 197 bool* is_keyword_hint) const; |
| 198 | 198 |
| 199 // Returns |keyword|, but only if it represents a substituting keyword that | 199 // Returns |keyword|, but only if it represents a substituting keyword that |
| 200 // the user has explicitly invoked. If for example this match represents a | 200 // the user has explicitly invoked. If for example this match represents a |
| 201 // search with the default search engine (and the user didn't explicitly | 201 // search with the default search engine (and the user didn't explicitly |
| 202 // invoke its keyword), this returns the empty string. The result is that | 202 // invoke its keyword), this returns the empty string. The result is that |
| 203 // this function returns a non-empty string in the same cases as when the UI | 203 // this function returns a non-empty string in the same cases as when the UI |
| 204 // should show up as being "in keyword mode". | 204 // should show up as being "in keyword mode". |
| 205 base::string16 GetSubstitutingExplicitlyInvokedKeyword( | 205 base::string16 GetSubstitutingExplicitlyInvokedKeyword( |
| 206 TemplateURLService* template_url_service) const; | 206 Profile* profile) const; |
| 207 | 207 |
| 208 // Returns the TemplateURL associated with this match. This may be NULL if | 208 // Returns the TemplateURL associated with this match. This may be NULL if |
| 209 // the match has no keyword OR if the keyword no longer corresponds to a valid | 209 // the match has no keyword OR if the keyword no longer corresponds to a valid |
| 210 // TemplateURL. See comments on |keyword| below. | 210 // TemplateURL. See comments on |keyword| below. |
| 211 // If |allow_fallback_to_destination_host| is true and the keyword does | 211 // If |allow_fallback_to_destination_host| is true and the keyword does |
| 212 // not map to a valid TemplateURL, we'll then check for a TemplateURL that | 212 // not map to a valid TemplateURL, we'll then check for a TemplateURL that |
| 213 // corresponds to the destination_url's hostname. | 213 // corresponds to the destination_url's hostname. |
| 214 TemplateURL* GetTemplateURL(TemplateURLService* template_url_service, | 214 TemplateURL* GetTemplateURL(Profile* profile, |
| 215 bool allow_fallback_to_destination_host) const; | 215 bool allow_fallback_to_destination_host) const; |
| 216 | 216 |
| 217 // Adds optional information to the |additional_info| dictionary. | 217 // Adds optional information to the |additional_info| dictionary. |
| 218 void RecordAdditionalInfo(const std::string& property, | 218 void RecordAdditionalInfo(const std::string& property, |
| 219 const std::string& value); | 219 const std::string& value); |
| 220 void RecordAdditionalInfo(const std::string& property, int value); | 220 void RecordAdditionalInfo(const std::string& property, int value); |
| 221 void RecordAdditionalInfo(const std::string& property, | 221 void RecordAdditionalInfo(const std::string& property, |
| 222 const base::Time& value); | 222 const base::Time& value); |
| 223 | 223 |
| 224 // Returns the value recorded for |property| in the |additional_info| | 224 // Returns the value recorded for |property| in the |additional_info| |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 const base::string16& text, | 364 const base::string16& text, |
| 365 const ACMatchClassifications& classifications) const; | 365 const ACMatchClassifications& classifications) const; |
| 366 #endif | 366 #endif |
| 367 }; | 367 }; |
| 368 | 368 |
| 369 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 369 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
| 370 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 370 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
| 371 typedef std::vector<AutocompleteMatch> ACMatches; | 371 typedef std::vector<AutocompleteMatch> ACMatches; |
| 372 | 372 |
| 373 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 373 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| OLD | NEW |