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

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: Fix Android builds Created 5 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 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 bd4895ba17342cc89d57e098a669ab17a8d0c978..ec60bea87e921fb0d5aefb783fab4a28402051be 100644
--- a/chrome/browser/captive_portal/captive_portal_tab_helper.cc
+++ b/chrome/browser/captive_portal/captive_portal_tab_helper.cc
@@ -42,8 +42,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),
@@ -193,6 +193,44 @@ bool CaptivePortalTabHelper::IsLoginTab() const {
return login_detector_->is_login_tab();
}
+// 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)
+ return;
+
+ // Check if the Profile's topmost browser window already has a login tab.
+ // If so, do nothing.
+ // 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* contents =
+ browser->tab_strip_model()->GetWebContentsAt(i);
+ CaptivePortalTabHelper* captive_portal_tab_helper =
+ 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* new_contents = chrome::AddSelectedTabWithURL(
+ browser,
+ CaptivePortalServiceFactory::GetForProfile(
+ browser->profile())->test_url(),
+ ui::PAGE_TRANSITION_TYPED);
+ CaptivePortalTabHelper* captive_portal_tab_helper =
+ CaptivePortalTabHelper::FromWebContents(new_contents);
+ captive_portal_tab_helper->SetIsLoginTab();
+}
+
void CaptivePortalTabHelper::OnRedirect(int child_id,
ResourceType resource_type,
const GURL& new_url) {
@@ -234,34 +272,3 @@ void CaptivePortalTabHelper::SetTabReloaderForTest(
CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() {
return tab_reloader_.get();
}
-
-void CaptivePortalTabHelper::OpenLoginTab() {
- Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
-
- // If the Profile doesn't have a tabbed browser window open, do nothing.
- if (!browser)
- return;
-
- // Check if the Profile's topmost browser window already has a login tab.
- // If so, do nothing.
- // 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 =
- browser->tab_strip_model()->GetWebContentsAt(i);
- CaptivePortalTabHelper* captive_portal_tab_helper =
- CaptivePortalTabHelper::FromWebContents(web_contents);
- if (captive_portal_tab_helper->IsLoginTab())
- 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(),
- ui::PAGE_TRANSITION_TYPED);
- CaptivePortalTabHelper* captive_portal_tab_helper =
- CaptivePortalTabHelper::FromWebContents(web_contents);
- captive_portal_tab_helper->SetIsLoginTab();
-}
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_tab_helper.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698