diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 20:20:09 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 20:20:09 +0000 |
commit | 5c0e648d6f4ea988be36e74cae045ba5f041e5cb (patch) | |
tree | f0fb62cf06be0ef7afa2b74babb0fe0ee7c1bc02 /chrome/browser/browser.cc | |
parent | 2e7054c0c76fe1c9a12de5925b7ad1a7aff94e45 (diff) | |
download | chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.zip chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.tar.gz chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.tar.bz2 |
Wires up restoring pinned tabs for session and tab restore
services. And turns on pinned tabs by default on linux.
BUG=16634
TEST=Currently this linux only. Try tab pinning and make sure it works.
Review URL: http://codereview.chromium.org/149621
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r-- | chrome/browser/browser.cc | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index cbda922..252ed9f 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -609,18 +609,23 @@ TabContents* Browser::AddRestoredTab( const std::vector<TabNavigation>& navigations, int tab_index, int selected_navigation, - bool select) { + bool select, + bool pin) { TabContents* new_tab = new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL); new_tab->controller().RestoreFromState(navigations, selected_navigation); + bool really_pin = + (pin && tab_index == tabstrip_model()->IndexOfFirstNonPinnedTab()); tabstrip_model_.InsertTabContentsAt(tab_index, new_tab, select, false); + if (really_pin) + tabstrip_model_.SetTabPinned(tab_index, true); if (select) window_->Activate(); if (profile_->HasSessionService()) { SessionService* session_service = profile_->GetSessionService(); if (session_service) - session_service->TabRestored(&new_tab->controller()); + session_service->TabRestored(&new_tab->controller(), really_pin); } return new_tab; } @@ -1474,19 +1479,20 @@ void Browser::DuplicateContentsAt(int index) { TabContents* contents = GetTabContentsAt(index); TabContents* new_contents = NULL; DCHECK(contents); + bool pinned = false; if (type_ == TYPE_NORMAL) { // If this is a tabbed browser, just create a duplicate tab inside the same // window next to the tab being duplicated. new_contents = contents->Clone(); - // If you duplicate a tab that is not selected, we need to make sure to - // select the tab being duplicated so that DetermineInsertionIndex returns - // the right index (if tab 5 is selected and we right-click tab 1 we want - // the new tab to appear in index position 2, not 6). - if (tabstrip_model_.selected_index() != index) - tabstrip_model_.SelectTabContentsAt(index, true); - tabstrip_model_.AddTabContents(new_contents, index + 1, false, + // Make sure we force the index, otherwise the duplicate tab may appear at + // the wrong location. + tabstrip_model_.AddTabContents(new_contents, index + 1, true, PageTransition::LINK, true); + if (tabstrip_model_.IsTabPinned(index)) { + pinned = true; + tabstrip_model_.SetTabPinned(index + 1, true); + } } else { Browser* browser = NULL; if (type_ & TYPE_APP) { @@ -1514,7 +1520,7 @@ void Browser::DuplicateContentsAt(int index) { if (profile_->HasSessionService()) { SessionService* session_service = profile_->GetSessionService(); if (session_service) - session_service->TabRestored(&new_contents->controller()); + session_service->TabRestored(&new_contents->controller(), pinned); } } @@ -1678,6 +1684,18 @@ void Browser::TabMoved(TabContents* contents, SyncHistoryWithTabs(std::min(from_index, to_index)); } +void Browser::TabPinnedStateChanged(TabContents* contents, int index) { + if (!profile()->HasSessionService()) + return; + SessionService* session_service = profile()->GetSessionService(); + if (session_service) { + session_service->SetPinnedState( + session_id(), + GetTabContentsAt(index)->controller().session_id(), + tabstrip_model_.IsTabPinned(index)); + } +} + void Browser::TabStripEmpty() { // Close the frame after we return to the message loop (not immediately, // otherwise it will destroy this object before the stack has a chance to @@ -2399,6 +2417,9 @@ void Browser::SyncHistoryWithTabs(int index) { if (contents) { session_service->SetTabIndexInWindow( session_id(), contents->controller().session_id(), i); + session_service->SetPinnedState(session_id(), + contents->controller().session_id(), + tabstrip_model_.IsTabPinned(i)); } } } |