diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 18:39:28 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 18:39:28 +0000 |
commit | 968e56aeb9ac7c51f7b1cb36cd7a5586fd13e966 (patch) | |
tree | 37f9285568dcdf87f42f171dcd73b2f0dc51dafe /chrome/browser/tabs/tab_strip_model.cc | |
parent | 0d6ac82ec35133d4be884c54a1e48a371570272f (diff) | |
download | chromium_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/tabs/tab_strip_model.cc')
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index c2076f1..3b632fe 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -346,6 +346,13 @@ void TabStripModel::ForgetGroup(TabContents* contents) { int index = GetIndexOfTabContents(contents); DCHECK(ContainsIndex(index)); contents_data_.at(index)->SetGroup(NULL); + contents_data_.at(index)->ForgetOpener(); +} + +bool TabStripModel::ShouldResetGroupOnSelect(TabContents* contents) const { + int index = GetIndexOfTabContents(contents); + DCHECK(ContainsIndex(index)); + return contents_data_.at(index)->reset_group_on_select; } TabContents* TabStripModel::AddBlankTab(bool foreground) { @@ -378,8 +385,22 @@ void TabStripModel::AddTabContents(TabContents* contents, index = count(); } TabContents* last_selected_contents = GetSelectedTabContents(); - InsertTabContentsAt( - index, contents, foreground, transition == PageTransition::LINK); + // Tabs opened from links inherit the "group" attribute of the Tab from which + // they were opened. This means when they're closed, that Tab will be + // selected again. + bool inherit_group = transition == PageTransition::LINK; + if (!inherit_group) { + // Also, any tab opened at the end of the TabStrip with a "TYPED" + // transition inherit group as well. This covers the cases where the user + // creates a New Tab (e.g. Ctrl+T, or clicks the New Tab button), or types + // in the address bar and presses Alt+Enter. This allows for opening a new + // Tab to quickly look up something. When this Tab is closed, the old one + // is re-selected, not the next-adjacent. + inherit_group = transition == PageTransition::TYPED && index == count(); + } + InsertTabContentsAt(index, contents, foreground, inherit_group); + if (inherit_group && transition == PageTransition::TYPED) + contents_data_.at(index)->reset_group_on_select = true; } void TabStripModel::CloseSelectedTab() { |