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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_helper.cc

Issue 11434074: browser: Move FindBrowserWithWebContents() into chrome namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/captive_portal/captive_portal_tab_helper.h" 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" 8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h"
9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" 9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h"
10 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" 10 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void CaptivePortalTabHelper::SetTabReloaderForTest( 233 void CaptivePortalTabHelper::SetTabReloaderForTest(
234 CaptivePortalTabReloader* tab_reloader) { 234 CaptivePortalTabReloader* tab_reloader) {
235 tab_reloader_.reset(tab_reloader); 235 tab_reloader_.reset(tab_reloader);
236 } 236 }
237 237
238 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { 238 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() {
239 return tab_reloader_.get(); 239 return tab_reloader_.get();
240 } 240 }
241 241
242 void CaptivePortalTabHelper::OpenLoginTab() { 242 void CaptivePortalTabHelper::OpenLoginTab() {
243 Browser* browser = browser::FindBrowserWithWebContents(web_contents_); 243 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
244 244
245 // If the Profile doesn't have a tabbed browser window open, do nothing. 245 // If the Profile doesn't have a tabbed browser window open, do nothing.
246 if (!browser) 246 if (!browser)
247 return; 247 return;
248 248
249 // Check if the Profile's topmost browser window already has a login tab. 249 // Check if the Profile's topmost browser window already has a login tab.
250 // If so, do nothing. 250 // If so, do nothing.
251 // TODO(mmenke): Consider focusing that tab, at least if this is the tab 251 // TODO(mmenke): Consider focusing that tab, at least if this is the tab
252 // helper for the currently active tab for the profile. 252 // helper for the currently active tab for the profile.
253 for (int i = 0; i < browser->tab_count(); ++i) { 253 for (int i = 0; i < browser->tab_count(); ++i) {
254 content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i); 254 content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i);
255 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = 255 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
256 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); 256 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents);
257 if (captive_portal_tab_helper->IsLoginTab()) 257 if (captive_portal_tab_helper->IsLoginTab())
258 return; 258 return;
259 } 259 }
260 260
261 // Otherwise, open a login tab. Only end up here when a captive portal result 261 // Otherwise, open a login tab. Only end up here when a captive portal result
262 // was received, so it's safe to assume |profile_| has a CaptivePortalService. 262 // was received, so it's safe to assume |profile_| has a CaptivePortalService.
263 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( 263 content::WebContents* web_contents = chrome::AddSelectedTabWithURL(
264 browser, 264 browser,
265 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), 265 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(),
266 content::PAGE_TRANSITION_TYPED); 266 content::PAGE_TRANSITION_TYPED);
267 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = 267 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
268 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); 268 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents);
269 captive_portal_tab_helper->SetIsLoginTab(); 269 captive_portal_tab_helper->SetIsLoginTab();
270 } 270 }
271 271
272 } // namespace captive_portal 272 } // namespace captive_portal
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/extensions/app_notify_channel_ui_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698