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

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

Issue 2179063003: Switching out of keyword mode shouldn't count as a minimal change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // result changes here, because the notification observer is in the midst of 230 // result changes here, because the notification observer is in the midst of
231 // shutdown too, so we don't ask Stop() to clear |result_| (and notify). 231 // shutdown too, so we don't ask Stop() to clear |result_| (and notify).
232 result_.Reset(); // Not really necessary. 232 result_.Reset(); // Not really necessary.
233 Stop(false); 233 Stop(false);
234 } 234 }
235 235
236 void AutocompleteController::Start(const AutocompleteInput& input) { 236 void AutocompleteController::Start(const AutocompleteInput& input) {
237 TRACE_EVENT1("omnibox", "AutocompleteController::Start", 237 TRACE_EVENT1("omnibox", "AutocompleteController::Start",
238 "text", base::UTF16ToUTF8(input.text())); 238 "text", base::UTF16ToUTF8(input.text()));
239 const base::string16 old_input_text(input_.text()); 239 const base::string16 old_input_text(input_.text());
240 const bool old_allow_exact_keyword_match = input_.allow_exact_keyword_match();
240 const bool old_want_asynchronous_matches = input_.want_asynchronous_matches(); 241 const bool old_want_asynchronous_matches = input_.want_asynchronous_matches();
241 const bool old_from_omnibox_focus = input_.from_omnibox_focus(); 242 const bool old_from_omnibox_focus = input_.from_omnibox_focus();
242 input_ = input; 243 input_ = input;
243 244
244 // See if we can avoid rerunning autocomplete when the query hasn't changed 245 // See if we can avoid rerunning autocomplete when the query hasn't changed
245 // much. When the user presses or releases the ctrl key, the desired_tld 246 // much. When the user presses or releases the ctrl key, the desired_tld
246 // changes, and when the user finishes an IME composition, inline autocomplete 247 // changes, and when the user finishes an IME composition, inline autocomplete
247 // may no longer be prevented. In both these cases the text itself hasn't 248 // may no longer be prevented. In both these cases the text itself hasn't
248 // changed since the last query, and some providers can do much less work (and 249 // changed since the last query, and some providers can do much less work (and
249 // get matches back more quickly). Taking advantage of this reduces flicker. 250 // get matches back more quickly). Taking advantage of this reduces flicker.
250 // 251 //
251 // NOTE: This comes after constructing |input_| above since that construction 252 // NOTE: This comes after constructing |input_| above since that construction
252 // can change the text string (e.g. by stripping off a leading '?'). 253 // can change the text string (e.g. by stripping off a leading '?').
253 const bool minimal_changes = 254 const bool minimal_changes =
254 (input_.text() == old_input_text) && 255 (input_.text() == old_input_text) &&
256 (input_.allow_exact_keyword_match() == old_allow_exact_keyword_match) &&
255 (input_.want_asynchronous_matches() == old_want_asynchronous_matches) && 257 (input_.want_asynchronous_matches() == old_want_asynchronous_matches) &&
256 (input.from_omnibox_focus() == old_from_omnibox_focus); 258 (input.from_omnibox_focus() == old_from_omnibox_focus);
257 259
258 expire_timer_.Stop(); 260 expire_timer_.Stop();
259 stop_timer_.Stop(); 261 stop_timer_.Stop();
260 262
261 // Start the new query. 263 // Start the new query.
262 in_start_ = true; 264 in_start_ = true;
263 base::TimeTicks start_time = base::TimeTicks::Now(); 265 base::TimeTicks start_time = base::TimeTicks::Now();
264 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { 266 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 476
475 NotifyChanged(force_notify_default_match_changed || notify_default_match); 477 NotifyChanged(force_notify_default_match_changed || notify_default_match);
476 } 478 }
477 479
478 void AutocompleteController::UpdateAssociatedKeywords( 480 void AutocompleteController::UpdateAssociatedKeywords(
479 AutocompleteResult* result) { 481 AutocompleteResult* result) {
480 if (!keyword_provider_) 482 if (!keyword_provider_)
481 return; 483 return;
482 484
483 // Determine if the user's input is an exact keyword match. 485 // Determine if the user's input is an exact keyword match.
484 base::string16 exact_keyword = keyword_provider_->GetKeywordForText( 486 base::string16 exact_keyword =
485 TemplateURLService::CleanUserInputKeyword(input_.text())); 487 keyword_provider_->GetKeywordForText(input_.text());
486 488
487 std::set<base::string16> keywords; 489 std::set<base::string16> keywords;
488 for (ACMatches::iterator match(result->begin()); match != result->end(); 490 for (ACMatches::iterator match(result->begin()); match != result->end();
489 ++match) { 491 ++match) {
490 base::string16 keyword( 492 base::string16 keyword(
491 match->GetSubstitutingExplicitlyInvokedKeyword(template_url_service_)); 493 match->GetSubstitutingExplicitlyInvokedKeyword(template_url_service_));
492 if (!keyword.empty()) { 494 if (!keyword.empty()) {
493 keywords.insert(keyword); 495 keywords.insert(keyword);
494 continue; 496 continue;
495 } 497 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 expire_timer_.Stop(); 659 expire_timer_.Stop();
658 stop_timer_.Stop(); 660 stop_timer_.Stop();
659 done_ = true; 661 done_ = true;
660 if (clear_result && !result_.empty()) { 662 if (clear_result && !result_.empty()) {
661 result_.Reset(); 663 result_.Reset();
662 // NOTE: We pass in false since we're trying to only clear the popup, not 664 // NOTE: We pass in false since we're trying to only clear the popup, not
663 // touch the edit... this is all a mess and should be cleaned up :( 665 // touch the edit... this is all a mess and should be cleaned up :(
664 NotifyChanged(false); 666 NotifyChanged(false);
665 } 667 }
666 } 668 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698