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

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

Issue 10967003: Add desktop type context to most existing instances of FindTabbedBrowser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moving check_deps exception to specific_include_rules after chat with Kai. Created 8 years, 2 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) 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 25 matching lines...) Expand all
36 profile_(web_contents ? Profile::FromBrowserContext( 36 profile_(web_contents ? Profile::FromBrowserContext(
37 web_contents->GetBrowserContext()) 37 web_contents->GetBrowserContext())
38 : NULL), 38 : NULL),
39 tab_reloader_( 39 tab_reloader_(
40 new CaptivePortalTabReloader( 40 new CaptivePortalTabReloader(
41 profile_, 41 profile_,
42 web_contents, 42 web_contents,
43 base::Bind(&CaptivePortalTabHelper::OpenLoginTab, 43 base::Bind(&CaptivePortalTabHelper::OpenLoginTab,
44 base::Unretained(this)))), 44 base::Unretained(this)))),
45 login_detector_(new CaptivePortalLoginDetector(profile_)), 45 login_detector_(new CaptivePortalLoginDetector(profile_)),
46 web_contents_(web_contents),
46 pending_error_code_(net::OK), 47 pending_error_code_(net::OK),
47 provisional_render_view_host_(NULL) { 48 provisional_render_view_host_(NULL) {
48 registrar_.Add(this, 49 registrar_.Add(this,
49 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 50 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
50 content::Source<Profile>(profile_)); 51 content::Source<Profile>(profile_));
51 registrar_.Add(this, 52 registrar_.Add(this,
52 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 53 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
53 content::Source<content::WebContents>(web_contents)); 54 content::Source<content::WebContents>(web_contents));
54 registrar_.Add(this, 55 registrar_.Add(this,
55 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 56 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void CaptivePortalTabHelper::SetTabReloaderForTest( 232 void CaptivePortalTabHelper::SetTabReloaderForTest(
232 CaptivePortalTabReloader* tab_reloader) { 233 CaptivePortalTabReloader* tab_reloader) {
233 tab_reloader_.reset(tab_reloader); 234 tab_reloader_.reset(tab_reloader);
234 } 235 }
235 236
236 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { 237 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() {
237 return tab_reloader_.get(); 238 return tab_reloader_.get();
238 } 239 }
239 240
240 void CaptivePortalTabHelper::OpenLoginTab() { 241 void CaptivePortalTabHelper::OpenLoginTab() {
241 Browser* browser = browser::FindTabbedBrowser(profile_, true); 242 Browser* browser = browser::FindBrowserWithWebContents(web_contents_);
243
242 // If the Profile doesn't have a tabbed browser window open, do nothing. 244 // If the Profile doesn't have a tabbed browser window open, do nothing.
243 if (!browser) 245 if (!browser)
244 return; 246 return;
245 247
246 // Check if the Profile's topmost browser window already has a login tab. 248 // Check if the Profile's topmost browser window already has a login tab.
247 // If so, do nothing. 249 // If so, do nothing.
248 // TODO(mmenke): Consider focusing that tab, at least if this is the tab 250 // TODO(mmenke): Consider focusing that tab, at least if this is the tab
249 // helper for the currently active tab for the profile. 251 // helper for the currently active tab for the profile.
250 for (int i = 0; i < browser->tab_count(); ++i) { 252 for (int i = 0; i < browser->tab_count(); ++i) {
251 content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i); 253 content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i);
252 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = 254 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
253 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); 255 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents);
254 if (captive_portal_tab_helper->IsLoginTab()) 256 if (captive_portal_tab_helper->IsLoginTab())
255 return; 257 return;
256 } 258 }
257 259
258 // Otherwise, open a login tab. Only end up here when a captive portal result 260 // Otherwise, open a login tab. Only end up here when a captive portal result
259 // was received, so it's safe to assume |profile_| has a CaptivePortalService. 261 // was received, so it's safe to assume |profile_| has a CaptivePortalService.
260 TabContents* tab_contents = chrome::AddSelectedTabWithURL( 262 TabContents* tab_contents = chrome::AddSelectedTabWithURL(
261 browser, 263 browser,
262 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), 264 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(),
263 content::PAGE_TRANSITION_TYPED); 265 content::PAGE_TRANSITION_TYPED);
264 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = 266 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
265 captive_portal::CaptivePortalTabHelper::FromWebContents( 267 captive_portal::CaptivePortalTabHelper::FromWebContents(
266 tab_contents->web_contents()); 268 tab_contents->web_contents());
267 captive_portal_tab_helper->SetIsLoginTab(); 269 captive_portal_tab_helper->SetIsLoginTab();
268 } 270 }
269 271
270 } // namespace captive_portal 272 } // namespace captive_portal
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_tab_helper.h ('k') | chrome/browser/chromeos/enrollment_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698