summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs
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/tabs
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/tabs')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc7
-rw-r--r--chrome/browser/tabs/tab_strip_model.h5
2 files changed, 11 insertions, 1 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index e1a93f3..e5a509f 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -561,9 +561,14 @@ void TabStripModel::ChangeSelectedContentsFrom(
TabContents* new_contents = GetContentsAt(to_index);
if (old_contents == new_contents)
return;
+
TabContents* last_selected_contents = old_contents;
- selected_index_ = to_index;
+ if (last_selected_contents) {
+ FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
+ TabDeselectedAt(last_selected_contents, selected_index_));
+ }
+ selected_index_ = to_index;
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabSelectedAt(last_selected_contents, new_contents, selected_index_,
user_gesture));
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 7f496c8..2431883 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -58,6 +58,11 @@ class TabStripModelObserver {
// action is necessary to deal with the TabContents no longer being present.
virtual void TabDetachedAt(TabContents* contents, int index) { }
+ // The selected TabContents is about to change from |old_contents| at |index|.
+ // This gives observers a chance to prepare for an impending switch before it
+ // happens.
+ virtual void TabDeselectedAt(TabContents* contents, int index) { }
+
// The selected TabContents changed from |old_contents| to |new_contents| at
// |index|. |user_gesture| specifies whether or not this was done by a user
// input event (e.g. clicking on a tab, keystroke) or as a side-effect of