summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 18:39:28 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 18:39:28 +0000
commit968e56aeb9ac7c51f7b1cb36cd7a5586fd13e966 (patch)
tree37f9285568dcdf87f42f171dcd73b2f0dc51dafe /chrome/browser/browser.cc
parent0d6ac82ec35133d4be884c54a1e48a371570272f (diff)
downloadchromium_src-968e56aeb9ac7c51f7b1cb36cd7a5586fd13e966.zip
chromium_src-968e56aeb9ac7c51f7b1cb36cd7a5586fd13e966.tar.gz
chromium_src-968e56aeb9ac7c51f7b1cb36cd7a5586fd13e966.tar.bz2
When a new tab is opened (either the new tab page via Ctrl+T or pressing the new tab button) or an address is opened from the address bar in a new tab (by pressing Alt+Enter), the opener is remembered briefly, allowing quick lookup in a new tab without disrupting the z-order experience.
Full explanation in bug: B=1266404 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@330 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 7a0bbb0..47299ce 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -589,14 +589,30 @@ void Browser::OpenURLFromTab(TabContents* source,
transition == PageTransition::AUTO_BOOKMARK ||
transition == PageTransition::GENERATED ||
transition == PageTransition::START_PAGE) {
- // If the user navigates the current tab to another page in any way other
- // than by clicking a link, we want to pro-actively forget all TabStrip
- // opener relationships since we assume they're beginning a different
- // task by reusing the current tab.
- tabstrip_model_.ForgetAllOpeners();
- // In this specific case we also want to reset the group relationship,
- // since it is now technically invalid.
- tabstrip_model_.ForgetGroup(current_tab);
+ // Don't forget the openers if this tab is a New Tab page opened at the
+ // end of the TabStrip (e.g. by pressing Ctrl+T). Give the user one
+ // navigation of one of these transition types before resetting the
+ // opener relationships (this allows for the use case of opening a new
+ // tab to do a quick look-up of something while viewing a tab earlier in
+ // the strip). We can make this heuristic more permissive if need be.
+ // TODO(beng): (http://b/1306495) write unit tests for this once this
+ // object is unit-testable.
+ int current_tab_index =
+ tabstrip_model_.GetIndexOfTabContents(current_tab);
+ bool forget_openers =
+ !(current_tab->type() == TAB_CONTENTS_NEW_TAB_UI &&
+ current_tab_index == (tab_count() - 1) &&
+ current_tab->controller()->GetEntryCount() == 1);
+ if (forget_openers) {
+ // If the user navigates the current tab to another page in any way
+ // other than by clicking a link, we want to pro-actively forget all
+ // TabStrip opener relationships since we assume they're beginning a
+ // different task by reusing the current tab.
+ tabstrip_model_.ForgetAllOpeners();
+ // In this specific case we also want to reset the group relationship,
+ // since it is now technically invalid.
+ tabstrip_model_.ForgetGroup(current_tab);
+ }
}
current_tab->controller()->LoadURL(url, transition);
// The TabContents might have changed as part of the navigation (ex: new tab