summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-22 00:15:17 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-22 00:15:17 +0000
commitc37e3b6de9ccfd2bc4c5f2852ae2e4b5ec9b985d (patch)
treee5df41c5242a176e955db360d5de40225fded383 /chrome/browser/views/tabs
parent7e3544bd5859cad57261bc4827686f266a8d3961 (diff)
downloadchromium_src-c37e3b6de9ccfd2bc4c5f2852ae2e4b5ec9b985d.zip
chromium_src-c37e3b6de9ccfd2bc4c5f2852ae2e4b5ec9b985d.tar.gz
chromium_src-c37e3b6de9ccfd2bc4c5f2852ae2e4b5ec9b985d.tar.bz2
Adds support for phantom tabs. A pinned tab becomes a phantom tab when
it is closed, and effectively unloads the renderer and replaces it with a new TabContents that loads when selected. A phantom tab is currently rendered without a border. Phantom tabs do not prevent a window from closing. Long term only pinned app tabs will have the ability to be made phantom, but this allows us to test the feature until app support is all wired in. BUG=32845 TEST=none yet Review URL: http://codereview.chromium.org/553008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc2
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc11
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h3
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc11
-rw-r--r--chrome/browser/views/tabs/tab_strip.h3
6 files changed, 25 insertions, 9 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index f7f81b8..e354e56 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -959,7 +959,7 @@ void DraggedTabController::Detach() {
}
// If we've removed the last Tab from the TabStrip, hide the frame now.
- if (attached_model->empty())
+ if (!attached_model->HasNonPhantomTabs())
HideFrame();
// Set up the photo booth to start capturing the contents of the dragged
@@ -1343,7 +1343,7 @@ void DraggedTabController::HideFrame() {
void DraggedTabController::CleanUpHiddenFrame() {
// If the model we started dragging from is now empty, we must ask the
// delegate to close the frame.
- if (source_tabstrip_->model()->empty())
+ if (!source_tabstrip_->model()->HasNonPhantomTabs())
source_tabstrip_->model()->delegate()->CloseFrameAfterDragSession();
}
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index d3a9263..5cd7531 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -42,7 +42,7 @@ DraggedTabView::DraggedTabView(TabContents* datasource,
tab_width_(0) {
set_parent_owned(false);
- renderer_->UpdateData(datasource, false);
+ renderer_->UpdateData(datasource, false, false);
#if defined(OS_WIN)
container_.reset(new views::WidgetWin);
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 60d24c9..34bee57 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -258,6 +258,7 @@ TabRenderer::TabRenderer()
data_.blocked = false;
data_.pinned = false;
data_.animating_pinned_change = false;
+ data_.phantom = false;
// Add the Close Button.
close_button_ = new TabCloseButton(this);
@@ -293,13 +294,16 @@ ThemeProvider* TabRenderer::GetThemeProvider() {
return NULL;
}
-void TabRenderer::UpdateData(TabContents* contents, bool loading_only) {
+void TabRenderer::UpdateData(TabContents* contents,
+ bool phantom,
+ bool loading_only) {
DCHECK(contents);
- if (!loading_only) {
+ if (data_.phantom != phantom || !loading_only) {
data_.title = contents->GetTitle();
data_.off_the_record = contents->profile()->IsOffTheRecord();
data_.crashed = contents->is_crashed();
data_.favicon = contents->GetFavIcon();
+ data_.phantom = phantom;
}
// TODO(glen): Temporary hax.
@@ -457,7 +461,8 @@ void TabRenderer::Paint(gfx::Canvas* canvas) {
show_close_button != showing_close_button_)
Layout();
- PaintTabBackground(canvas);
+ if (!data_.phantom)
+ PaintTabBackground(canvas);
SkColor title_color = GetThemeProvider()->
GetColor(IsSelected() ?
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index 4cecfbe..c08dd8a 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -45,7 +45,7 @@ class TabRenderer : public views::View,
// TabContents.
//
// See TabStripModel::TabChangedAt documentation for what loading_only means.
- void UpdateData(TabContents* contents, bool loading_only);
+ void UpdateData(TabContents* contents, bool phantom, bool loading_only);
// Sets the pinned state of the tab.
void SetBlocked(bool blocked);
@@ -207,6 +207,7 @@ class TabRenderer : public views::View,
bool pinned;
bool blocked;
bool animating_pinned_change;
+ bool phantom;
};
TabData data_;
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 27bbb68..e051f7d 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -1111,7 +1111,7 @@ void TabStrip::TabInsertedAt(TabContents* contents,
if (!contains_tab) {
TabData d = { tab, gfx::Rect() };
tab_data_.insert(tab_data_.begin() + index, d);
- tab->UpdateData(contents, false);
+ tab->UpdateData(contents, model_->IsPhantomTab(index), false);
}
tab->set_pinned(model_->IsTabPinned(index));
tab->SetBlocked(model_->IsTabBlocked(index));
@@ -1186,10 +1186,17 @@ void TabStrip::TabChangedAt(TabContents* contents, int index,
// We'll receive another notification of the change asynchronously.
return;
}
- tab->UpdateData(contents, change_type == LOADING_ONLY);
+ tab->UpdateData(contents, model_->IsPhantomTab(index),
+ change_type == LOADING_ONLY);
tab->UpdateFromModel();
}
+void TabStrip::TabReplacedAt(TabContents* old_contents,
+ TabContents* new_contents,
+ int index) {
+ TabChangedAt(new_contents, index, ALL);
+}
+
void TabStrip::TabPinnedStateChanged(TabContents* contents, int index) {
GetTabAt(index)->set_pinned(model_->IsTabPinned(index));
StartPinnedTabAnimation(index);
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 27f6a97..309a9f3 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -139,6 +139,9 @@ class TabStrip : public views::View,
bool pinned_state_changed);
virtual void TabChangedAt(TabContents* contents, int index,
TabChangeType change_type);
+ virtual void TabReplacedAt(TabContents* old_contents,
+ TabContents* new_contents,
+ int index);
virtual void TabPinnedStateChanged(TabContents* contents, int index);
virtual void TabBlockedStateChanged(TabContents* contents, int index);