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_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget_observer.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 class Widget; | 14 class Widget; |
15 } | 15 } |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 class CaptivePortalView; | 19 class CaptivePortalView; |
20 | 20 |
21 // Delegate interface for CaptivePortalWindowProxy. | 21 // Delegate interface for CaptivePortalWindowProxy. |
22 class CaptivePortalWindowProxyDelegate { | 22 class CaptivePortalWindowProxyDelegate { |
23 public: | 23 public: |
24 // Called when a captive portal is detected. | 24 // Called when a captive portal is detected. |
25 virtual void OnPortalDetected() = 0; | 25 virtual void OnPortalDetected() = 0; |
26 | 26 |
27 protected: | 27 protected: |
28 virtual ~CaptivePortalWindowProxyDelegate() {} | 28 virtual ~CaptivePortalWindowProxyDelegate() {} |
29 }; | 29 }; |
30 | 30 |
31 // Proxy which manages showing of the window for CaptivePortal sign-in. | 31 // Proxy which manages showing of the window for CaptivePortal sign-in. |
32 class CaptivePortalWindowProxy : public views::Widget::Observer { | 32 class CaptivePortalWindowProxy : public views::WidgetObserver { |
33 public: | 33 public: |
34 typedef CaptivePortalWindowProxyDelegate Delegate; | 34 typedef CaptivePortalWindowProxyDelegate Delegate; |
35 | 35 |
36 CaptivePortalWindowProxy(Delegate* delegate, gfx::NativeWindow parent); | 36 CaptivePortalWindowProxy(Delegate* delegate, gfx::NativeWindow parent); |
37 virtual ~CaptivePortalWindowProxy(); | 37 virtual ~CaptivePortalWindowProxy(); |
38 | 38 |
39 // Shows captive portal window only after a redirection has happened. So it is | 39 // Shows captive portal window only after a redirection has happened. So it is |
40 // safe to call this method, when the caller isn't 100% sure that the network | 40 // safe to call this method, when the caller isn't 100% sure that the network |
41 // is in the captive portal state. | 41 // is in the captive portal state. |
42 // Subsequent call to this method would reuses existing view | 42 // Subsequent call to this method would reuses existing view |
43 // but reloads test page (generate_204). | 43 // but reloads test page (generate_204). |
44 void ShowIfRedirected(); | 44 void ShowIfRedirected(); |
45 | 45 |
46 // Forces captive portal window show. | 46 // Forces captive portal window show. |
47 void Show(); | 47 void Show(); |
48 | 48 |
49 // Closes the window. | 49 // Closes the window. |
50 void Close(); | 50 void Close(); |
51 | 51 |
52 // Called by CaptivePortalView when URL loading was redirected from the | 52 // Called by CaptivePortalView when URL loading was redirected from the |
53 // original URL. | 53 // original URL. |
54 void OnRedirected(); | 54 void OnRedirected(); |
55 | 55 |
56 // Called by CaptivePortalView when origin URL is loaded without any | 56 // Called by CaptivePortalView when origin URL is loaded without any |
57 // redirections. | 57 // redirections. |
58 void OnOriginalURLLoaded(); | 58 void OnOriginalURLLoaded(); |
59 | 59 |
60 // views::Widget::Observer implementation: | 60 // Overridden from views::WidgetObserver: |
61 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | 61 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
62 | 62 |
63 private: | 63 private: |
64 Delegate* delegate_; | 64 Delegate* delegate_; |
65 views::Widget* widget_; | 65 views::Widget* widget_; |
66 scoped_ptr<CaptivePortalView> captive_portal_view_; | 66 scoped_ptr<CaptivePortalView> captive_portal_view_; |
67 gfx::NativeWindow parent_; | 67 gfx::NativeWindow parent_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(CaptivePortalWindowProxy); | 69 DISALLOW_COPY_AND_ASSIGN(CaptivePortalWindowProxy); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace chromeos | 72 } // namespace chromeos |
73 | 73 |
74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_CAPTIVE_PORTAL_WINDOW_PROXY_H_ |
OLD | NEW |