Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/autocomplete/autocomplete_controller.h" | 5 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 // need the edit model to update the display. | 293 // need the edit model to update the display. |
| 294 UpdateResult(false, true); | 294 UpdateResult(false, true); |
| 295 | 295 |
| 296 if (!done_) { | 296 if (!done_) { |
| 297 StartExpireTimer(); | 297 StartExpireTimer(); |
| 298 StartStopTimer(); | 298 StartStopTimer(); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 void AutocompleteController::Stop(bool clear_result) { | 302 void AutocompleteController::Stop(bool clear_result) { |
| 303 for (Providers::const_iterator i(providers_.begin()); i != providers_.end(); | 303 StopHelper(clear_result, false); |
|
Mark P
2015/03/05 20:43:18
This is a direct move below except for revising th
| |
| 304 ++i) { | |
| 305 (*i)->Stop(clear_result); | |
| 306 } | |
| 307 | |
| 308 expire_timer_.Stop(); | |
| 309 stop_timer_.Stop(); | |
| 310 done_ = true; | |
| 311 if (clear_result && !result_.empty()) { | |
| 312 result_.Reset(); | |
| 313 // NOTE: We pass in false since we're trying to only clear the popup, not | |
| 314 // touch the edit... this is all a mess and should be cleaned up :( | |
| 315 NotifyChanged(false); | |
| 316 } | |
| 317 } | 304 } |
| 318 | 305 |
| 319 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput& input) { | 306 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput& input) { |
| 320 DCHECK(!in_start_); // We should not be already running a query. | 307 DCHECK(!in_start_); // We should not be already running a query. |
| 321 | 308 |
| 322 // Call Start() on all prefix-based providers with an INVALID | 309 // Call Start() on all prefix-based providers with an INVALID |
| 323 // AutocompleteInput to clear out cached |matches_|, which ensures that | 310 // AutocompleteInput to clear out cached |matches_|, which ensures that |
| 324 // they aren't used with zero suggest. | 311 // they aren't used with zero suggest. |
| 325 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) | 312 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) |
| 326 (*i)->Start(input, false, true); | 313 (*i)->Start(input, false, true); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 | 643 |
| 657 if (result_.HasCopiedMatches()) | 644 if (result_.HasCopiedMatches()) |
| 658 expire_timer_.Start(FROM_HERE, | 645 expire_timer_.Start(FROM_HERE, |
| 659 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 646 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 660 this, &AutocompleteController::ExpireCopiedEntries); | 647 this, &AutocompleteController::ExpireCopiedEntries); |
| 661 } | 648 } |
| 662 | 649 |
| 663 void AutocompleteController::StartStopTimer() { | 650 void AutocompleteController::StartStopTimer() { |
| 664 stop_timer_.Start(FROM_HERE, | 651 stop_timer_.Start(FROM_HERE, |
| 665 stop_timer_duration_, | 652 stop_timer_duration_, |
| 666 base::Bind(&AutocompleteController::Stop, | 653 base::Bind(&AutocompleteController::StopHelper, |
| 667 base::Unretained(this), | 654 base::Unretained(this), |
| 668 false)); | 655 false, true)); |
| 669 } | 656 } |
| 657 | |
| 658 void AutocompleteController::StopHelper(bool clear_result, | |
| 659 bool user_inactivity_timer) { | |
| 660 for (Providers::const_iterator i(providers_.begin()); i != providers_.end(); | |
| 661 ++i) { | |
| 662 (*i)->Stop(clear_result, user_inactivity_timer); | |
| 663 } | |
| 664 | |
| 665 expire_timer_.Stop(); | |
| 666 stop_timer_.Stop(); | |
| 667 done_ = true; | |
| 668 if (clear_result && !result_.empty()) { | |
| 669 result_.Reset(); | |
| 670 // NOTE: We pass in false since we're trying to only clear the popup, not | |
| 671 // touch the edit... this is all a mess and should be cleaned up :( | |
| 672 NotifyChanged(false); | |
| 673 } | |
| 674 } | |
| OLD | NEW |