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

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: more indentation changes 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"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "chrome/browser/autocomplete/autocomplete_input.h" 13 #include "chrome/browser/autocomplete/autocomplete_input.h"
14 #include "chrome/browser/autocomplete/autocomplete_provider.h" 14 #include "chrome/browser/autocomplete/autocomplete_provider.h"
15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
16 #include "chrome/browser/autocomplete/autocomplete_result.h" 16 #include "chrome/browser/autocomplete/autocomplete_result.h"
17 #include "chrome/browser/autocomplete/keyword_provider.h"
18 #include "chrome/browser/autocomplete/search_provider.h"
17 19
18 class AutocompleteControllerDelegate; 20 class AutocompleteControllerDelegate;
19 class KeywordProvider;
20 class Profile; 21 class Profile;
21 class SearchProvider;
22 class ZeroSuggestProvider; 22 class ZeroSuggestProvider;
23 23
24 // The AutocompleteController is the center of the autocomplete system. A 24 // The AutocompleteController is the center of the autocomplete system. A
25 // class creates an instance of the controller, which in turn creates a set of 25 // class creates an instance of the controller, which in turn creates a set of
26 // AutocompleteProviders to serve it. The owning class can ask the controller 26 // AutocompleteProviders to serve it. The owning class can ask the controller
27 // to Start() a query; the controller in turn passes this call down to the 27 // to Start() a query; the controller in turn passes this call down to the
28 // providers, each of which keeps track of its own matches and whether it has 28 // providers, each of which keeps track of its own matches and whether it has
29 // finished processing the query. When a provider gets more matches or finishes 29 // finished processing the query. When a provider gets more matches or finishes
30 // processing, it notifies the controller, which merges the combined matches 30 // processing, it notifies the controller, which merges the combined matches
31 // together and makes the result available to interested observers. 31 // together and makes the result available to interested observers.
(...skipping 11 matching lines...) Expand all
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 // Normally, you will call the first constructor. Unit tests can use the
50 // second to set the providers to some known testing providers. The default 50 // second to set the providers to some known testing providers. The default
51 // providers will be overridden and the controller will take ownership of the 51 // providers will be overridden and the controller will take ownership of the
52 // providers, Release()ing them on destruction. 52 // providers, Release()ing them on destruction.
53 //
54 // |provider_types| is a bitmap containing AutocompleteProvider::Type values
55 // that will (potentially, depending on platform, flags, etc.) be
56 // instantiated.
53 AutocompleteController(Profile* profile, 57 AutocompleteController(Profile* profile,
54 AutocompleteControllerDelegate* delegate); 58 AutocompleteControllerDelegate* delegate,
59 int provider_types);
55 #ifdef UNIT_TEST 60 #ifdef UNIT_TEST
61 // Inlined since UNIT_TEST may or may not have been defined when compiling the
62 // .cc file.
Peter Kasting 2012/09/11 00:05:39 Nit: Comment not really necessary
Daniel Erat 2012/09/11 00:42:19 Done.
56 AutocompleteController(const ACProviders& providers, Profile* profile) 63 AutocompleteController(const ACProviders& providers, Profile* profile)
Peter Kasting 2012/09/11 00:05:39 So what things are left using this? Can we TODO t
Daniel Erat 2012/09/11 00:42:19 chrome/browser/autocomplete/autocomplete_provider_
57 : delegate_(NULL), 64 : delegate_(NULL),
58 providers_(providers), 65 providers_(providers),
59 keyword_provider_(NULL), 66 keyword_provider_(NULL),
60 search_provider_(NULL), 67 search_provider_(NULL),
68 zero_suggest_provider_(NULL),
61 done_(true), 69 done_(true),
62 in_start_(false), 70 in_start_(false),
71 in_zero_suggest_(false),
63 profile_(profile) { 72 profile_(profile) {
73 for (ACProviders::iterator it = providers_.begin();
74 it != providers_.end(); ++it) {
75 if ((*it)->type() == AutocompleteProvider::TYPE_SEARCH)
76 search_provider_ = static_cast<SearchProvider*>(*it);
77 else if ((*it)->type() == AutocompleteProvider::TYPE_KEYWORD)
78 keyword_provider_ = static_cast<KeywordProvider*>(*it);
79 }
64 } 80 }
65 #endif 81 #endif
66 ~AutocompleteController(); 82 ~AutocompleteController();
67 83
68 // Starts an autocomplete query, which continues until all providers are 84 // 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 85 // done or the query is Stop()ed. It is safe to Start() a new query without
70 // Stop()ing the previous one. 86 // Stop()ing the previous one.
71 // 87 //
72 // See AutocompleteInput::desired_tld() for meaning of |desired_tld|. 88 // See AutocompleteInput::desired_tld() for meaning of |desired_tld|.
73 // 89 //
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 137
122 // Asks the relevant provider to delete |match|, and ensures observers are 138 // Asks the relevant provider to delete |match|, and ensures observers are
123 // notified of resulting changes immediately. This should only be called when 139 // notified of resulting changes immediately. This should only be called when
124 // no query is running. 140 // no query is running.
125 void DeleteMatch(const AutocompleteMatch& match); 141 void DeleteMatch(const AutocompleteMatch& match);
126 142
127 // Removes any entries that were copied from the last result. This is used by 143 // 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. 144 // the popup to ensure it's not showing an out-of-date query.
129 void ExpireCopiedEntries(); 145 void ExpireCopiedEntries();
130 146
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_; } 147 SearchProvider* search_provider() const { return search_provider_; }
140 KeywordProvider* keyword_provider() const { return keyword_provider_; } 148 KeywordProvider* keyword_provider() const { return keyword_provider_; }
141 149
142 const AutocompleteInput& input() const { return input_; } 150 const AutocompleteInput& input() const { return input_; }
143 const AutocompleteResult& result() const { return result_; } 151 const AutocompleteResult& result() const { return result_; }
144 bool done() const { return done_; } 152 bool done() const { return done_; }
145 const ACProviders* providers() const { return &providers_; } 153 const ACProviders* providers() const { return &providers_; }
146 154
147 // AutocompleteProviderListener: 155 // AutocompleteProviderListener:
148 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE; 156 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 228
221 // Has StartZeroSuggest() been called but not Start()? 229 // Has StartZeroSuggest() been called but not Start()?
222 bool in_zero_suggest_; 230 bool in_zero_suggest_;
223 231
224 Profile* profile_; 232 Profile* profile_;
225 233
226 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); 234 DISALLOW_COPY_AND_ASSIGN(AutocompleteController);
227 }; 235 };
228 236
229 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 237 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698