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

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

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Expand browser tests Created 6 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 #ifndef CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
6 #define CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_ 6 #define CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "chrome/browser/captive_portal/captive_portal_service.h" 12 #include "chrome/browser/captive_portal/captive_portal_service.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
17 #include "content/public/common/resource_type.h" 17 #include "content/public/common/resource_type.h"
18 18
19 class GURL; 19 class GURL;
20 class Profile; 20 class Profile;
21 21
22 namespace content { 22 namespace content {
23 class WebContents; 23 class WebContents;
24 } 24 }
25 25
26 namespace net { 26 namespace net {
27 class SSLInfo; 27 class SSLInfo;
28 } 28 }
29 29
30 class CaptivePortalLoginDetector; 30 class CaptivePortalLoginDetector;
31 class CaptivePortalTabReloader; 31 class CaptivePortalTabReloader;
32 32
33 // Along with the classes it owns, responsible for detecting page loads broken 33 // Along with the classes it owns, responsible for detecting page loads broken
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const content::NotificationSource& source, 88 const content::NotificationSource& source,
89 const content::NotificationDetails& details) override; 89 const content::NotificationDetails& details) override;
90 90
91 // Called when a certificate interstitial error page is about to be shown. 91 // Called when a certificate interstitial error page is about to be shown.
92 void OnSSLCertError(const net::SSLInfo& ssl_info); 92 void OnSSLCertError(const net::SSLInfo& ssl_info);
93 93
94 // A "Login Tab" is a tab that was originally at a captive portal login 94 // A "Login Tab" is a tab that was originally at a captive portal login
95 // page. This is set to false when a captive portal is no longer detected. 95 // page. This is set to false when a captive portal is no longer detected.
96 bool IsLoginTab() const; 96 bool IsLoginTab() const;
97 97
98 // Returns the delay to show an SSL interstitial if a cert error occurs.
99 base::TimeDelta GetSSLErrorDelay() const;
100
101 // Opens a login tab if the profile's active window doesn't have one already.
102 static void OpenLoginTabForWebContents(content::WebContents* web_contents,
103 bool focus);
104
98 private: 105 private:
99 friend class CaptivePortalBrowserTest; 106 friend class CaptivePortalBrowserTest;
100 friend class CaptivePortalTabHelperTest; 107 friend class CaptivePortalTabHelperTest;
101 108
102 friend class content::WebContentsUserData<CaptivePortalTabHelper>; 109 friend class content::WebContentsUserData<CaptivePortalTabHelper>;
103 explicit CaptivePortalTabHelper(content::WebContents* web_contents); 110 explicit CaptivePortalTabHelper(content::WebContents* web_contents);
104 111
105 // Called by Observe in response to the corresponding event. 112 // Called by Observe in response to the corresponding event.
106 void OnRedirect(int child_id, 113 void OnRedirect(int child_id,
107 content::ResourceType resource_type, 114 content::ResourceType resource_type,
108 const GURL& new_url); 115 const GURL& new_url);
109 116
110 // Called by Observe in response to the corresponding event. 117 // Called by Observe in response to the corresponding event.
111 void OnCaptivePortalResults( 118 void OnCaptivePortalResults(
112 captive_portal::CaptivePortalResult previous_result, 119 captive_portal::CaptivePortalResult previous_result,
113 captive_portal::CaptivePortalResult result); 120 captive_portal::CaptivePortalResult result);
114 121
115 void OnLoadAborted(); 122 void OnLoadAborted();
116 123
117 // Called to indicate a tab is at, or is navigating to, the captive portal 124 // Called to indicate a tab is at, or is navigating to, the captive portal
118 // login page. 125 // login page.
119 void SetIsLoginTab(); 126 void SetIsLoginTab();
120 127
121 // |this| takes ownership of |tab_reloader|. 128 // |this| takes ownership of |tab_reloader|.
122 void SetTabReloaderForTest(CaptivePortalTabReloader* tab_reloader); 129 void SetTabReloaderForTest(CaptivePortalTabReloader* tab_reloader);
123 130
131 void SetSSLErrorDelayForTest(base::TimeDelta ssl_error_delay);
132
124 const content::RenderViewHost* provisional_render_view_host() const { 133 const content::RenderViewHost* provisional_render_view_host() const {
125 return provisional_render_view_host_; 134 return provisional_render_view_host_;
126 } 135 }
127 136
128 CaptivePortalTabReloader* GetTabReloaderForTest(); 137 CaptivePortalTabReloader* GetTabReloaderForTest();
129 138
130 // Opens a login tab if the profile's active window doesn't have one already.
131 void OpenLoginTab();
132
133 Profile* profile_; 139 Profile* profile_;
134 140
135 // Neither of these will ever be NULL. 141 // Neither of these will ever be NULL.
136 scoped_ptr<CaptivePortalTabReloader> tab_reloader_; 142 scoped_ptr<CaptivePortalTabReloader> tab_reloader_;
137 scoped_ptr<CaptivePortalLoginDetector> login_detector_; 143 scoped_ptr<CaptivePortalLoginDetector> login_detector_;
138 144
139 content::WebContents* web_contents_; 145 content::WebContents* web_contents_;
140 146
141 // If a provisional load has failed, and the tab is loading an error page, the 147 // If a provisional load has failed, and the tab is loading an error page, the
142 // error code associated with the error page we're loading. 148 // error code associated with the error page we're loading.
143 // net::OK, otherwise. 149 // net::OK, otherwise.
144 int pending_error_code_; 150 int pending_error_code_;
145 151
152 base::TimeDelta ssl_error_delay_;
mmenke 2014/12/09 22:42:26 As much as I dislike statics variables, I think th
meacer 2014/12/10 22:48:02 Moved to SSLErrorHandler as a static variable.
153
146 // The RenderViewHost with a provisional load, if any. Can either be 154 // The RenderViewHost with a provisional load, if any. Can either be
147 // the currently displayed RenderViewHost or a pending RenderViewHost for 155 // the currently displayed RenderViewHost or a pending RenderViewHost for
148 // cross-process navitations. NULL when there's currently no provisional 156 // cross-process navitations. NULL when there's currently no provisional
149 // load. 157 // load.
150 content::RenderViewHost* provisional_render_view_host_; 158 content::RenderViewHost* provisional_render_view_host_;
151 159
152 content::NotificationRegistrar registrar_; 160 content::NotificationRegistrar registrar_;
153 161
154 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelper); 162 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelper);
155 }; 163 };
156 164
157 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_ 165 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698