summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 17:46:37 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 17:46:37 +0000
commitb13dee3299a400d604038b6a49a161a1048a2373 (patch)
treebdc5b2f562f5fa716161fb3e308cd07cbd40f374 /chrome/browser
parent74392c5335d534902360f9817382dfd73302af7f (diff)
downloadchromium_src-b13dee3299a400d604038b6a49a161a1048a2373.zip
chromium_src-b13dee3299a400d604038b6a49a161a1048a2373.tar.gz
chromium_src-b13dee3299a400d604038b6a49a161a1048a2373.tar.bz2
Makes aero peek and instant work well together. Aero peek needed to
override TabReplacedAt to correctly update internal state. I also removed the implementation of TabClosingAt as TabDetachedAt covers it. BUG=74370 TEST=see bug Review URL: http://codereview.chromium.org/6602105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/aeropeek_manager.cc81
-rw-r--r--chrome/browser/aeropeek_manager.h16
2 files changed, 55 insertions, 42 deletions
diff --git a/chrome/browser/aeropeek_manager.cc b/chrome/browser/aeropeek_manager.cc
index 4d1159d..fd5312a 100644
--- a/chrome/browser/aeropeek_manager.cc
+++ b/chrome/browser/aeropeek_manager.cc
@@ -1034,6 +1034,19 @@ void AeroPeekManager::DeleteAeroPeekWindow(int tab_id) {
}
}
}
+
+void AeroPeekManager::DeleteAeroPeekWindowForTab(TabContentsWrapper* tab) {
+ // Delete the AeroPeekWindow object associated with this tab and all its
+ // resources. (AeroPeekWindow::Destory() also removes this tab from the tab
+ // list of Windows.)
+ AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(tab->tab_contents()));
+ if (!window)
+ return;
+
+ window->Destroy();
+ DeleteAeroPeekWindow(GetTabID(tab->tab_contents()));
+}
+
AeroPeekWindow* AeroPeekManager::GetAeroPeekWindow(int tab_id) const {
size_t size = tab_list_.size();
for (std::list<AeroPeekWindow*>::const_iterator i = tab_list_.begin();
@@ -1045,6 +1058,21 @@ AeroPeekWindow* AeroPeekManager::GetAeroPeekWindow(int tab_id) const {
return NULL;
}
+void AeroPeekManager::CreateAeroPeekWindowIfNecessary(TabContentsWrapper* tab,
+ bool foreground) {
+ if (GetAeroPeekWindow(GetTabID(tab->tab_contents())))
+ return;
+
+ AeroPeekWindow* window =
+ new AeroPeekWindow(application_window_,
+ this,
+ GetTabID(tab->tab_contents()),
+ foreground,
+ tab->tab_contents()->GetTitle(),
+ tab->tab_contents()->GetFavIcon());
+ tab_list_.push_back(window);
+}
+
TabContents* AeroPeekManager::GetTabContents(int tab_id) const {
for (TabContentsIterator iterator; !iterator.done(); ++iterator) {
TabContents* target_contents = *iterator;
@@ -1069,54 +1097,17 @@ void AeroPeekManager::TabInsertedAt(TabContentsWrapper* contents,
if (!contents)
return;
- // If there are not any AeroPeekWindow objects associated with the given
- // tab, Create a new AeroPeekWindow object and add it to the list.
- if (GetAeroPeekWindow(GetTabID(contents->tab_contents())))
- return;
-
- AeroPeekWindow* window =
- new AeroPeekWindow(application_window_,
- this,
- GetTabID(contents->tab_contents()),
- foreground,
- contents->tab_contents()->GetTitle(),
- contents->tab_contents()->GetFavIcon());
- if (!window)
- return;
-
- tab_list_.push_back(window);
-}
-
-void AeroPeekManager::TabClosingAt(TabStripModel* tab_strip_model,
- TabContentsWrapper* contents,
- int index) {
- if (!contents)
- return;
-
- // |tab_strip_model| is NULL when this is being called from TabDetachedAt
- // below.
- // Delete the AeroPeekWindow object associated with this tab and all its
- // resources. (AeroPeekWindow::Destory() also removes this tab from the tab
- // list of Windows.)
- AeroPeekWindow* window =
- GetAeroPeekWindow(GetTabID(contents->tab_contents()));
- if (!window)
- return;
-
- window->Destroy();
- DeleteAeroPeekWindow(GetTabID(contents->tab_contents()));
+ CreateAeroPeekWindowIfNecessary(contents, foreground);
}
void AeroPeekManager::TabDetachedAt(TabContentsWrapper* contents, int index) {
if (!contents)
return;
- // Same as TabClosingAt(), we remove this tab from the tab list and delete
- // its AeroPeekWindow.
// Chrome will call TabInsertedAt() when this tab is inserted to another
// TabStrip. We will re-create an AeroPeekWindow object for this tab and
// re-add it to the tab list there.
- TabClosingAt(NULL, contents, index);
+ DeleteAeroPeekWindowForTab(contents);
}
void AeroPeekManager::TabSelectedAt(TabContentsWrapper* old_contents,
@@ -1143,6 +1134,18 @@ void AeroPeekManager::TabSelectedAt(TabContentsWrapper* old_contents,
}
}
+void AeroPeekManager::TabReplacedAt(TabStripModel* tab_strip_model,
+ TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index) {
+ DeleteAeroPeekWindowForTab(old_contents);
+
+ CreateAeroPeekWindowIfNecessary(new_contents,
+ (index == tab_strip_model->selected_index()));
+ // We don't need to update the selection as if |new_contents| is selected the
+ // TabStripModel will send TabSelectedAt.
+}
+
void AeroPeekManager::TabMoved(TabContentsWrapper* contents,
int from_index,
int to_index,
diff --git a/chrome/browser/aeropeek_manager.h b/chrome/browser/aeropeek_manager.h
index 58eaf07..e29ff4c 100644
--- a/chrome/browser/aeropeek_manager.h
+++ b/chrome/browser/aeropeek_manager.h
@@ -110,9 +110,6 @@ class AeroPeekManager : public TabStripModelObserver,
virtual void TabInsertedAt(TabContentsWrapper* contents,
int index,
bool foreground);
- virtual void TabClosingAt(TabStripModel* tab_strip_model,
- TabContentsWrapper* contents,
- int index);
virtual void TabDetachedAt(TabContentsWrapper* contents, int index);
virtual void TabSelectedAt(TabContentsWrapper* old_contents,
TabContentsWrapper* new_contents,
@@ -125,6 +122,10 @@ class AeroPeekManager : public TabStripModelObserver,
virtual void TabChangedAt(TabContentsWrapper* contents,
int index,
TabChangeType change_type);
+ virtual void TabReplacedAt(TabStripModel* tab_strip_model,
+ TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index);
// Overriden from TabThumbnailWindowDelegate:
virtual void CloseTab(int tab_id);
@@ -138,10 +139,19 @@ class AeroPeekManager : public TabStripModelObserver,
// Tab ID.
void DeleteAeroPeekWindow(int tab_id);
+ // If there is an AeroPeekWindow associated with |tab| it is removed and
+ // deleted.
+ void DeleteAeroPeekWindowForTab(TabContentsWrapper* tab);
+
// Retrieves the AeroPeekWindow object associated with the specified
// Tab ID.
AeroPeekWindow* GetAeroPeekWindow(int tab_id) const;
+ // If an AeroPeekWindow hasn't been created for |tab| yet, one is created.
+ // |foreground| is true if the tab is selected.
+ void CreateAeroPeekWindowIfNecessary(TabContentsWrapper* tab,
+ bool foreground);
+
// Returns a rectangle that fits into the destination rectangle and keeps
// the pixel-aspect ratio of the source one.
// (This function currently uses the longer-fit algorithm as IE8 does.)