Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/tabs/tab_finder.cc

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tabs/tab_finder.h" 5 #include "chrome/browser/tabs/tab_finder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 TabFinder* TabFinder::GetInstance() { 74 TabFinder* TabFinder::GetInstance() {
75 return IsEnabled() ? Singleton<TabFinder>::get() : NULL; 75 return IsEnabled() ? Singleton<TabFinder>::get() : NULL;
76 } 76 }
77 77
78 // static 78 // static
79 bool TabFinder::IsEnabled() { 79 bool TabFinder::IsEnabled() {
80 return CommandLine::ForCurrentProcess()->HasSwitch( 80 return CommandLine::ForCurrentProcess()->HasSwitch(
81 switches::kFocusExistingTabOnOpen); 81 switches::kFocusExistingTabOnOpen);
82 } 82 }
83 83
84 TabContents* TabFinder::FindTab(Browser* browser, 84 WebContents* TabFinder::FindTab(Browser* browser,
85 const GURL& url, 85 const GURL& url,
86 Browser** existing_browser) { 86 Browser** existing_browser) {
87 if (browser->profile()->IsOffTheRecord()) 87 if (browser->profile()->IsOffTheRecord())
88 return NULL; 88 return NULL;
89 89
90 // If the current tab matches the url, ignore it and let the user reload the 90 // If the current tab matches the url, ignore it and let the user reload the
91 // existing tab. 91 // existing tab.
92 TabContents* selected_tab = browser->GetSelectedTabContents(); 92 WebContents* selected_tab = browser->GetSelectedWebContents();
93 if (TabMatchesURL(selected_tab, url)) 93 if (TabMatchesURL(selected_tab, url))
94 return NULL; 94 return NULL;
95 95
96 // See if the current browser has a tab matching the specified url. 96 // See if the current browser has a tab matching the specified url.
97 TabContents* tab_in_browser = FindTabInBrowser(browser, url); 97 WebContents* tab_in_browser = FindTabInBrowser(browser, url);
98 if (tab_in_browser) { 98 if (tab_in_browser) {
99 *existing_browser = browser; 99 *existing_browser = browser;
100 return tab_in_browser; 100 return tab_in_browser;
101 } 101 }
102 102
103 // Then check other browsers. 103 // Then check other browsers.
104 for (BrowserList::const_iterator i = BrowserList::begin(); 104 for (BrowserList::const_iterator i = BrowserList::begin();
105 i != BrowserList::end(); ++i) { 105 i != BrowserList::end(); ++i) {
106 if (!(*i)->profile()->IsOffTheRecord() && 106 if (!(*i)->profile()->IsOffTheRecord() &&
107 (*i)->profile()->IsSameProfile(browser->profile())) { 107 (*i)->profile()->IsSameProfile(browser->profile())) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 bool TabFinder::TabMatchesURL(WebContents* tab_contents, const GURL& url) { 153 bool TabFinder::TabMatchesURL(WebContents* tab_contents, const GURL& url) {
154 if (tab_contents->GetURL() == url) 154 if (tab_contents->GetURL() == url)
155 return true; 155 return true;
156 156
157 WebContentsToURLMap::const_iterator i = 157 WebContentsToURLMap::const_iterator i =
158 web_contents_to_url_.find(tab_contents); 158 web_contents_to_url_.find(tab_contents);
159 return i != web_contents_to_url_.end() && i->second == url; 159 return i != web_contents_to_url_.end() && i->second == url;
160 } 160 }
161 161
162 TabContents* TabFinder::FindTabInBrowser(Browser* browser, const GURL& url) { 162 WebContents* TabFinder::FindTabInBrowser(Browser* browser, const GURL& url) {
163 if (!browser->is_type_tabbed()) 163 if (!browser->is_type_tabbed())
164 return NULL; 164 return NULL;
165 165
166 for (int i = 0; i < browser->tab_count(); ++i) { 166 for (int i = 0; i < browser->tab_count(); ++i) {
167 if (TabMatchesURL(browser->GetTabContentsAt(i), url)) 167 if (TabMatchesURL(browser->GetTabContentsAt(i), url))
168 return browser->GetTabContentsAt(i); 168 return browser->GetTabContentsAt(i);
169 } 169 }
170 return NULL; 170 return NULL;
171 } 171 }
172 172
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 GURL url, 234 GURL url,
235 bool success, 235 bool success,
236 history::RedirectList* redirects) { 236 history::RedirectList* redirects) {
237 if (success && !redirects->empty()) { 237 if (success && !redirects->empty()) {
238 WebContents* web_contents = 238 WebContents* web_contents =
239 callback_consumer_.GetClientDataForCurrentRequest(); 239 callback_consumer_.GetClientDataForCurrentRequest();
240 DCHECK(web_contents); 240 DCHECK(web_contents);
241 web_contents_to_url_[web_contents] = redirects->back(); 241 web_contents_to_url_[web_contents] = redirects->back();
242 } 242 }
243 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_finder.h ('k') | chrome/browser/task_manager/task_manager_resource_providers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698