diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-05 23:33:15 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-05 23:33:15 +0000 |
commit | ae1c2f0e3acf8d7cda922a36894c1fa55e55fa02 (patch) | |
tree | 78778a2495d1260370e3281506c6c058cd2ce031 /chrome/browser/sessions/tab_restore_service.cc | |
parent | 75c3e3ab998af77062e4a2cf67b2a437ca2cedbd (diff) | |
download | chromium_src-ae1c2f0e3acf8d7cda922a36894c1fa55e55fa02.zip chromium_src-ae1c2f0e3acf8d7cda922a36894c1fa55e55fa02.tar.gz chromium_src-ae1c2f0e3acf8d7cda922a36894c1fa55e55fa02.tar.bz2 |
retry r112077 - recently closed menu: respect middle click
(and other disposition modifiers)
BUG=7678
TEST=trybots
Review URL: http://codereview.chromium.org/8662051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions/tab_restore_service.cc')
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.cc | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index c0ee440..3fb872a 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -302,12 +302,12 @@ void TabRestoreService::RestoreMostRecentEntry( if (entries_.empty()) return; - RestoreEntryById(delegate, entries_.front()->id, false); + RestoreEntryById(delegate, entries_.front()->id, UNKNOWN); } void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, SessionID::id_type id, - bool replace_existing_tab) { + WindowOpenDisposition disposition) { Entries::iterator i = GetEntryIteratorById(id); if (i == entries_.end()) { // Don't hoark here, we allow an invalid id. @@ -339,7 +339,7 @@ void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, // new browser into which we restore the tabs. if (entry->type == TAB) { Tab* tab = static_cast<Tab*>(entry); - delegate = RestoreTab(*tab, delegate, replace_existing_tab); + delegate = RestoreTab(*tab, delegate, disposition); delegate->ShowBrowserWindow(); } else if (entry->type == WINDOW) { TabRestoreServiceDelegate* current_delegate = delegate; @@ -356,8 +356,8 @@ void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, delegate->AddRestoredTab(tab.navigations, delegate->GetTabCount(), tab.current_navigation_index, tab.extension_app_id, - (static_cast<int>(tab_i) == - window->selected_tab_index), + static_cast<int>(tab_i) == + window->selected_tab_index, tab.pinned, tab.from_last_session, tab.session_storage_namespace); if (restored_tab) { @@ -377,7 +377,7 @@ void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, tab_i != window->tabs.end(); ++tab_i) { const Tab& tab = *tab_i; if (tab.id == id) { - delegate = RestoreTab(tab, delegate, replace_existing_tab); + delegate = RestoreTab(tab, delegate, disposition); window->tabs.erase(tab_i); // If restoring the tab leaves the window with nothing else, delete it // as well. @@ -401,7 +401,7 @@ void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, } delegate->ShowBrowserWindow(); - if (replace_existing_tab && current_delegate && + if (disposition == CURRENT_TAB && current_delegate && current_delegate->GetSelectedTabContents()) { current_delegate->CloseTab(); } @@ -911,31 +911,35 @@ void TabRestoreService::CreateEntriesFromCommands( TabRestoreServiceDelegate* TabRestoreService::RestoreTab( const Tab& tab, TabRestoreServiceDelegate* delegate, - bool replace_existing_tab) { - // |browser| will be NULL in cases where one isn't already available (eg, - // when invoked on Mac OS X with no windows open). In this case, create a - // new browser into which we restore the tabs. - if (replace_existing_tab && delegate) { + WindowOpenDisposition disposition) { + if (disposition == CURRENT_TAB && delegate) { delegate->ReplaceRestoredTab(tab.navigations, tab.current_navigation_index, tab.from_last_session, tab.extension_app_id, tab.session_storage_namespace); } else { - if (tab.has_browser()) + // We only respsect the tab's original browser if there's no disposition. + if (disposition == UNKNOWN && tab.has_browser()) delegate = TabRestoreServiceDelegate::FindDelegateWithID(tab.browser_id); int tab_index = -1; - if (delegate) { + + // |delegate| will be NULL in cases where one isn't already available (eg, + // when invoked on Mac OS X with no windows open). In this case, create a + // new browser into which we restore the tabs. + if (delegate && disposition != NEW_WINDOW) { tab_index = tab.tabstrip_index; } else { delegate = TabRestoreServiceDelegate::Create(profile()); - if (tab.has_browser()) { + if (tab.has_browser()) UpdateTabBrowserIDs(tab.browser_id, delegate->GetSessionID().id()); - } } - if (tab_index < 0 || tab_index > delegate->GetTabCount()) { + // Place the tab at the end if the tab index is no longer valid or + // we were passed a specific disposition. + if (tab_index < 0 || tab_index > delegate->GetTabCount() || + disposition != UNKNOWN) { tab_index = delegate->GetTabCount(); } @@ -943,7 +947,9 @@ TabRestoreServiceDelegate* TabRestoreService::RestoreTab( tab_index, tab.current_navigation_index, tab.extension_app_id, - true, tab.pinned, tab.from_last_session, + disposition != NEW_BACKGROUND_TAB, + tab.pinned, + tab.from_last_session, tab.session_storage_namespace); } RecordAppLaunch(profile(), tab); |