summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
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/browser.cc
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/browser.cc')
-rw-r--r--chrome/browser/browser.cc56
1 files changed, 39 insertions, 17 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 92bf8eb..3259fd6 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -178,8 +178,8 @@ Browser::Browser(Type type, Profile* profile)
}
Browser::~Browser() {
- // The tab strip should be empty at this point.
- DCHECK(tabstrip_model_.empty());
+ // The tab strip should not have any significant tabs at this point.
+ DCHECK(!tabstrip_model_.HasNonPhantomTabs());
tabstrip_model_.RemoveObserver(this);
BrowserList::RemoveBrowser(this);
@@ -1854,7 +1854,7 @@ void Browser::TabInsertedAt(TabContents* contents,
contents->set_delegate(this);
contents->controller().SetWindowID(session_id());
- SyncHistoryWithTabs(tabstrip_model_.GetIndexOfTabContents(contents));
+ SyncHistoryWithTabs(index);
// Make sure the loading state is updated correctly, otherwise the throbber
// won't start if the page is loading.
@@ -1877,20 +1877,7 @@ void Browser::TabClosingAt(TabContents* contents, int index) {
}
void Browser::TabDetachedAt(TabContents* contents, int index) {
- // Save what the user's currently typing.
- window_->GetLocationBar()->SaveStateToContents(contents);
-
- contents->set_delegate(NULL);
- if (!tabstrip_model_.closing_all())
- SyncHistoryWithTabs(0);
-
- RemoveScheduledUpdatesFor(contents);
-
- if (find_bar_controller_.get() && index == tabstrip_model_.selected_index())
- find_bar_controller_->ChangeTabContents(NULL);
-
- registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
- Source<TabContents>(contents));
+ TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
}
void Browser::TabDeselectedAt(TabContents* contents, int index) {
@@ -1952,6 +1939,21 @@ void Browser::TabMoved(TabContents* contents,
SyncHistoryWithTabs(std::min(from_index, to_index));
}
+void Browser::TabReplacedAt(TabContents* old_contents,
+ TabContents* new_contents, int index) {
+ TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE);
+ TabInsertedAt(new_contents, index,
+ (index == tabstrip_model_.selected_index()));
+
+ int entry_count = new_contents->controller().entry_count();
+ if (entry_count > 0) {
+ // Send out notification so that observers are updated appropriately.
+ new_contents->controller().NotifyEntryChanged(
+ new_contents->controller().GetEntryAtIndex(entry_count - 1),
+ entry_count - 1);
+ }
+}
+
void Browser::TabPinnedStateChanged(TabContents* contents, int index) {
if (!profile()->HasSessionService())
return;
@@ -3178,6 +3180,26 @@ void Browser::CloseFrame() {
window_->Close();
}
+void Browser::TabDetachedAtImpl(TabContents* contents, int index,
+ DetachType type) {
+ if (type == DETACH_TYPE_DETACH) {
+ // Save what the user's currently typed.
+ window_->GetLocationBar()->SaveStateToContents(contents);
+
+ if (!tabstrip_model_.closing_all())
+ SyncHistoryWithTabs(0);
+ }
+
+ contents->set_delegate(NULL);
+ RemoveScheduledUpdatesFor(contents);
+
+ if (find_bar_controller_.get() && index == tabstrip_model_.selected_index())
+ find_bar_controller_->ChangeTabContents(NULL);
+
+ registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
+ Source<TabContents>(contents));
+}
+
// static
void Browser::RegisterAppPrefs(const std::wstring& app_name) {
// A set of apps that we've already started.