OLD | NEW |
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 Loading... |
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 // Opens a login tab if the profile's active window doesn't have one already. |
| 99 static void OpenLoginTabForWebContents(content::WebContents* web_contents, |
| 100 bool focus); |
| 101 |
98 private: | 102 private: |
99 friend class CaptivePortalBrowserTest; | 103 friend class CaptivePortalBrowserTest; |
100 friend class CaptivePortalTabHelperTest; | 104 friend class CaptivePortalTabHelperTest; |
101 | 105 |
102 friend class content::WebContentsUserData<CaptivePortalTabHelper>; | 106 friend class content::WebContentsUserData<CaptivePortalTabHelper>; |
103 explicit CaptivePortalTabHelper(content::WebContents* web_contents); | 107 explicit CaptivePortalTabHelper(content::WebContents* web_contents); |
104 | 108 |
105 // Called by Observe in response to the corresponding event. | 109 // Called by Observe in response to the corresponding event. |
106 void OnRedirect(int child_id, | 110 void OnRedirect(int child_id, |
107 content::ResourceType resource_type, | 111 content::ResourceType resource_type, |
(...skipping 12 matching lines...) Expand all Loading... |
120 | 124 |
121 // |this| takes ownership of |tab_reloader|. | 125 // |this| takes ownership of |tab_reloader|. |
122 void SetTabReloaderForTest(CaptivePortalTabReloader* tab_reloader); | 126 void SetTabReloaderForTest(CaptivePortalTabReloader* tab_reloader); |
123 | 127 |
124 const content::RenderViewHost* provisional_render_view_host() const { | 128 const content::RenderViewHost* provisional_render_view_host() const { |
125 return provisional_render_view_host_; | 129 return provisional_render_view_host_; |
126 } | 130 } |
127 | 131 |
128 CaptivePortalTabReloader* GetTabReloaderForTest(); | 132 CaptivePortalTabReloader* GetTabReloaderForTest(); |
129 | 133 |
130 // Opens a login tab if the profile's active window doesn't have one already. | |
131 void OpenLoginTab(); | |
132 | |
133 Profile* profile_; | 134 Profile* profile_; |
134 | 135 |
135 // Neither of these will ever be NULL. | 136 // Neither of these will ever be NULL. |
136 scoped_ptr<CaptivePortalTabReloader> tab_reloader_; | 137 scoped_ptr<CaptivePortalTabReloader> tab_reloader_; |
137 scoped_ptr<CaptivePortalLoginDetector> login_detector_; | 138 scoped_ptr<CaptivePortalLoginDetector> login_detector_; |
138 | 139 |
139 content::WebContents* web_contents_; | 140 content::WebContents* web_contents_; |
140 | 141 |
141 // If a provisional load has failed, and the tab is loading an error page, the | 142 // 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. | 143 // error code associated with the error page we're loading. |
143 // net::OK, otherwise. | 144 // net::OK, otherwise. |
144 int pending_error_code_; | 145 int pending_error_code_; |
145 | 146 |
146 // The RenderViewHost with a provisional load, if any. Can either be | 147 // The RenderViewHost with a provisional load, if any. Can either be |
147 // the currently displayed RenderViewHost or a pending RenderViewHost for | 148 // the currently displayed RenderViewHost or a pending RenderViewHost for |
148 // cross-process navitations. NULL when there's currently no provisional | 149 // cross-process navitations. NULL when there's currently no provisional |
149 // load. | 150 // load. |
150 content::RenderViewHost* provisional_render_view_host_; | 151 content::RenderViewHost* provisional_render_view_host_; |
151 | 152 |
152 content::NotificationRegistrar registrar_; | 153 content::NotificationRegistrar registrar_; |
153 | 154 |
154 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelper); | 155 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelper); |
155 }; | 156 }; |
156 | 157 |
157 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_ | 158 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_ |
OLD | NEW |