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 #include "chrome/browser/chromeos/login/screen_locker_webui.h" | 5 #include "chrome/browser/chromeos/login/screen_locker_webui.h" |
6 | 6 |
7 #include <X11/extensions/XTest.h> | 7 #include <X11/extensions/XTest.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 DISALLOW_COPY_AND_ASSIGN(InputEventObserver); | 130 DISALLOW_COPY_AND_ASSIGN(InputEventObserver); |
131 }; | 131 }; |
132 | 132 |
133 // ScreenLockWebUI creates components necessary to authenticate a user to | 133 // ScreenLockWebUI creates components necessary to authenticate a user to |
134 // unlock the screen. | 134 // unlock the screen. |
135 class ScreenLockWebUI : public WebUILoginView { | 135 class ScreenLockWebUI : public WebUILoginView { |
136 public: | 136 public: |
137 explicit ScreenLockWebUI(ScreenLocker* screen_locker); | 137 explicit ScreenLockWebUI(ScreenLocker* screen_locker); |
138 virtual ~ScreenLockWebUI(); | 138 virtual ~ScreenLockWebUI(); |
139 | 139 |
140 // WebUILoginView overrides: | 140 // Initializes ScreenLockWebUI. |
141 virtual void Init() OVERRIDE; | 141 void InitView(); |
142 | 142 |
143 // Clears and sets the focus to the password field. | 143 // Clears and sets the focus to the password field. |
144 void ClearAndSetFocusToPassword(); | 144 void ClearAndSetFocusToPassword(); |
145 | 145 |
146 // Enable/Disable signout button. | 146 // Enable/Disable signout button. |
147 void SetSignoutEnabled(bool enabled); | 147 void SetSignoutEnabled(bool enabled); |
148 | 148 |
149 // Display error message. | 149 // Display error message. |
150 void DisplayErrorMessage(string16 message); | 150 void DisplayErrorMessage(string16 message); |
151 | 151 |
152 void SubmitPassword(); | 152 void SubmitPassword(); |
153 | 153 |
154 // Overridden from views::Views: | 154 // Overridden from views::Views: |
155 virtual bool AcceleratorPressed( | 155 virtual bool AcceleratorPressed( |
156 const views::Accelerator& accelerator) OVERRIDE; | 156 const views::Accelerator& accelerator) OVERRIDE; |
157 virtual void HandleKeyboardEvent( | 157 virtual void HandleKeyboardEvent( |
158 const NativeWebKeyboardEvent& event) OVERRIDE; | 158 const NativeWebKeyboardEvent& event) OVERRIDE; |
159 | 159 |
160 protected: | |
161 // WebUILoginView overrides: | |
162 virtual views::Widget* GetLoginWindow() OVERRIDE; | |
163 | |
164 private: | 160 private: |
165 friend class test::ScreenLockerTester; | 161 friend class test::ScreenLockerTester; |
166 | 162 |
167 // ScreenLocker is owned by itself. | 163 // ScreenLocker is owned by itself. |
168 ScreenLocker* screen_locker_; | 164 ScreenLocker* screen_locker_; |
169 | 165 |
170 std::string password_; | 166 std::string password_; |
171 | 167 |
172 DISALLOW_COPY_AND_ASSIGN(ScreenLockWebUI); | 168 DISALLOW_COPY_AND_ASSIGN(ScreenLockWebUI); |
173 }; | 169 }; |
(...skipping 23 matching lines...) Expand all Loading... |
197 lock_window_->Init(params); | 193 lock_window_->Init(params); |
198 gtk_widget_modify_bg( | 194 gtk_widget_modify_bg( |
199 lock_window_->GetNativeView(), GTK_STATE_NORMAL, &kGdkBlack); | 195 lock_window_->GetNativeView(), GTK_STATE_NORMAL, &kGdkBlack); |
200 | 196 |
201 g_signal_connect(lock_window_->GetNativeView(), "client-event", | 197 g_signal_connect(lock_window_->GetNativeView(), "client-event", |
202 G_CALLBACK(OnClientEventThunk), this); | 198 G_CALLBACK(OnClientEventThunk), this); |
203 | 199 |
204 // GTK does not like zero width/height. | 200 // GTK does not like zero width/height. |
205 if (!unlock_on_input) { | 201 if (!unlock_on_input) { |
206 screen_lock_webui_ = new ScreenLockWebUI(screen_locker_); | 202 screen_lock_webui_ = new ScreenLockWebUI(screen_locker_); |
207 screen_lock_webui_->Init(); | 203 screen_lock_webui_->InitView(); |
208 screen_lock_webui_->SetEnabled(false); | 204 screen_lock_webui_->SetEnabled(false); |
209 } else { | 205 } else { |
210 input_event_observer_.reset(new InputEventObserver(screen_locker_)); | 206 input_event_observer_.reset(new InputEventObserver(screen_locker_)); |
211 MessageLoopForUI::current()->AddObserver(input_event_observer_.get()); | 207 MessageLoopForUI::current()->AddObserver(input_event_observer_.get()); |
212 } | 208 } |
213 | 209 |
214 DCHECK(GTK_WIDGET_REALIZED(lock_window_->GetNativeView())); | 210 DCHECK(GTK_WIDGET_REALIZED(lock_window_->GetNativeView())); |
215 WmIpc::instance()->SetWindowType( | 211 WmIpc::instance()->SetWindowType( |
216 lock_window_->GetNativeView(), | 212 lock_window_->GetNativeView(), |
217 WM_IPC_WINDOW_CHROME_SCREEN_LOCKER, | 213 WM_IPC_WINDOW_CHROME_SCREEN_LOCKER, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // ScreenLockWebUI implementation. | 288 // ScreenLockWebUI implementation. |
293 | 289 |
294 ScreenLockWebUI::ScreenLockWebUI(ScreenLocker* screen_locker) | 290 ScreenLockWebUI::ScreenLockWebUI(ScreenLocker* screen_locker) |
295 : screen_locker_(screen_locker) { | 291 : screen_locker_(screen_locker) { |
296 DCHECK(screen_locker_); | 292 DCHECK(screen_locker_); |
297 } | 293 } |
298 | 294 |
299 ScreenLockWebUI::~ScreenLockWebUI() { | 295 ScreenLockWebUI::~ScreenLockWebUI() { |
300 } | 296 } |
301 | 297 |
302 void ScreenLockWebUI::Init() { | 298 void ScreenLockWebUI::InitView() { |
303 WebUILoginView::Init(); | 299 DCHECK(screen_locker_webui_); |
| 300 Init(screen_locker_webui_->lock_window_); |
304 LoadURL(GURL(chrome::kChromeUILockScreenURL)); | 301 LoadURL(GURL(chrome::kChromeUILockScreenURL)); |
305 } | 302 } |
306 | 303 |
307 void ScreenLockWebUI::ClearAndSetFocusToPassword() { | 304 void ScreenLockWebUI::ClearAndSetFocusToPassword() { |
308 // TODO(flackr): Send a javascript message to clear and focus the password | 305 // TODO(flackr): Send a javascript message to clear and focus the password |
309 // field. | 306 // field. |
310 NOTIMPLEMENTED(); | 307 NOTIMPLEMENTED(); |
311 } | 308 } |
312 | 309 |
313 void ScreenLockWebUI::SetSignoutEnabled(bool enabled) { | 310 void ScreenLockWebUI::SetSignoutEnabled(bool enabled) { |
(...skipping 24 matching lines...) Expand all Loading... |
338 } | 335 } |
339 | 336 |
340 void ScreenLockWebUI::HandleKeyboardEvent( | 337 void ScreenLockWebUI::HandleKeyboardEvent( |
341 const NativeWebKeyboardEvent& event) { | 338 const NativeWebKeyboardEvent& event) { |
342 // Override WebUILoginView::HandleKeyboardEvent to prevent call to WebUI | 339 // Override WebUILoginView::HandleKeyboardEvent to prevent call to WebUI |
343 // cr.ui.Oobe functions. | 340 // cr.ui.Oobe functions. |
344 // TODO(flackr): This might be able to be removed once merging with the login | 341 // TODO(flackr): This might be able to be removed once merging with the login |
345 // screen WebUI is complete. | 342 // screen WebUI is complete. |
346 } | 343 } |
347 | 344 |
348 views::Widget* ScreenLockWebUI::GetLoginWindow() { | |
349 DCHECK(screen_locker_webui_); | |
350 return screen_locker_webui_->lock_window_; | |
351 } | |
352 | |
353 } // namespace chromeos | 345 } // namespace chromeos |
OLD | NEW |