diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 16:59:11 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 16:59:11 +0000 |
commit | df772cbfe7a1b17dd7bb179c1e25780201d0b0ce (patch) | |
tree | bb2c277deb1b3ef07d04b5908e362c0ef7556478 /chrome/browser/autocomplete/autocomplete.cc | |
parent | 8e0dca871966c15a08c23bfd890aad73ee3b8aa5 (diff) | |
download | chromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.zip chromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.tar.gz chromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.tar.bz2 |
More work fixing miscellaneous issues in the autocomplete code, probably none of which will help my crasher :(
* Force the query to stop if the user deletes a match. This makes more sense from a UI perspective and allows some code to be simpler.
* Prevent us from potentially doing a "minimal changes" match in a different profile (hard to trigger, likely no practical effects)
* Remove unneeded Reset() call on a repeating timer (which will auto-reset itself)
* Rename one of the notifications and move its listener to the edit, since that's who really cares about it anyway.
* Make the controller's Stop(true) notify the popup via the normal observer pipeline rather than coding something special into the popup's StopAutocomplete().
* Rename |paste_and_go_controller| |synchronous_controller| and use it instead of using the main popup controller to do the synchronous query when calling URLsForDefaultMatch(). This makes things both simpler and safer.
BUG=none
TEST=Using the omnibox still works fine
Review URL: http://codereview.chromium.org/178049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 6c18880..6a2989e 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -646,6 +646,8 @@ AutocompleteController::~AutocompleteController() { void AutocompleteController::SetProfile(Profile* profile) { for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) (*i)->SetProfile(profile); + input_.Clear(); // Ensure we don't try to do a "minimal_changes" query on a + // different profile. } void AutocompleteController::Start(const std::wstring& text, @@ -710,19 +712,26 @@ void AutocompleteController::Stop(bool clear_result) { updated_latest_result_ = false; delay_interval_has_passed_ = false; done_ = true; - if (clear_result) + if (clear_result) { result_.Reset(); + NotificationService::current()->Notify( + NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED, + Source<AutocompleteController>(this), + Details<const AutocompleteResult>(&result_)); + // NOTE: We don't notify AUTOCOMPLETE_CONTROLLER_DEFAULT_MATCH_UPDATED since + // we're trying to only clear the popup, not touch the edit... this is all + // a mess and should be cleaned up :( + } latest_result_.CopyFrom(result_); } void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { DCHECK(match.deletable); - match.provider->DeleteMatch(match); // This will synchronously call back to + match.provider->DeleteMatch(match); // This may synchronously call back to // OnProviderUpdate(). - - // Notify observers of this change immediately, so the UI feels responsive to - // the user's action. - CommitResult(); + CommitResult(); // Ensure any new result gets committed immediately. If it + // was committed already or hasn't been modified, this is + // harmless. } void AutocompleteController::OnProviderUpdate(bool updated_matches) { @@ -759,7 +768,7 @@ void AutocompleteController::UpdateLatestResult(bool is_synchronous_pass) { } NotificationService::current()->Notify( - NotificationType::AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE, + NotificationType::AUTOCOMPLETE_CONTROLLER_DEFAULT_MATCH_UPDATED, Source<AutocompleteController>(this), Details<const AutocompleteResult>(&latest_result_)); } @@ -776,7 +785,6 @@ void AutocompleteController::UpdateLatestResult(bool is_synchronous_pass) { void AutocompleteController::DelayTimerFired() { delay_interval_has_passed_ = true; - update_delay_timer_.Reset(); CommitResult(); } @@ -798,6 +806,13 @@ void AutocompleteController::CommitResult() { NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED, Source<AutocompleteController>(this), Details<const AutocompleteResult>(&result_)); + // This notification must be sent after the other so the popup has time to + // update its state before the edit calls into it. + // TODO(pkasting): Eliminate this ordering requirement. + NotificationService::current()->Notify( + NotificationType::AUTOCOMPLETE_CONTROLLER_DEFAULT_MATCH_UPDATED, + Source<AutocompleteController>(this), + Details<const AutocompleteResult>(&result_)); if (!done_) update_delay_timer_.Reset(); } |