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 627b1a79f20d05b18523680173d39911f770a20d..b6e0b55a6575020c169ff48929d413e27b53533b 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_controller.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_controller.cc |
| @@ -183,6 +183,7 @@ AutocompleteController::AutocompleteController( |
| zero_suggest_provider_(NULL), |
| stop_timer_duration_(OmniboxFieldTrial::StopTimerFieldTrialDuration()), |
| done_(true), |
| + has_providers_for_omnibox_focus_(false), |
| in_start_(false), |
| template_url_service_(template_url_service) { |
| provider_types &= ~OmniboxFieldTrial::GetDisabledProviderTypes(); |
| @@ -222,6 +223,12 @@ AutocompleteController::AutocompleteController( |
| if (zero_suggest_provider_) |
| providers_.push_back(zero_suggest_provider_); |
| } |
| + for (auto& provider : providers_) { |
|
Peter Kasting
2014/12/30 21:18:23
Just eliminate this loop and the variable it sets
jif
2014/12/31 19:02:26
Done.
|
| + if (provider.ActivatedOnOmniboxFocus()) { |
| + has_providers_for_omnibox_focus_ = true; |
| + break; |
| + } |
| + } |
| } |
| AutocompleteController::~AutocompleteController() { |
| @@ -327,8 +334,9 @@ void AutocompleteController::Stop(bool clear_result) { |
| } |
| } |
| -void AutocompleteController::StartZeroSuggest(const AutocompleteInput& input) { |
| - if (zero_suggest_provider_ == NULL) |
| +void AutocompleteController::StartOnOmniboxFocus( |
| + const AutocompleteInput& input) { |
| + if (!has_providers_for_omnibox_focus_) |
| return; |
| DCHECK(!in_start_); // We should not be already running a query. |
| @@ -336,14 +344,18 @@ void AutocompleteController::StartZeroSuggest(const AutocompleteInput& input) { |
| // Call Start() on all prefix-based providers with an INVALID |
| // AutocompleteInput to clear out cached |matches_|, which ensures that |
| // they aren't used with zero suggest. |
| + bool non_empty_matches = false; |
| for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { |
| - if (i->get() == zero_suggest_provider_) |
| + if (i->get().ActivatedOnOmniboxFocus()) { |
| (*i)->Start(input, false); |
| - else |
| + if (!(*i)_->matches().empty()) |
| + non_empty_matches = true; |
| + } else { |
| (*i)->Start(AutocompleteInput(), false); |
| + } |
| } |
| - if (!zero_suggest_provider_->matches().empty()) |
| + if (non_empty_matches) |
|
Peter Kasting
2014/12/30 21:18:23
I think you can eliminate this conditional and jus
jif
2014/12/31 19:02:26
Done.
Looks good.
|
| UpdateResult(false, false); |
| } |