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

Side by Side Diff: components/omnibox/browser/autocomplete_controller.cc

Issue 2048693003: Misc. omnibox cleanup: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 4 years, 6 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
« no previous file with comments | « no previous file | components/omnibox/browser/history_url_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/omnibox/browser/autocomplete_controller.h" 5 #include "components/omnibox/browser/autocomplete_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 } // namespace 170 } // namespace
171 171
172 AutocompleteController::AutocompleteController( 172 AutocompleteController::AutocompleteController(
173 std::unique_ptr<AutocompleteProviderClient> provider_client, 173 std::unique_ptr<AutocompleteProviderClient> provider_client,
174 AutocompleteControllerDelegate* delegate, 174 AutocompleteControllerDelegate* delegate,
175 int provider_types) 175 int provider_types)
176 : delegate_(delegate), 176 : delegate_(delegate),
177 provider_client_(std::move(provider_client)), 177 provider_client_(std::move(provider_client)),
178 history_url_provider_(NULL), 178 history_url_provider_(nullptr),
179 keyword_provider_(NULL), 179 keyword_provider_(nullptr),
180 search_provider_(NULL), 180 search_provider_(nullptr),
181 zero_suggest_provider_(NULL), 181 zero_suggest_provider_(nullptr),
182 stop_timer_duration_(OmniboxFieldTrial::StopTimerFieldTrialDuration()), 182 stop_timer_duration_(OmniboxFieldTrial::StopTimerFieldTrialDuration()),
183 done_(true), 183 done_(true),
184 in_start_(false), 184 in_start_(false),
185 template_url_service_(provider_client_->GetTemplateURLService()) { 185 template_url_service_(provider_client_->GetTemplateURLService()) {
186 provider_types &= ~OmniboxFieldTrial::GetDisabledProviderTypes(); 186 provider_types &= ~OmniboxFieldTrial::GetDisabledProviderTypes();
187 if (provider_types & AutocompleteProvider::TYPE_BOOKMARK) 187 if (provider_types & AutocompleteProvider::TYPE_BOOKMARK)
188 providers_.push_back(new BookmarkProvider(provider_client_.get())); 188 providers_.push_back(new BookmarkProvider(provider_client_.get()));
189 if (provider_types & AutocompleteProvider::TYPE_BUILTIN) 189 if (provider_types & AutocompleteProvider::TYPE_BUILTIN)
190 providers_.push_back(new BuiltinProvider(provider_client_.get())); 190 providers_.push_back(new BuiltinProvider(provider_client_.get()));
191 if (provider_types & AutocompleteProvider::TYPE_HISTORY_QUICK) 191 if (provider_types & AutocompleteProvider::TYPE_HISTORY_QUICK)
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 bool force_notify_default_match_changed) { 401 bool force_notify_default_match_changed) {
402 TRACE_EVENT0("omnibox", "AutocompleteController::UpdateResult"); 402 TRACE_EVENT0("omnibox", "AutocompleteController::UpdateResult");
403 const bool last_default_was_valid = result_.default_match() != result_.end(); 403 const bool last_default_was_valid = result_.default_match() != result_.end();
404 // The following three variables are only set and used if 404 // The following three variables are only set and used if
405 // |last_default_was_valid|. 405 // |last_default_was_valid|.
406 base::string16 last_default_fill_into_edit, last_default_keyword, 406 base::string16 last_default_fill_into_edit, last_default_keyword,
407 last_default_associated_keyword; 407 last_default_associated_keyword;
408 if (last_default_was_valid) { 408 if (last_default_was_valid) {
409 last_default_fill_into_edit = result_.default_match()->fill_into_edit; 409 last_default_fill_into_edit = result_.default_match()->fill_into_edit;
410 last_default_keyword = result_.default_match()->keyword; 410 last_default_keyword = result_.default_match()->keyword;
411 if (result_.default_match()->associated_keyword != NULL) 411 if (result_.default_match()->associated_keyword) {
412 last_default_associated_keyword = 412 last_default_associated_keyword =
413 result_.default_match()->associated_keyword->keyword; 413 result_.default_match()->associated_keyword->keyword;
414 }
414 } 415 }
415 416
416 if (regenerate_result) 417 if (regenerate_result)
417 result_.Reset(); 418 result_.Reset();
418 419
419 AutocompleteResult last_result; 420 AutocompleteResult last_result;
420 last_result.Swap(&result_); 421 last_result.Swap(&result_);
421 422
422 for (Providers::const_iterator i(providers_.begin()); 423 for (Providers::const_iterator i(providers_.begin());
423 i != providers_.end(); ++i) 424 i != providers_.end(); ++i)
(...skipping 16 matching lines...) Expand all
440 441
441 UpdateKeywordDescriptions(&result_); 442 UpdateKeywordDescriptions(&result_);
442 UpdateAssociatedKeywords(&result_); 443 UpdateAssociatedKeywords(&result_);
443 UpdateAssistedQueryStats(&result_); 444 UpdateAssistedQueryStats(&result_);
444 if (search_provider_) 445 if (search_provider_)
445 search_provider_->RegisterDisplayedAnswers(result_); 446 search_provider_->RegisterDisplayedAnswers(result_);
446 447
447 const bool default_is_valid = result_.default_match() != result_.end(); 448 const bool default_is_valid = result_.default_match() != result_.end();
448 base::string16 default_associated_keyword; 449 base::string16 default_associated_keyword;
449 if (default_is_valid && 450 if (default_is_valid &&
450 (result_.default_match()->associated_keyword != NULL)) { 451 result_.default_match()->associated_keyword) {
451 default_associated_keyword = 452 default_associated_keyword =
452 result_.default_match()->associated_keyword->keyword; 453 result_.default_match()->associated_keyword->keyword;
453 } 454 }
454 // We've gotten async results. Send notification that the default match 455 // We've gotten async results. Send notification that the default match
455 // updated if fill_into_edit, associated_keyword, or keyword differ. (The 456 // updated if fill_into_edit, associated_keyword, or keyword differ. (The
456 // second can change if we've just started Chrome and the keyword database 457 // second can change if we've just started Chrome and the keyword database
457 // finishes loading while processing this request. The third can change 458 // finishes loading while processing this request. The third can change
458 // if we swapped from interpreting the input as a search--which gets 459 // if we swapped from interpreting the input as a search--which gets
459 // labeled with the default search provider's keyword--to a URL.) 460 // labeled with the default search provider's keyword--to a URL.)
460 // We don't check the URL as that may change for the default match 461 // We don't check the URL as that may change for the default match
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 expire_timer_.Stop(); 656 expire_timer_.Stop();
656 stop_timer_.Stop(); 657 stop_timer_.Stop();
657 done_ = true; 658 done_ = true;
658 if (clear_result && !result_.empty()) { 659 if (clear_result && !result_.empty()) {
659 result_.Reset(); 660 result_.Reset();
660 // NOTE: We pass in false since we're trying to only clear the popup, not 661 // NOTE: We pass in false since we're trying to only clear the popup, not
661 // touch the edit... this is all a mess and should be cleaned up :( 662 // touch the edit... this is all a mess and should be cleaned up :(
662 NotifyChanged(false); 663 NotifyChanged(false);
663 } 664 }
664 } 665 }
OLDNEW
« no previous file with comments | « no previous file | components/omnibox/browser/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698