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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_controller.h

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add !! for windows Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 28 matching lines...) Expand all
39 // happen on the same thread. AutocompleteProviders are responsible for doing 39 // happen on the same thread. AutocompleteProviders are responsible for doing
40 // their own thread management when they need to return matches asynchronously. 40 // their own thread management when they need to return matches asynchronously.
41 // 41 //
42 // The coordinator for autocomplete queries, responsible for combining the 42 // The coordinator for autocomplete queries, responsible for combining the
43 // matches from a series of providers into one AutocompleteResult. 43 // matches from a series of providers into one AutocompleteResult.
44 class AutocompleteController : public AutocompleteProviderListener { 44 class AutocompleteController : public AutocompleteProviderListener {
45 public: 45 public:
46 // Used to indicate an index that is not selected in a call to Update(). 46 // Used to indicate an index that is not selected in a call to Update().
47 static const int kNoItemSelected; 47 static const int kNoItemSelected;
48 48
49 // Normally, you will call the first constructor. Unit tests can use the 49 // |provider_types| is a bitmap containing AutocompleteProvider::Type values
50 // second to set the providers to some known testing providers. The default 50 // that will (potentially, depending on platform, flags, etc.) be
51 // providers will be overridden and the controller will take ownership of the 51 // instantiated.
52 // providers, Release()ing them on destruction.
53 AutocompleteController(Profile* profile, 52 AutocompleteController(Profile* profile,
54 AutocompleteControllerDelegate* delegate); 53 AutocompleteControllerDelegate* delegate,
55 #ifdef UNIT_TEST 54 int provider_types);
56 AutocompleteController(const ACProviders& providers, Profile* profile)
57 : delegate_(NULL),
58 providers_(providers),
59 keyword_provider_(NULL),
60 search_provider_(NULL),
61 done_(true),
62 in_start_(false),
63 profile_(profile) {
64 }
65 #endif
66 ~AutocompleteController(); 55 ~AutocompleteController();
67 56
68 // Starts an autocomplete query, which continues until all providers are 57 // Starts an autocomplete query, which continues until all providers are
69 // done or the query is Stop()ed. It is safe to Start() a new query without 58 // done or the query is Stop()ed. It is safe to Start() a new query without
70 // Stop()ing the previous one. 59 // Stop()ing the previous one.
71 // 60 //
72 // See AutocompleteInput::desired_tld() for meaning of |desired_tld|. 61 // See AutocompleteInput::desired_tld() for meaning of |desired_tld|.
73 // 62 //
74 // |prevent_inline_autocomplete| is true if the generated result set should 63 // |prevent_inline_autocomplete| is true if the generated result set should
75 // not require inline autocomplete for the default match. This is difficult 64 // not require inline autocomplete for the default match. This is difficult
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 110
122 // Asks the relevant provider to delete |match|, and ensures observers are 111 // Asks the relevant provider to delete |match|, and ensures observers are
123 // notified of resulting changes immediately. This should only be called when 112 // notified of resulting changes immediately. This should only be called when
124 // no query is running. 113 // no query is running.
125 void DeleteMatch(const AutocompleteMatch& match); 114 void DeleteMatch(const AutocompleteMatch& match);
126 115
127 // Removes any entries that were copied from the last result. This is used by 116 // Removes any entries that were copied from the last result. This is used by
128 // the popup to ensure it's not showing an out-of-date query. 117 // the popup to ensure it's not showing an out-of-date query.
129 void ExpireCopiedEntries(); 118 void ExpireCopiedEntries();
130 119
131 #ifdef UNIT_TEST
132 void set_search_provider(SearchProvider* provider) {
133 search_provider_ = provider;
134 }
135 void set_keyword_provider(KeywordProvider* provider) {
136 keyword_provider_ = provider;
137 }
138 #endif
139 SearchProvider* search_provider() const { return search_provider_; } 120 SearchProvider* search_provider() const { return search_provider_; }
140 KeywordProvider* keyword_provider() const { return keyword_provider_; } 121 KeywordProvider* keyword_provider() const { return keyword_provider_; }
141 122
142 const AutocompleteInput& input() const { return input_; } 123 const AutocompleteInput& input() const { return input_; }
143 const AutocompleteResult& result() const { return result_; } 124 const AutocompleteResult& result() const { return result_; }
144 bool done() const { return done_; } 125 bool done() const { return done_; }
145 const ACProviders* providers() const { return &providers_; } 126 const ACProviders* providers() const { return &providers_; }
146 127
147 // AutocompleteProviderListener: 128 // AutocompleteProviderListener:
148 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE; 129 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE;
149 130
150 // Called when an omnibox event log entry is generated. 131 // Called when an omnibox event log entry is generated.
151 // Populates provider_info with diagnostic information about the status 132 // Populates provider_info with diagnostic information about the status
152 // of various providers. In turn, calls 133 // of various providers. In turn, calls
153 // AutocompleteProvider::AddProviderInfo() so each provider can add 134 // AutocompleteProvider::AddProviderInfo() so each provider can add
154 // provider-specific information, information we want to log for a particular 135 // provider-specific information, information we want to log for a particular
155 // provider but not others. 136 // provider but not others.
156 void AddProvidersInfo(ProvidersInfo* provider_info) const; 137 void AddProvidersInfo(ProvidersInfo* provider_info) const;
157 138
158 private: 139 private:
159 friend class AutocompleteProviderTest; 140 friend class AutocompleteProviderTest;
160 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, 141 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest,
161 RedundantKeywordsIgnoredInResult); 142 RedundantKeywordsIgnoredInResult);
162 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, UpdateAssistedQueryStats); 143 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, UpdateAssistedQueryStats);
163 144
145 friend class SearchProviderTest;
146 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, UpdateKeywordDescriptions);
147
164 // Updates |result_| to reflect the current provider state. Resets timers and 148 // Updates |result_| to reflect the current provider state. Resets timers and
165 // fires notifications as necessary. |is_synchronous_pass| is true only when 149 // fires notifications as necessary. |is_synchronous_pass| is true only when
166 // Start() is calling this to get the synchronous result. 150 // Start() is calling this to get the synchronous result.
167 void UpdateResult(bool is_synchronous_pass); 151 void UpdateResult(bool is_synchronous_pass);
168 152
169 // Updates |result| to populate each match's |associated_keyword| if that 153 // Updates |result| to populate each match's |associated_keyword| if that
170 // match can show a keyword hint. |result| should be sorted by 154 // match can show a keyword hint. |result| should be sorted by
171 // relevance before this is called. 155 // relevance before this is called.
172 void UpdateAssociatedKeywords(AutocompleteResult* result); 156 void UpdateAssociatedKeywords(AutocompleteResult* result);
173 157
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 204
221 // Has StartZeroSuggest() been called but not Start()? 205 // Has StartZeroSuggest() been called but not Start()?
222 bool in_zero_suggest_; 206 bool in_zero_suggest_;
223 207
224 Profile* profile_; 208 Profile* profile_;
225 209
226 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); 210 DISALLOW_COPY_AND_ASSIGN(AutocompleteController);
227 }; 211 };
228 212
229 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 213 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_classifier.cc ('k') | chrome/browser/autocomplete/autocomplete_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698