summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 21:22:03 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 21:22:03 +0000
commit85ff2c48df0789ae2476cd85738e07cecae9b3e3 (patch)
treed5a15f916376146d8626b92d97556c80627c9d0c /chrome/browser/autocomplete/autocomplete_edit.cc
parente2eb43115440dc442b92c5842274290caedb146f (diff)
downloadchromium_src-85ff2c48df0789ae2476cd85738e07cecae9b3e3.zip
chromium_src-85ff2c48df0789ae2476cd85738e07cecae9b3e3.tar.gz
chromium_src-85ff2c48df0789ae2476cd85738e07cecae9b3e3.tar.bz2
Revert the Omnibox when changing tabs while its contents have been deleted.
To do this, I needed to add a new TabStripModelObserver call that fired before the tab had been changed, since when the Omnibox asks for the current permanent_text_ it gets it from the selected tab's navigation controller. BUG=6850 Review URL: http://codereview.chromium.org/113983 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index 2ab706b3..70622d3 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -71,8 +71,18 @@ const AutocompleteEditModel::State
// Like typing, switching tabs "accepts" the temporary text as the user
// text, because it makes little sense to have temporary text when the
// popup is closed.
- if (user_input_in_progress_)
- InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
+ if (user_input_in_progress_) {
+ // Weird edge case to match other browsers: if the edit is empty, revert to
+ // the permanent text (so the user can get it back easily) but select it (so
+ // on switching back, typing will "just work").
+ const std::wstring user_text(UserTextFromDisplayText(view_->GetText()));
+ if (user_text.empty()) {
+ view_->RevertAll();
+ view_->SelectAll(true);
+ } else {
+ InternalSetUserText(user_text);
+ }
+ }
return State(user_input_in_progress_, user_text_, keyword_, is_keyword_hint_,
keyword_ui_state_, show_search_hint_);