OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 AutocompleteProvider::AutocompleteProvider(ACProviderListener* listener, | 497 AutocompleteProvider::AutocompleteProvider(ACProviderListener* listener, |
498 Profile* profile, | 498 Profile* profile, |
499 const char* name) | 499 const char* name) |
500 : profile_(profile), | 500 : profile_(profile), |
501 listener_(listener), | 501 listener_(listener), |
502 done_(true), | 502 done_(true), |
503 name_(name) { | 503 name_(name) { |
504 } | 504 } |
505 | 505 |
506 void AutocompleteProvider::SetProfile(Profile* profile) { | |
507 DCHECK(profile); | |
508 DCHECK(done_); // The controller should have already stopped us. | |
509 profile_ = profile; | |
510 } | |
511 | |
512 void AutocompleteProvider::Stop() { | 506 void AutocompleteProvider::Stop() { |
513 done_ = true; | 507 done_ = true; |
514 } | 508 } |
515 | 509 |
516 void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { | 510 void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { |
517 } | 511 } |
518 | 512 |
519 AutocompleteProvider::~AutocompleteProvider() { | 513 AutocompleteProvider::~AutocompleteProvider() { |
520 Stop(); | 514 Stop(); |
521 } | 515 } |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 // shutdown too, so we don't ask Stop() to clear |result_| (and notify). | 822 // shutdown too, so we don't ask Stop() to clear |result_| (and notify). |
829 result_.Reset(); // Not really necessary. | 823 result_.Reset(); // Not really necessary. |
830 Stop(false); | 824 Stop(false); |
831 | 825 |
832 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) | 826 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) |
833 (*i)->Release(); | 827 (*i)->Release(); |
834 | 828 |
835 providers_.clear(); // Not really necessary. | 829 providers_.clear(); // Not really necessary. |
836 } | 830 } |
837 | 831 |
838 void AutocompleteController::SetProfile(Profile* profile) { | |
839 Stop(true); | |
840 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) | |
841 (*i)->SetProfile(profile); | |
842 input_.Clear(); // Ensure we don't try to do a "minimal_changes" query on a | |
843 // different profile. | |
844 profile_ = profile; | |
845 } | |
846 | |
847 void AutocompleteController::Start( | 832 void AutocompleteController::Start( |
848 const string16& text, | 833 const string16& text, |
849 const string16& desired_tld, | 834 const string16& desired_tld, |
850 bool prevent_inline_autocomplete, | 835 bool prevent_inline_autocomplete, |
851 bool prefer_keyword, | 836 bool prefer_keyword, |
852 bool allow_exact_keyword_match, | 837 bool allow_exact_keyword_match, |
853 AutocompleteInput::MatchesRequested matches_requested) { | 838 AutocompleteInput::MatchesRequested matches_requested) { |
854 const string16 old_input_text(input_.text()); | 839 const string16 old_input_text(input_.text()); |
855 const AutocompleteInput::MatchesRequested old_matches_requested = | 840 const AutocompleteInput::MatchesRequested old_matches_requested = |
856 input_.matches_requested(); | 841 input_.matches_requested(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1018 } |
1034 } | 1019 } |
1035 done_ = true; | 1020 done_ = true; |
1036 } | 1021 } |
1037 | 1022 |
1038 void AutocompleteController::StartExpireTimer() { | 1023 void AutocompleteController::StartExpireTimer() { |
1039 if (result_.HasCopiedMatches()) | 1024 if (result_.HasCopiedMatches()) |
1040 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 1025 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
1041 this, &AutocompleteController::ExpireCopiedEntries); | 1026 this, &AutocompleteController::ExpireCopiedEntries); |
1042 } | 1027 } |
OLD | NEW |