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

Unified Diff: chrome/browser/captive_portal/captive_portal_tab_helper.cc

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Const all the things Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/captive_portal/captive_portal_tab_helper.cc
diff --git a/chrome/browser/captive_portal/captive_portal_tab_helper.cc b/chrome/browser/captive_portal/captive_portal_tab_helper.cc
index d939bdaec5a99cb906a6acea4c9fc02fa199e557..8f203f0b7d6acb3621a5c72b3fb023a30288ede0 100644
--- a/chrome/browser/captive_portal/captive_portal_tab_helper.cc
+++ b/chrome/browser/captive_portal/captive_portal_tab_helper.cc
@@ -40,8 +40,8 @@ CaptivePortalTabHelper::CaptivePortalTabHelper(
new CaptivePortalTabReloader(
profile_,
web_contents,
- base::Bind(&CaptivePortalTabHelper::OpenLoginTab,
- base::Unretained(this)))),
+ base::Bind(&CaptivePortalTabHelper::OpenLoginTabForWebContents,
+ web_contents, false))),
login_detector_(new CaptivePortalLoginDetector(profile_)),
web_contents_(web_contents),
pending_error_code_(net::OK),
@@ -239,8 +239,11 @@ CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() {
return tab_reloader_.get();
}
-void CaptivePortalTabHelper::OpenLoginTab() {
- Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
+// static
+void CaptivePortalTabHelper::OpenLoginTabForWebContents(
+ content::WebContents* web_contents,
+ bool focus) {
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
// If the Profile doesn't have a tabbed browser window open, do nothing.
if (!browser)
@@ -251,21 +254,25 @@ void CaptivePortalTabHelper::OpenLoginTab() {
// TODO(mmenke): Consider focusing that tab, at least if this is the tab
// helper for the currently active tab for the profile.
for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
- content::WebContents* web_contents =
+ content::WebContents* contents =
browser->tab_strip_model()->GetWebContentsAt(i);
CaptivePortalTabHelper* captive_portal_tab_helper =
- CaptivePortalTabHelper::FromWebContents(web_contents);
- if (captive_portal_tab_helper->IsLoginTab())
+ CaptivePortalTabHelper::FromWebContents(contents);
+ if (captive_portal_tab_helper->IsLoginTab()) {
+ if (focus)
+ browser->tab_strip_model()->ActivateTabAt(i, false);
return;
+ }
}
// Otherwise, open a login tab. Only end up here when a captive portal result
- // was received, so it's safe to assume |profile_| has a CaptivePortalService.
- content::WebContents* web_contents = chrome::AddSelectedTabWithURL(
- browser,
- CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(),
- content::PAGE_TRANSITION_TYPED);
+ // was received, so it's safe to assume profile has a CaptivePortalService.
+ content::WebContents* contents = chrome::AddSelectedTabWithURL(
mmenke 2014/06/24 18:09:26 nit: new_contents or login_web_contents or login_
meacer 2014/10/22 23:04:28 Done.
+ browser,
+ CaptivePortalServiceFactory::GetForProfile(
+ browser->profile())->test_url(),
+ content::PAGE_TRANSITION_TYPED);
CaptivePortalTabHelper* captive_portal_tab_helper =
- CaptivePortalTabHelper::FromWebContents(web_contents);
+ CaptivePortalTabHelper::FromWebContents(contents);
captive_portal_tab_helper->SetIsLoginTab();
}

Powered by Google App Engine
This is Rietveld 408576698