OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEBUI_SCREEN_LOCKER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/chromeos/login/lock_window.h" | |
13 #include "chrome/browser/chromeos/login/login_display.h" | 14 #include "chrome/browser/chromeos/login/login_display.h" |
14 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" | 15 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" |
15 #include "chrome/browser/chromeos/login/webui_login_view.h" | 16 #include "chrome/browser/chromeos/login/webui_login_view.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
19 | 20 |
20 #if defined(TOOLKIT_USES_GTK) | |
21 #include "ui/views/widget/native_widget_gtk.h" | |
22 #endif | |
23 | |
24 namespace chromeos { | 21 namespace chromeos { |
25 | 22 |
26 class ScreenLocker; | 23 class ScreenLocker; |
27 class WebUILoginDisplay; | 24 class WebUILoginDisplay; |
28 | 25 |
29 // This version of ScreenLockerDelegate displays a WebUI lock screen based on | 26 // This version of ScreenLockerDelegate displays a WebUI lock screen based on |
30 // the Oobe account picker screen. | 27 // the Oobe account picker screen. |
31 class WebUIScreenLocker : public WebUILoginView, | 28 class WebUIScreenLocker : public WebUILoginView, |
32 public LoginDisplay::Delegate, | 29 public LoginDisplay::Delegate, |
33 public content::NotificationObserver, | 30 public content::NotificationObserver, |
34 public ScreenLockerDelegate { | 31 public ScreenLockerDelegate, |
32 public LockWindow::Observer { | |
35 public: | 33 public: |
36 explicit WebUIScreenLocker(ScreenLocker* screen_locker); | 34 explicit WebUIScreenLocker(ScreenLocker* screen_locker); |
37 | 35 |
38 // Called when the GTK grab breaks. | |
39 void HandleGtkGrabBroke(); | |
40 | |
41 // ScreenLockerDelegate implementation: | 36 // ScreenLockerDelegate implementation: |
42 virtual void LockScreen(bool unlock_on_input) OVERRIDE; | 37 virtual void LockScreen(bool unlock_on_input) OVERRIDE; |
43 virtual void ScreenLockReady() OVERRIDE; | 38 virtual void ScreenLockReady() OVERRIDE; |
44 virtual void OnAuthenticate() OVERRIDE; | 39 virtual void OnAuthenticate() OVERRIDE; |
45 virtual void SetInputEnabled(bool enabled) OVERRIDE; | 40 virtual void SetInputEnabled(bool enabled) OVERRIDE; |
46 virtual void SetSignoutEnabled(bool enabled) OVERRIDE; | 41 virtual void SetSignoutEnabled(bool enabled) OVERRIDE; |
47 virtual void ShowErrorMessage(const string16& message, | 42 virtual void ShowErrorMessage(const string16& message, |
48 bool sign_out_only) OVERRIDE; | 43 bool sign_out_only) OVERRIDE; |
49 virtual void ShowCaptchaAndErrorMessage(const GURL& captcha_url, | 44 virtual void ShowCaptchaAndErrorMessage(const GURL& captcha_url, |
50 const string16& message) OVERRIDE; | 45 const string16& message) OVERRIDE; |
51 virtual void ClearErrors() OVERRIDE; | 46 virtual void ClearErrors() OVERRIDE; |
52 | 47 |
53 // LoginDisplay::Delegate: implementation | 48 // LoginDisplay::Delegate: implementation |
54 virtual void CreateAccount() OVERRIDE; | 49 virtual void CreateAccount() OVERRIDE; |
55 virtual string16 GetConnectedNetworkName() OVERRIDE; | 50 virtual string16 GetConnectedNetworkName() OVERRIDE; |
56 virtual void FixCaptivePortal() OVERRIDE; | 51 virtual void FixCaptivePortal() OVERRIDE; |
57 virtual void CompleteLogin(const std::string& username, | 52 virtual void CompleteLogin(const std::string& username, |
58 const std::string& password) OVERRIDE; | 53 const std::string& password) OVERRIDE; |
59 virtual void Login(const std::string& username, | 54 virtual void Login(const std::string& username, |
60 const std::string& password) OVERRIDE; | 55 const std::string& password) OVERRIDE; |
61 virtual void LoginAsGuest() OVERRIDE; | 56 virtual void LoginAsGuest() OVERRIDE; |
62 virtual void OnUserSelected(const std::string& username) OVERRIDE; | 57 virtual void OnUserSelected(const std::string& username) OVERRIDE; |
63 virtual void OnStartEnterpriseEnrollment() OVERRIDE; | 58 virtual void OnStartEnterpriseEnrollment() OVERRIDE; |
64 | 59 |
65 // content::NotificationObserver implementation. | 60 // content::NotificationObserver implementation. |
66 virtual void Observe(int type, | 61 virtual void Observe(int type, |
67 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
68 const content::NotificationDetails& details) OVERRIDE; | 63 const content::NotificationDetails& details) OVERRIDE; |
69 | 64 |
65 // LockWindow::Observer implementation. | |
66 virtual void OnLockWindowReady(); | |
oshima
2011/12/01 22:45:35
OVERRIDE;
(note that this is now required and fo
flackr
2011/12/01 23:16:34
Done.
| |
67 | |
68 // Overridden from WebUILoginView. | |
69 virtual void OnTabMainFrameFirstRender() OVERRIDE; | |
70 | |
70 private: | 71 private: |
71 virtual ~WebUIScreenLocker(); | 72 virtual ~WebUIScreenLocker(); |
72 | 73 |
73 // Called when the window manager is ready to handle locked state. | |
74 void OnWindowManagerReady(); | |
75 | |
76 // Called when the all inputs are grabbed. | |
77 void OnGrabInputs(); | |
78 | |
79 // Clear current GTK grab. | |
80 void ClearGtkGrab(); | |
81 | |
82 // Try to grab all inputs. It initiates another try if it fails to | |
83 // grab and the retry count is within a limit, or fails with CHECK. | |
84 void TryGrabAllInputs(); | |
85 | |
86 // This method tries to steal pointer/keyboard grab from other | |
87 // client by sending events that will hopefully close menus or windows | |
88 // that have the grab. | |
89 void TryUngrabOtherClients(); | |
90 | |
91 // Event handler for client-event. | |
92 CHROMEGTK_CALLBACK_1(WebUIScreenLocker, void, OnClientEvent, GdkEventClient*) | |
93 | |
94 // The screen locker window. | 74 // The screen locker window. |
95 views::Widget* lock_window_; | 75 views::Widget* lock_window_; |
96 | 76 |
97 // Login UI implementation instance. | 77 // Login UI implementation instance. |
98 scoped_ptr<WebUILoginDisplay> login_display_; | 78 scoped_ptr<WebUILoginDisplay> login_display_; |
99 | 79 |
100 // Used for user image changed notifications. | 80 // Used for user image changed notifications. |
101 content::NotificationRegistrar registrar_; | 81 content::NotificationRegistrar registrar_; |
102 | 82 |
103 // True if the screen locker's window has been drawn. | 83 // Tracks when the lock window is displayed and ready. |
104 bool drawn_; | 84 bool lock_ready_; |
105 | 85 |
106 // True if both mouse input and keyboard input are grabbed. | 86 // Tracks when the WebUI finishes loading. |
107 bool input_grabbed_; | 87 bool webui_ready_; |
108 | |
109 base::WeakPtrFactory<WebUIScreenLocker> weak_factory_; | |
110 | |
111 // The number times the widget tried to grab all focus. | |
112 int grab_failure_count_; | |
113 | |
114 // Status of keyboard and mouse grab. | |
115 GdkGrabStatus kbd_grab_status_; | |
116 GdkGrabStatus mouse_grab_status_; | |
117 | 88 |
118 DISALLOW_COPY_AND_ASSIGN(WebUIScreenLocker); | 89 DISALLOW_COPY_AND_ASSIGN(WebUIScreenLocker); |
119 }; | 90 }; |
120 | 91 |
121 } // namespace chromeos | 92 } // namespace chromeos |
122 | 93 |
123 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ | 94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ |
OLD | NEW |