diff options
author | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 23:28:38 +0000 |
---|---|---|
committer | suzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 23:28:38 +0000 |
commit | 27c9c76cf55f6628259620d09d3bca2b86012011 (patch) | |
tree | 8fea605a3f496b02cbed5dd79bc0c35cbc926eed | |
parent | 15972e045c30234976dc838aa430ff9514e70109 (diff) | |
download | chromium_src-27c9c76cf55f6628259620d09d3bca2b86012011.zip chromium_src-27c9c76cf55f6628259620d09d3bca2b86012011.tar.gz chromium_src-27c9c76cf55f6628259620d09d3bca2b86012011.tar.bz2 |
Fix a CHECK failure in AutocompletePopupModel::InfoForCurrentSelection().
BUG=70344
TEST=See bug report.
Review URL: http://codereview.chromium.org/6380012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72417 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 14 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.h | 3 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_model.cc | 6 |
3 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 1ad993e..ff2d5d3 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -479,12 +479,6 @@ void AutocompleteEditModel::OnKillFocus() { has_focus_ = false; control_key_state_ = UP; paste_state_ = NONE; - - // Like typing, killing focus "accepts" the temporary text as the user - // text, because it makes little sense to have temporary text when the - // popup is closed. - InternalSetUserText(UserTextFromDisplayText(view_->GetText())); - has_temporary_text_ = false; } bool AutocompleteEditModel::OnEscapeKeyPressed() { @@ -680,6 +674,14 @@ void AutocompleteEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { controller_->OnPopupBoundsChanged(bounds); } +void AutocompleteEditModel::OnPopupClosed() { + // Accepts the temporary text as the user text, because it makes little + // sense to have temporary text when the popup is closed. + InternalSetUserText(UserTextFromDisplayText(view_->GetText())); + has_temporary_text_ = false; + PopupBoundsChangedTo(gfx::Rect()); +} + // Return true if the suggestion type warrants a TCP/IP preconnection. // i.e., it is now highly likely that the user will select the related domain. static bool IsPreconnectable(AutocompleteMatch::Type type) { diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h index 6cefc0b..6458f6c 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.h +++ b/chrome/browser/autocomplete/autocomplete_edit.h @@ -319,6 +319,9 @@ class AutocompleteEditModel : public NotificationObserver { // Invoked when the popup is going to change its bounds to |bounds|. void PopupBoundsChangedTo(const gfx::Rect& bounds); + // Called when the popup is closed. + void OnPopupClosed(); + private: enum PasteState { NONE, // Most recent edit was not a paste. diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc index 588683d..089f603 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_model.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc @@ -317,8 +317,12 @@ void AutocompletePopupModel::Observe(NotificationType type, if ((hovered_line_ != kNoMatch) && (result->size() <= hovered_line_)) SetHoveredLine(kNoMatch); + const bool was_open = view_->IsOpen(); view_->UpdatePopupAppearance(); - edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds()); + if (view_->IsOpen()) + edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds()); + else if (was_open) + edit_model_->OnPopupClosed(); } const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( |