| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index 74acb11a2e2b4e2918440d1e234c645a5614dcad..714d6bef6a8ff4f4a9a8070ed275c9390504f2a2 100644
|
| --- a/chrome/browser/ui/browser.cc
|
| +++ b/chrome/browser/ui/browser.cc
|
| @@ -1148,11 +1148,15 @@ bool Browser::CanRestoreTab() {
|
|
|
| bool Browser::NavigateToIndexWithDisposition(int index,
|
| WindowOpenDisposition disp) {
|
| - NavigationController& controller =
|
| - GetOrCloneTabForDisposition(disp)->controller();
|
| + TabContentsWrapper* tab = GetOrCloneTabWrapperForDisposition(disp);
|
| +
|
| + NavigationController& controller = tab->controller();
|
| if (index < 0 || index >= controller.entry_count())
|
| return false;
|
| controller.GoToIndex(index);
|
| +
|
| + CreateNewBrowserForDisposition(tab, disp);
|
| +
|
| return true;
|
| }
|
|
|
| @@ -1224,7 +1228,7 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // Browser, Assorted browser commands:
|
|
|
| -bool Browser::ShouldOpenNewTabForWindowDisposition(
|
| +bool Browser::ShouldOpenNewTabForDisposition(
|
| WindowOpenDisposition disposition) {
|
| return (disposition == NEW_FOREGROUND_TAB ||
|
| disposition == NEW_BACKGROUND_TAB);
|
| @@ -1232,15 +1236,37 @@ bool Browser::ShouldOpenNewTabForWindowDisposition(
|
|
|
| TabContents* Browser::GetOrCloneTabForDisposition(
|
| WindowOpenDisposition disposition) {
|
| + return GetOrCloneTabWrapperForDisposition(disposition)->tab_contents();
|
| +}
|
| +
|
| +TabContentsWrapper* Browser::GetOrCloneTabWrapperForDisposition(
|
| + WindowOpenDisposition disposition)
|
| +{
|
| TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| - if (ShouldOpenNewTabForWindowDisposition(disposition)) {
|
| - current_tab = current_tab->Clone();
|
| +
|
| + if (disposition == NEW_WINDOW)
|
| + return current_tab->Clone();
|
| +
|
| + if (ShouldOpenNewTabForDisposition(disposition)) {
|
| + TabContentsWrapper* new_tab = current_tab->Clone();
|
| tab_handler_->GetTabStripModel()->AddTabContents(
|
| - current_tab, -1, PageTransition::LINK,
|
| + new_tab, -1, PageTransition::LINK,
|
| disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
|
| TabStripModel::ADD_NONE);
|
| + return new_tab;
|
| + }
|
| +
|
| + return current_tab;
|
| +}
|
| +
|
| +void Browser::CreateNewBrowserForDisposition(TabContentsWrapper* tab_contents,
|
| + WindowOpenDisposition disposition)
|
| +{
|
| + if (disposition == NEW_WINDOW) {
|
| + Browser* browser = Create(profile_);
|
| + browser->AddTab(tab_contents, PageTransition::LINK);
|
| + browser->window()->Show();
|
| }
|
| - return current_tab->tab_contents();
|
| }
|
|
|
| void Browser::UpdateTabStripModelInsertionPolicy() {
|
| @@ -1303,21 +1329,30 @@ void Browser::GoBack(WindowOpenDisposition disposition) {
|
| UserMetrics::RecordAction(UserMetricsAction("Back"));
|
|
|
| TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| - if (current_tab->controller().CanGoBack()) {
|
| - TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
|
| - // If we are on an interstitial page and clone the tab, it won't be copied
|
| - // to the new tab, so we don't need to go back.
|
| - if (current_tab->tab_contents()->showing_interstitial_page() &&
|
| - (new_tab != current_tab->tab_contents()))
|
| - return;
|
| - new_tab->controller().GoBack();
|
| - }
|
| + if (!current_tab->controller().CanGoBack())
|
| + return;
|
| +
|
| + TabContentsWrapper* new_tab = GetOrCloneTabWrapperForDisposition(disposition);
|
| + if (current_tab->tab_contents()->showing_interstitial_page() &&
|
| + (new_tab != current_tab))
|
| + return;
|
| +
|
| + new_tab->controller().GoBack();
|
| +
|
| + CreateNewBrowserForDisposition(new_tab, disposition);
|
| }
|
|
|
| void Browser::GoForward(WindowOpenDisposition disposition) {
|
| UserMetrics::RecordAction(UserMetricsAction("Forward"));
|
| - if (GetSelectedTabContentsWrapper()->controller().CanGoForward())
|
| - GetOrCloneTabForDisposition(disposition)->controller().GoForward();
|
| +
|
| + TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| + if (!current_tab->controller().CanGoForward())
|
| + return;
|
| +
|
| + TabContentsWrapper* new_tab = GetOrCloneTabWrapperForDisposition(disposition);
|
| + new_tab->controller().GoForward();
|
| +
|
| + CreateNewBrowserForDisposition(new_tab, disposition);
|
| }
|
|
|
| void Browser::Reload(WindowOpenDisposition disposition) {
|
|
|