Chromium Code Reviews| 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..8312d1ba7566b0aa5fe29ecf298fc7fcd3cdcd18 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_controller.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_controller.cc |
| @@ -76,7 +76,8 @@ const int AutocompleteController::kNoItemSelected = -1; |
| AutocompleteController::AutocompleteController( |
| Profile* profile, |
| - AutocompleteControllerDelegate* delegate) |
| + AutocompleteControllerDelegate* delegate, |
| + int provider_types) |
| : delegate_(delegate), |
| keyword_provider_(NULL), |
| zero_suggest_provider_(NULL), |
| @@ -84,35 +85,53 @@ AutocompleteController::AutocompleteController( |
| 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) { |
| + 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. |
| - CommandLine* cl = CommandLine::ForCurrentProcess(); |
| - if (cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) { |
| - zero_suggest_provider_ = new ZeroSuggestProvider(this, profile, |
| - cl->GetSwitchValueASCII(switches::kExperimentalZeroSuggestURLPrefix)); |
| - providers_.push_back(zero_suggest_provider_); |
| +#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) |
|
Peter Kasting
2012/09/07 23:23:02
Nit: {}
Daniel Erat
2012/09/08 16:37:36
Done.
|
| + 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)); |
| + |
| + if (provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) { |
| + // Create ZeroSuggest if its switch is present. |
| + CommandLine* cl = CommandLine::ForCurrentProcess(); |
|
Peter Kasting
2012/09/07 23:23:02
Nit: If you inline this into the conditional, you
Daniel Erat
2012/09/08 16:37:36
Done (combining the conditionals; kept the |cl| va
|
| + if (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(); |
| } |