diff options
author | dilmah@chromium.org <dilmah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 10:07:11 +0000 |
---|---|---|
committer | dilmah@chromium.org <dilmah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 10:07:11 +0000 |
commit | 07afd7c54e974e537fd094f0f4c41784ab5919b1 (patch) | |
tree | 84edcd71fedbfb4f19ca63c3c70fc144dfb08926 /chrome/browser/ui/browser_navigator.cc | |
parent | 9ada3e8ddf24fad1f34d02527708de8f7f29083a (diff) | |
download | chromium_src-07afd7c54e974e537fd094f0f4c41784ab5919b1.zip chromium_src-07afd7c54e974e537fd094f0f4c41784ab5919b1.tar.gz chromium_src-07afd7c54e974e537fd094f0f4c41784ab5919b1.tar.bz2 |
Enhance search for SINGLETON_TAB in case of ignore_path flag.
If we are ignoring path then it makes sense to ignore also a Query part.
If there are several matches: prefer currently selected tab.
BUG=chromium-os:11047
TEST=Manual
Review URL: http://codereview.chromium.org/6489002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_navigator.cc')
-rw-r--r-- | chrome/browser/ui/browser_navigator.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index bcd40cf..f009028 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -1,9 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/browser_navigator.h" +#include <algorithm> + #include "base/command_line.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_url_handler.h" @@ -82,21 +84,28 @@ int GetIndexOfSingletonTab(browser::NavigateParams* params) { params->browser->profile(), &reverse_on_redirect); - for (int i = 0; i < params->browser->tab_count(); ++i) { + // If there are several matches: prefer currently selected tab. So we are + // starting our search at selected tab. + int start_index = std::max(0, params->browser->selected_index()); + int tab_count = params->browser->tab_count(); + for (int i = 0; i < tab_count; ++i) { + int tab_index = (start_index + i) % tab_count; TabContentsWrapper* tab = - params->browser->GetTabContentsWrapperAt(i); + params->browser->GetTabContentsWrapperAt(tab_index); url_canon::Replacements<char> replacements; replacements.ClearRef(); - if (params->ignore_path) + if (params->ignore_path) { replacements.ClearPath(); + replacements.ClearQuery(); + } if (CompareURLsWithReplacements(tab->tab_contents()->GetURL(), params->url, replacements) || CompareURLsWithReplacements(tab->tab_contents()->GetURL(), rewritten_url, replacements)) { params->target_contents = tab; - return i; + return tab_index; } } |