diff options
author | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 20:15:07 +0000 |
---|---|---|
committer | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 20:15:07 +0000 |
commit | 8ebde6bb112957ea0ff13b9b2297967bacf0acb3 (patch) | |
tree | b972b0cbb478b4b842612552ed9de20527f4d7d7 | |
parent | 543e04930a52a85f683aca29417c832934036867 (diff) | |
download | chromium_src-8ebde6bb112957ea0ff13b9b2297967bacf0acb3.zip chromium_src-8ebde6bb112957ea0ff13b9b2297967bacf0acb3.tar.gz chromium_src-8ebde6bb112957ea0ff13b9b2297967bacf0acb3.tar.bz2 |
Revert r24920 due to compile failures.
TBR=pkasting
Review URL: http://codereview.chromium.org/181023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24927 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_model.cc | 49 |
2 files changed, 29 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 74d3d7d..1b1cc7f 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -6,7 +6,6 @@ #include "base/basictypes.h" #include "base/string_util.h" -#include "base/time.h" // TEMPORARY #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/keyword_provider.h" @@ -54,9 +53,6 @@ AutocompleteEditModel::AutocompleteEditModel( // we'll set this before each call to the controller. paste_and_go_controller = new AutocompleteController(NULL); } - - temporary_timer_.Start(base::TimeDelta::FromMilliseconds(10), this, - &AutocompleteEditModel::TemporaryTimerFired); } AutocompleteEditModel::~AutocompleteEditModel() { @@ -388,7 +384,7 @@ void AutocompleteEditModel::OnUpOrDownKeyPressed(int count) { // NOTE: This purposefully don't trigger any code that resets paste_state_. if (!popup_->IsOpen()) { - if (!query_in_progress()) { + if (popup_->autocomplete_controller()->done()) { // The popup is neither open nor working on a query already. So, start an // autocomplete query for the current text. This also sets // user_input_in_progress_ to true, which we want: if the user has started @@ -555,7 +551,7 @@ GURL AutocompleteEditModel::GetURLForCurrentText( PageTransition::Type* transition, bool* is_history_what_you_typed_match, GURL* alternate_nav_url) { - return (popup_->IsOpen() || query_in_progress()) ? + return (popup_->IsOpen() || !popup_->autocomplete_controller()->done()) ? popup_->URLsForCurrentSelection(transition, is_history_what_you_typed_match, alternate_nav_url) : diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc index 0e75699..d3a6fe6 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_model.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc @@ -150,7 +150,6 @@ GURL AutocompletePopupModel::URLsForCurrentSelection( PageTransition::Type* transition, bool* is_history_what_you_typed_match, GURL* alternate_nav_url) const { - CHECK(IsOpen()); const AutocompleteResult* result; AutocompleteResult::const_iterator match; if (!controller_->done()) { @@ -171,9 +170,8 @@ GURL AutocompletePopupModel::URLsForCurrentSelection( // controller_->latest_result() here too, since the controller keeps that // up-to-date. However we generally try to avoid referring to that. result = &controller_->result(); - // If there are no results, the popup should be closed (so we should have - // failed the CHECK above), and URLsForDefaultMatch() should have been - // called instead. + // If there are no results, the popup is closed, so URLsForDefaultMatch() + // should have been called instead. CHECK(!result->empty()); CHECK(selected_line_ < result->size()); match = result->begin() + selected_line_; @@ -195,32 +193,28 @@ GURL AutocompletePopupModel::URLsForDefaultMatch( GURL* alternate_nav_url) { // We had better not already be doing anything, or this call will blow it // away. - CHECK(!IsOpen()); - CHECK(controller_->done()); + DCHECK(!IsOpen()); + DCHECK(controller_->done()); // Run the new query and get only the synchronously available matches. inside_synchronous_query_ = true; // Tell Observe() not to notify the edit or // update our appearance. controller_->Start(text, desired_tld, true, false, true); inside_synchronous_query_ = false; - CHECK(controller_->done()); - + DCHECK(controller_->done()); const AutocompleteResult& result = controller_->result(); - GURL destination_url; - if (!result.empty()) { - // Get the URLs for the default match. - const AutocompleteResult::const_iterator match = result.default_match(); - if (transition) - *transition = match->transition; - if (is_history_what_you_typed_match) - *is_history_what_you_typed_match = match->is_history_what_you_typed_match; - if (alternate_nav_url) - *alternate_nav_url = result.alternate_nav_url(); - destination_url = match->destination_url; - } + if (result.empty()) + return GURL(); - controller_->Stop(true); // Keeps our state consistent. - return destination_url; + // Get the URLs for the default match. + const AutocompleteResult::const_iterator match = result.default_match(); + if (transition) + *transition = match->transition; + if (is_history_what_you_typed_match) + *is_history_what_you_typed_match = match->is_history_what_you_typed_match; + if (alternate_nav_url) + *alternate_nav_url = result.alternate_nav_url(); + return match->destination_url; } bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, @@ -259,6 +253,17 @@ AutocompleteLog* AutocompletePopupModel::GetAutocompleteLog() { } void AutocompletePopupModel::Move(int count) { + // TODO(pkasting): Temporary hack. If the query is running while the popup is + // open, we might be showing the results of the previous query still. Force + // the popup to display the latest results so the popup and the controller + // aren't out of sync. The better fix here is to roll the controller back to + // be in sync with what the popup is showing. + if (IsOpen() && !controller_->done()) { + Observe(NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED, + Source<AutocompleteController>(controller_.get()), + Details<const AutocompleteResult>(&controller_->result())); + } + const AutocompleteResult& result = controller_->result(); if (result.empty()) return; |