| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index 4d1777e99271ace15aef6e9ba0c8fc15b03fccc9..e3d8bbc460884c0bab5b74fe058b19461a918f33 100644
|
| --- a/chrome/browser/ui/browser.cc
|
| +++ b/chrome/browser/ui/browser.cc
|
| @@ -1207,6 +1207,7 @@ bool Browser::ShouldOpenNewTabForWindowDisposition(
|
| TabContents* Browser::GetOrCloneTabForDisposition(
|
| WindowOpenDisposition disposition) {
|
| TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| +
|
| if (ShouldOpenNewTabForWindowDisposition(disposition)) {
|
| current_tab = current_tab->Clone();
|
| tab_handler_->GetTabStripModel()->AddTabContents(
|
| @@ -1214,6 +1215,7 @@ TabContents* Browser::GetOrCloneTabForDisposition(
|
| disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
|
| TabStripModel::ADD_NONE);
|
| }
|
| +
|
| return current_tab->tab_contents();
|
| }
|
|
|
| @@ -1278,21 +1280,56 @@ void Browser::GoBack(WindowOpenDisposition disposition) {
|
| UserMetrics::RecordAction(UserMetricsAction("Back"), profile_);
|
|
|
| TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| - if (current_tab->controller().CanGoBack()) {
|
| - TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
|
| + if (!current_tab->controller().CanGoBack())
|
| + return;
|
| +
|
| + if (disposition == NEW_WINDOW) {
|
| + TabContentsWrapper* new_wrapper = current_tab->Clone();
|
| +
|
| // 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_wrapper->tab_contents() != current_tab->tab_contents()))
|
| + return;
|
| +
|
| + new_wrapper->tab_contents()->controller().GoBack();
|
| +
|
| + // Make a new normal browser window.
|
| + Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
|
| + browser->InitBrowserWindow();
|
| + browser->AddTab(new_wrapper, PageTransition::LINK);
|
| + browser->window()->Show();
|
| + } else {
|
| + TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
|
| +
|
| + if (current_tab->tab_contents()->showing_interstitial_page() &&
|
| (new_tab != current_tab->tab_contents()))
|
| return;
|
| +
|
| new_tab->controller().GoBack();
|
| }
|
| }
|
|
|
| void Browser::GoForward(WindowOpenDisposition disposition) {
|
| UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_);
|
| - if (GetSelectedTabContentsWrapper()->controller().CanGoForward())
|
| +
|
| + TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
|
| + if (!current_tab->controller().CanGoForward())
|
| + return;
|
| +
|
| + if (disposition == NEW_WINDOW) {
|
| + TabContentsWrapper* new_wrapper = current_tab->Clone();
|
| +
|
| + new_wrapper->tab_contents()->controller().GoForward();
|
| +
|
| + // Make a new normal browser window.
|
| + Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
|
| + browser->InitBrowserWindow();
|
| + browser->AddTab(new_wrapper, PageTransition::LINK);
|
| + browser->window()->Show();
|
| + } else {
|
| GetOrCloneTabForDisposition(disposition)->controller().GoForward();
|
| + }
|
| }
|
|
|
| void Browser::Reload(WindowOpenDisposition disposition) {
|
|
|