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

Unified Diff: chrome/browser/autocomplete/autocomplete_controller.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_controller.cc
diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc
index 5c8d7720f41461dc2b406da4d9ddaec52302ece1..f120a66655ba2d0724d1b734d5a3c68de14d8420 100644
--- a/chrome/browser/autocomplete/autocomplete_controller.cc
+++ b/chrome/browser/autocomplete/autocomplete_controller.cc
@@ -76,43 +76,62 @@ const int AutocompleteController::kNoItemSelected = -1;
AutocompleteController::AutocompleteController(
Profile* profile,
- AutocompleteControllerDelegate* delegate)
+ AutocompleteControllerDelegate* delegate,
+ int provider_types)
: delegate_(delegate),
keyword_provider_(NULL),
+ search_provider_(NULL),
zero_suggest_provider_(NULL),
done_(true),
in_start_(false),
in_zero_suggest_(false),
profile_(profile) {
- search_provider_ = new SearchProvider(this, profile);
- providers_.push_back(search_provider_);
-#if !defined(OS_ANDROID)
- // History quick provider is enabled on all platforms other than Android.
- bool hqp_enabled = true;
- providers_.push_back(new HistoryQuickProvider(this, profile));
- // Search provider/"tab to search" is enabled on all platforms other than
- // Android.
- keyword_provider_ = new KeywordProvider(this, profile);
- providers_.push_back(keyword_provider_);
-#else
- // TODO(mrossetti): Remove the following and permanently modify the
- // HistoryURLProvider to not search titles once HQP is turned on permanently.
+ if (provider_types & AutocompleteProvider::TYPE_SEARCH) {
Peter Kasting 2012/09/11 00:05:39 Nit: I'd put all these in the same order as the en
Daniel Erat 2012/09/11 00:42:19 Done (had to do a bit of shuffling around since Hi
+ search_provider_ = new SearchProvider(this, profile);
+ providers_.push_back(search_provider_);
+ }
+
+ bool hqp_enabled = false;
+ // TODO(mrossetti): Permanently modify the HistoryURLProvider to not search
+ // titles once HQP is turned on permanently.
// TODO(jcivelli): Enable the History Quick Provider and figure out why it
// reports the wrong results for some pages.
- bool hqp_enabled = false;
-#endif // !OS_ANDROID
- providers_.push_back(new HistoryURLProvider(this, profile));
- providers_.push_back(new ShortcutsProvider(this, profile));
- providers_.push_back(new HistoryContentsProvider(this, profile, hqp_enabled));
- providers_.push_back(new BuiltinProvider(this, profile));
- providers_.push_back(new ExtensionAppProvider(this, profile));
- // Create ZeroSuggest if its switch is present.
+#if !defined(OS_ANDROID)
+ // History quick provider can be used on all platforms other than Android.
+ if (provider_types & AutocompleteProvider::TYPE_HISTORY_QUICK) {
+ hqp_enabled = true;
+ providers_.push_back(new HistoryQuickProvider(this, profile));
+ }
+
+ if (provider_types & AutocompleteProvider::TYPE_KEYWORD) {
+ // Search provider/"tab to search" can be used on all platforms other than
+ // Android.
+ keyword_provider_ = new KeywordProvider(this, profile);
+ providers_.push_back(keyword_provider_);
+ }
+#endif
+
+ if (provider_types & AutocompleteProvider::TYPE_HISTORY_URL)
+ providers_.push_back(new HistoryURLProvider(this, profile));
+ if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS)
+ providers_.push_back(new ShortcutsProvider(this, profile));
+ if (provider_types & AutocompleteProvider::TYPE_HISTORY_CONTENTS) {
+ providers_.push_back(
+ new HistoryContentsProvider(this, profile, hqp_enabled));
+ }
+ if (provider_types & AutocompleteProvider::TYPE_BUILTIN)
+ providers_.push_back(new BuiltinProvider(this, profile));
+ if (provider_types & AutocompleteProvider::TYPE_EXTENSION_APP)
+ providers_.push_back(new ExtensionAppProvider(this, profile));
+
CommandLine* cl = CommandLine::ForCurrentProcess();
- if (cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) {
+ if ((provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) &&
+ cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) {
zero_suggest_provider_ = new ZeroSuggestProvider(this, profile,
cl->GetSwitchValueASCII(switches::kExperimentalZeroSuggestURLPrefix));
providers_.push_back(zero_suggest_provider_);
}
+
for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)
(*i)->AddRef();
}

Powered by Google App Engine
This is Rietveld 408576698