Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
| index edebe564bb01b50a69d42a5fcc0014c72de7af9f..5e27cfcdcd4a522c05e8c5435a2f738b8a20cf55 100644 |
| --- a/chrome/browser/ui/browser.cc |
| +++ b/chrome/browser/ui/browser.cc |
| @@ -1273,21 +1273,56 @@ void Browser::GoBack(WindowOpenDisposition disposition) { |
| UserMetrics::RecordAction(UserMetricsAction("Back")); |
| 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")); |
| - 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_); |
|
brettw
2011/05/03 19:43:53
It seems like this logic should be inside GetOrClo
|
| + browser->InitBrowserWindow(); |
| + browser->AddTab(new_wrapper, PageTransition::LINK); |
| + browser->window()->Show(); |
| + } else { |
| GetOrCloneTabForDisposition(disposition)->controller().GoForward(); |
| + } |
| } |
| void Browser::Reload(WindowOpenDisposition disposition) { |