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 10 matching lines...) Expand all Loading... | |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "base/timer.h" | 22 #include "base/timer.h" |
| 23 #include "chrome/browser/autocomplete/autocomplete_input.h" | 23 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete_match.h" | 24 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 25 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 25 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 26 #include "chrome/browser/history/history_types.h" | 26 #include "chrome/browser/history/history_types.h" |
| 27 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
| 28 #include "chrome/common/instant_types.h" | 28 #include "chrome/common/instant_types.h" |
| 29 #include "net/url_request/url_fetcher_delegate.h" | 29 #include "net/url_request/url_fetcher_delegate.h" |
| 30 | 30 |
| 31 class SearchProviderTest; | |
|
msw
2013/04/03 23:28:48
nit: alphabetize this.
Mark P
2013/04/03 23:58:39
Done.
| |
| 31 class Profile; | 32 class Profile; |
| 32 class TemplateURLService; | 33 class TemplateURLService; |
| 33 | 34 |
| 34 namespace base { | 35 namespace base { |
| 35 class Value; | 36 class Value; |
| 36 } | 37 } |
| 37 | 38 |
| 38 namespace net { | 39 namespace net { |
| 39 class URLFetcher; | 40 class URLFetcher; |
| 40 } | 41 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 virtual void ResetSession() OVERRIDE; | 79 virtual void ResetSession() OVERRIDE; |
| 79 | 80 |
| 80 // net::URLFetcherDelegate | 81 // net::URLFetcherDelegate |
| 81 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 82 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 82 | 83 |
| 83 bool field_trial_triggered_in_session() const { | 84 bool field_trial_triggered_in_session() const { |
| 84 return field_trial_triggered_in_session_; | 85 return field_trial_triggered_in_session_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 // ID used in creating URLFetcher for default provider's suggest results. | 88 // ID used in creating URLFetcher for default provider's suggest results. |
| 88 static const int kDefaultProviderURLFetcherID; | 89 static const int kDefaultProviderURLFetcherID; |
|
msw
2013/04/03 23:28:48
optional nit: move this and kKeywordProviderURLFet
Mark P
2013/04/03 23:58:39
Done.
| |
| 89 | 90 |
| 90 // ID used in creating URLFetcher for keyword provider's suggest results. | 91 // ID used in creating URLFetcher for keyword provider's suggest results. |
| 91 static const int kKeywordProviderURLFetcherID; | 92 static const int kKeywordProviderURLFetcherID; |
| 92 | 93 |
| 93 private: | 94 private: |
| 95 friend class SearchProviderTest; | |
| 94 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 96 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 95 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 97 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 96 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 98 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 97 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 99 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 98 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); | 100 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
| 99 | 101 |
| 100 virtual ~SearchProvider(); | 102 virtual ~SearchProvider(); |
| 101 | 103 |
| 102 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 104 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
| 103 // may be used: | 105 // may be used: |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 string16 description_; | 241 string16 description_; |
| 240 }; | 242 }; |
| 241 | 243 |
| 242 typedef std::vector<SuggestResult> SuggestResults; | 244 typedef std::vector<SuggestResult> SuggestResults; |
| 243 typedef std::vector<NavigationResult> NavigationResults; | 245 typedef std::vector<NavigationResult> NavigationResults; |
| 244 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; | 246 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; |
| 245 typedef std::map<string16, AutocompleteMatch> MatchMap; | 247 typedef std::map<string16, AutocompleteMatch> MatchMap; |
| 246 | 248 |
| 247 class CompareScoredResults; | 249 class CompareScoredResults; |
| 248 | 250 |
| 251 // The amount of time to wait before sending a new suggest request after | |
| 252 // the previous one. | |
| 253 static int kMinimumTimeBetweenSuggestQueriesMs; | |
|
msw
2013/04/03 23:28:48
This belongs at line 102 before "virtual ~SearchPr
Mark P
2013/04/03 23:58:39
Done.
| |
| 254 | |
| 249 // Called when timer_ expires. | 255 // Called when timer_ expires. |
| 250 void Run(); | 256 void Run(); |
| 251 | 257 |
| 252 // Runs the history query, if necessary. The history query is synchronous. | 258 // Runs the history query, if necessary. The history query is synchronous. |
| 253 // This does not update |done_|. | 259 // This does not update |done_|. |
| 254 void DoHistoryQuery(bool minimal_changes); | 260 void DoHistoryQuery(bool minimal_changes); |
| 255 | 261 |
| 256 // Determines whether an asynchronous subcomponent query should run for the | 262 // Determines whether an asynchronous subcomponent query should run for the |
| 257 // current input. If so, starts it if necessary; otherwise stops it. | 263 // current input. If so, starts it if necessary; otherwise stops it. |
| 258 // NOTE: This function does not update |done_|. Callers must do so. | 264 // NOTE: This function does not update |done_|. Callers must do so. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 bool field_trial_triggered_; | 467 bool field_trial_triggered_; |
| 462 | 468 |
| 463 // Same as above except that it is maintained across the current Omnibox | 469 // Same as above except that it is maintained across the current Omnibox |
| 464 // session. | 470 // session. |
| 465 bool field_trial_triggered_in_session_; | 471 bool field_trial_triggered_in_session_; |
| 466 | 472 |
| 467 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 473 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 468 }; | 474 }; |
| 469 | 475 |
| 470 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 476 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |