| OLD | NEW |
| 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 // This class contains common functionality for search-based autocomplete | 5 // This class contains common functionality for search-based autocomplete |
| 6 // providers. Search provider and zero suggest provider both use it for common | 6 // providers. Search provider and zero suggest provider both use it for common |
| 7 // functionality. | 7 // functionality. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| 10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Returns an AutocompleteMatch with the given |autocomplete_provider| | 106 // Returns an AutocompleteMatch with the given |autocomplete_provider| |
| 107 // for the search |suggestion|, which represents a search via |template_url|. | 107 // for the search |suggestion|, which represents a search via |template_url|. |
| 108 // If |template_url| is NULL, returns a match with an invalid destination URL. | 108 // If |template_url| is NULL, returns a match with an invalid destination URL. |
| 109 // | 109 // |
| 110 // |input| is the original user input. Text in the input is used to highlight | 110 // |input| is the original user input. Text in the input is used to highlight |
| 111 // portions of the match contents to distinguish locally-typed text from | 111 // portions of the match contents to distinguish locally-typed text from |
| 112 // suggested text. | 112 // suggested text. |
| 113 // | 113 // |
| 114 // |input| is also necessary for various other details, like whether we should | 114 // |input| is also necessary for various other details, like whether we should |
| 115 // allow inline autocompletion and what the transition type should be. | 115 // allow inline autocompletion and what the transition type should be. |
| 116 // |in_keyword_mode| helps guarantee a non-keyword suggestion does not |
| 117 // appear as the default match when the user is in keyword mode. |
| 116 // |accepted_suggestion| is used to generate Assisted Query Stats. | 118 // |accepted_suggestion| is used to generate Assisted Query Stats. |
| 117 // |append_extra_query_params| should be set if |template_url| is the default | 119 // |append_extra_query_params| should be set if |template_url| is the default |
| 118 // search engine, so the destination URL will contain any | 120 // search engine, so the destination URL will contain any |
| 119 // command-line-specified query params. | 121 // command-line-specified query params. |
| 120 static AutocompleteMatch CreateSearchSuggestion( | 122 static AutocompleteMatch CreateSearchSuggestion( |
| 121 AutocompleteProvider* autocomplete_provider, | 123 AutocompleteProvider* autocomplete_provider, |
| 122 const AutocompleteInput& input, | 124 const AutocompleteInput& input, |
| 125 const bool in_keyword_mode, |
| 123 const SearchSuggestionParser::SuggestResult& suggestion, | 126 const SearchSuggestionParser::SuggestResult& suggestion, |
| 124 const TemplateURL* template_url, | 127 const TemplateURL* template_url, |
| 125 const SearchTermsData& search_terms_data, | 128 const SearchTermsData& search_terms_data, |
| 126 int accepted_suggestion, | 129 int accepted_suggestion, |
| 127 bool append_extra_query_params); | 130 bool append_extra_query_params); |
| 128 | 131 |
| 129 // Returns whether the requirements for requesting zero suggest results | 132 // Returns whether the requirements for requesting zero suggest results |
| 130 // are met. The requirements are | 133 // are met. The requirements are |
| 131 // * The user is enrolled in a zero suggest experiment. | 134 // * The user is enrolled in a zero suggest experiment. |
| 132 // * The user is not on the NTP. | 135 // * The user is not on the NTP. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // the key |kDeletionUrlKey|. | 176 // the key |kDeletionUrlKey|. |
| 174 void SetDeletionURL(const std::string& deletion_url, | 177 void SetDeletionURL(const std::string& deletion_url, |
| 175 AutocompleteMatch* match); | 178 AutocompleteMatch* match); |
| 176 | 179 |
| 177 // Creates an AutocompleteMatch from |result| to search for the query in | 180 // Creates an AutocompleteMatch from |result| to search for the query in |
| 178 // |result|. Adds the created match to |map|; if such a match | 181 // |result|. Adds the created match to |map|; if such a match |
| 179 // already exists, whichever one has lower relevance is eliminated. | 182 // already exists, whichever one has lower relevance is eliminated. |
| 180 // |metadata| and |accepted_suggestion| are used for generating an | 183 // |metadata| and |accepted_suggestion| are used for generating an |
| 181 // AutocompleteMatch. | 184 // AutocompleteMatch. |
| 182 // |mark_as_deletable| indicates whether the match should be marked deletable. | 185 // |mark_as_deletable| indicates whether the match should be marked deletable. |
| 186 // |in_keyword_mode| helps guarantee a non-keyword suggestion does not |
| 187 // appear as the default match when the user is in keyword mode. |
| 183 // NOTE: Any result containing a deletion URL is always marked deletable. | 188 // NOTE: Any result containing a deletion URL is always marked deletable. |
| 184 void AddMatchToMap(const SearchSuggestionParser::SuggestResult& result, | 189 void AddMatchToMap(const SearchSuggestionParser::SuggestResult& result, |
| 185 const std::string& metadata, | 190 const std::string& metadata, |
| 186 int accepted_suggestion, | 191 int accepted_suggestion, |
| 187 bool mark_as_deletable, | 192 bool mark_as_deletable, |
| 193 bool in_keyword_mode, |
| 188 MatchMap* map); | 194 MatchMap* map); |
| 189 | 195 |
| 190 // Parses results from the suggest server and updates the appropriate suggest | 196 // Parses results from the suggest server and updates the appropriate suggest |
| 191 // and navigation result lists in |results|. |default_result_relevance| is | 197 // and navigation result lists in |results|. |default_result_relevance| is |
| 192 // the relevance to use if it was not explicitly set by the server. | 198 // the relevance to use if it was not explicitly set by the server. |
| 193 // |is_keyword_result| indicates whether the response was received from the | 199 // |is_keyword_result| indicates whether the response was received from the |
| 194 // keyword provider. | 200 // keyword provider. |
| 195 // Returns whether the appropriate result list members were updated. | 201 // Returns whether the appropriate result list members were updated. |
| 196 bool ParseSuggestResults(const base::Value& root_val, | 202 bool ParseSuggestResults(const base::Value& root_val, |
| 197 int default_result_relevance, | 203 int default_result_relevance, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 259 |
| 254 // Each deletion handler in this vector corresponds to an outstanding request | 260 // Each deletion handler in this vector corresponds to an outstanding request |
| 255 // that a server delete a personalized suggestion. Making this a ScopedVector | 261 // that a server delete a personalized suggestion. Making this a ScopedVector |
| 256 // causes us to auto-cancel all such requests on shutdown. | 262 // causes us to auto-cancel all such requests on shutdown. |
| 257 SuggestionDeletionHandlers deletion_handlers_; | 263 SuggestionDeletionHandlers deletion_handlers_; |
| 258 | 264 |
| 259 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 265 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
| 260 }; | 266 }; |
| 261 | 267 |
| 262 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 268 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| OLD | NEW |