| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index 101b622c990ba7b2aa5aa4ceb2b0640577442187..565c6887279ddbe8492d4e2893adcd59903a173b 100644
|
| --- a/chrome/browser/ui/browser.cc
|
| +++ b/chrome/browser/ui/browser.cc
|
| @@ -1190,11 +1190,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;
|
| }
|
|
|
| @@ -1267,7 +1271,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);
|
| @@ -1275,15 +1279,35 @@ 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() {
|
| @@ -1350,21 +1374,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) {
|
|
|