Chromium Code Reviews| 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 // This file contains the Search autocomplete provider. This provider is | 5 // This file contains the Search autocomplete provider. This provider is |
| 6 // responsible for all autocomplete entries that start with "Search <engine> | 6 // responsible for all autocomplete entries that start with "Search <engine> |
| 7 // for ...", including searching for the current input string, search | 7 // for ...", including searching for the current input string, search |
| 8 // history, and search suggestions. An instance of it gets created and | 8 // history, and search suggestions. An instance of it gets created and |
| 9 // managed by the autocomplete controller. | 9 // managed by the autocomplete controller. |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 90 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 91 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 91 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 92 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 92 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 93 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 93 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 94 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); | 94 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); |
| 95 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); | 95 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); |
| 96 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); | 96 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); |
| 97 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); | 97 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); |
| 98 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveExtraAnswers); | 98 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveExtraAnswers); |
| 99 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoesNotProvideOnFocus); | 99 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoesNotProvideOnFocus); |
| 100 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SendsWarmUpRequestOnFocus); | |
| 100 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); | 101 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); |
| 101 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); | 102 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); |
| 102 | 103 |
| 103 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 104 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
| 104 // may be used: | 105 // may be used: |
| 105 // . The default provider. This corresponds to the user's default search | 106 // . The default provider. This corresponds to the user's default search |
| 106 // engine. This is always used, except for the rare case of no default | 107 // engine. This is always used, except for the rare case of no default |
| 107 // engine. | 108 // engine. |
| 108 // . The keyword provider. This is used if the user has typed in a keyword. | 109 // . The keyword provider. This is used if the user has typed in a keyword. |
| 109 class Providers { | 110 class Providers { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 // Called after ParseSuggestResults to rank the |results|. | 189 // Called after ParseSuggestResults to rank the |results|. |
| 189 void SortResults(bool is_keyword, SearchSuggestionParser::Results* results); | 190 void SortResults(bool is_keyword, SearchSuggestionParser::Results* results); |
| 190 | 191 |
| 191 // Records UMA statistics about a suggest server response. | 192 // Records UMA statistics about a suggest server response. |
| 192 void LogFetchComplete(bool success, bool is_keyword); | 193 void LogFetchComplete(bool success, bool is_keyword); |
| 193 | 194 |
| 194 // Updates |matches_| from the latest results; applies calculated relevances | 195 // Updates |matches_| from the latest results; applies calculated relevances |
| 195 // if suggested relevances cause undesirable behavior. Updates |done_|. | 196 // if suggested relevances cause undesirable behavior. Updates |done_|. |
| 196 void UpdateMatches(); | 197 void UpdateMatches(); |
| 197 | 198 |
| 199 // Check constraints that may be violated by suggested relevances and revises/ | |
|
Peter Kasting
2017/03/02 22:50:42
Nit: Check -> Checks
Mark P
2017/03/03 22:12:24
Done.
| |
| 200 // rolls back the suggested relevance scores to make all constraints old. | |
|
Peter Kasting
2017/03/02 22:50:42
Nit: old -> hold
Mark P
2017/03/03 22:12:24
Done.
| |
| 201 void EnforceConstraints(); | |
| 202 | |
| 203 // Record the top suggestion (if any) for future use. SearchProvider tries | |
|
Peter Kasting
2017/03/02 22:50:42
Nit: Record -> Records
Mark P
2017/03/03 22:12:24
Done.
| |
| 204 // to ensure that an inline autocomplete suggestion does not change | |
| 205 // asynchronously. | |
| 206 void RecordTopSuggestion(); | |
| 207 | |
| 198 // Called when |timer_| expires. Sends the suggest requests. | 208 // Called when |timer_| expires. Sends the suggest requests. |
| 199 // If |query_is_private|, the function doesn't send this query to the default | 209 // If |query_is_private|, the function doesn't send this query to the default |
| 200 // provider. | 210 // provider. |
| 201 void Run(bool query_is_private); | 211 void Run(bool query_is_private); |
| 202 | 212 |
| 203 // Runs the history query, if necessary. The history query is synchronous. | 213 // Runs the history query, if necessary. The history query is synchronous. |
| 204 // This does not update |done_|. | 214 // This does not update |done_|. |
| 205 void DoHistoryQuery(bool minimal_changes); | 215 void DoHistoryQuery(bool minimal_changes); |
| 206 | 216 |
| 207 // Returns the time to delay before sending the Suggest request. | 217 // Returns the time to delay before sending the Suggest request. |
| 208 base::TimeDelta GetSuggestQueryDelay() const; | 218 base::TimeDelta GetSuggestQueryDelay() const; |
| 209 | 219 |
| 210 // Determines whether an asynchronous subcomponent query should run for the | 220 // Determines whether an asynchronous subcomponent query should run for the |
| 211 // current input. If so, starts it if necessary; otherwise stops it. | 221 // current input. If so, starts it if necessary; otherwise stops it. |
| 212 // NOTE: This function does not update |done_|. Callers must do so. | 222 // NOTE: This function does not update |done_|. Callers must do so. |
| 213 void StartOrStopSuggestQuery(bool minimal_changes); | 223 void StartOrStopSuggestQuery(bool minimal_changes); |
| 214 | 224 |
| 215 // Stops |fetcher| if it's running. This includes resetting the scoped_ptr. | 225 // Stops |fetcher| if it's running. This includes resetting the scoped_ptr. |
| 216 void CancelFetcher(std::unique_ptr<net::URLFetcher>* fetcher); | 226 void CancelFetcher(std::unique_ptr<net::URLFetcher>* fetcher); |
| 217 | 227 |
| 218 // Returns true when the current query can be sent to at least one suggest | 228 // Returns true when the current query can be sent to at least one suggest |
| 219 // service. This will be false for example when suggest is disabled. In | 229 // service. This will be false for example when suggest is disabled. In |
| 220 // the process, calculates whether the query may contain potentionally | 230 // the process, calculates whether the query may contain potentionally |
| 221 // private data and stores the result in |is_query_private|; such queries | 231 // private data and stores the result in |is_query_private|; such queries |
| 222 // should not be sent to the default search engine. | 232 // should not be sent to the default search engine. |
| 223 bool IsQuerySuitableForSuggest(bool* query_is_private) const; | 233 bool IsQuerySuitableForSuggest(bool* query_is_private) const; |
| 224 | 234 |
| 225 // Returns true if sending the query to a suggest server may leak sensitive | 235 // Returns true if sending the query to a suggest server may leak sensitive |
| 226 // information (and hence the suggest request shouldn't be sent). | 236 // information (and hence the suggest request shouldn't be sent). In |
| 237 // particular, if the input type might be a URL, we take extra care so that | |
| 238 // it isn't sent to the server. | |
| 227 bool IsQueryPotentionallyPrivate() const; | 239 bool IsQueryPotentionallyPrivate() const; |
| 228 | 240 |
| 229 // Remove existing keyword results if the user is no longer in keyword mode, | 241 // Remove existing keyword results if the user is no longer in keyword mode, |
| 230 // and, if |minimal_changes| is false, revise the existing results to | 242 // and, if |minimal_changes| is false, revise the existing results to |
| 231 // indicate they were received before the last keystroke. | 243 // indicate they were received before the last keystroke. |
| 232 void UpdateAllOldResults(bool minimal_changes); | 244 void UpdateAllOldResults(bool minimal_changes); |
| 233 | 245 |
| 234 // Given new asynchronous results, ensure that we don't clobber the current | 246 // Given new asynchronous results, ensure that we don't clobber the current |
| 235 // top results, which were determined synchronously on the last keystroke. | 247 // top results, which were determined synchronously on the last keystroke. |
| 236 void PersistTopSuggestions(SearchSuggestionParser::Results* results); | 248 void PersistTopSuggestions(SearchSuggestionParser::Results* results); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 base::TimeTicks token_expiration_time_; | 412 base::TimeTicks token_expiration_time_; |
| 401 | 413 |
| 402 // Answers prefetch management. | 414 // Answers prefetch management. |
| 403 AnswersCache answers_cache_; // Cache for last answers seen. | 415 AnswersCache answers_cache_; // Cache for last answers seen. |
| 404 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 416 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
| 405 | 417 |
| 406 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 418 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 407 }; | 419 }; |
| 408 | 420 |
| 409 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_PROVIDER_H_ | 421 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_PROVIDER_H_ |
| OLD | NEW |