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

Side by Side Diff: chrome/browser/chromeos/login/screen_locker.cc

Issue 6823055: Consolidate OnKeyEvent and InputMethod code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore IME call in accelerator_handler_touch.cc. Created 9 years, 8 months 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_input_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "chrome/browser/chromeos/login/screen_locker.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 public NotificationObserver { 75 public NotificationObserver {
76 public: 76 public:
77 ScreenLockObserver() { 77 ScreenLockObserver() {
78 registrar_.Add(this, NotificationType::LOGIN_USER_CHANGED, 78 registrar_.Add(this, NotificationType::LOGIN_USER_CHANGED,
79 NotificationService::AllSources()); 79 NotificationService::AllSources());
80 } 80 }
81 81
82 // NotificationObserver overrides: 82 // NotificationObserver overrides:
83 virtual void Observe(NotificationType type, 83 virtual void Observe(NotificationType type,
84 const NotificationSource& source, 84 const NotificationSource& source,
85 const NotificationDetails& details) { 85 const NotificationDetails& details) OVERRIDE {
86 if (type == NotificationType::LOGIN_USER_CHANGED) { 86 if (type == NotificationType::LOGIN_USER_CHANGED) {
87 // Register Screen Lock after login screen to make sure 87 // Register Screen Lock after login screen to make sure
88 // we don't show the screen lock on top of the login screen by accident. 88 // we don't show the screen lock on top of the login screen by accident.
89 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) 89 if (chromeos::CrosLibrary::Get()->EnsureLoaded())
90 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); 90 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
91 } 91 }
92 } 92 }
93 93
94 virtual void LockScreen(chromeos::ScreenLockLibrary* obj) { 94 virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
95 VLOG(1) << "In: ScreenLockObserver::LockScreen"; 95 VLOG(1) << "In: ScreenLockObserver::LockScreen";
96 SetupInputMethodsForScreenLocker(); 96 SetupInputMethodsForScreenLocker();
97 chromeos::ScreenLocker::Show(); 97 chromeos::ScreenLocker::Show();
98 } 98 }
99 99
100 virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) { 100 virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
101 RestoreInputMethods(); 101 RestoreInputMethods();
102 chromeos::ScreenLocker::Hide(); 102 chromeos::ScreenLocker::Hide();
103 } 103 }
104 104
105 virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) { 105 virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) OVERRIDE {
106 chromeos::ScreenLocker::UnlockScreenFailed(); 106 chromeos::ScreenLocker::UnlockScreenFailed();
107 } 107 }
108 108
109 private: 109 private:
110 // Temporarily deactivates all input methods (e.g. Chinese, Japanese, Arabic) 110 // Temporarily deactivates all input methods (e.g. Chinese, Japanese, Arabic)
111 // since they are not necessary to input a login password. Users are still 111 // since they are not necessary to input a login password. Users are still
112 // able to use/switch active keyboard layouts (e.g. US qwerty, US dvorak, 112 // able to use/switch active keyboard layouts (e.g. US qwerty, US dvorak,
113 // French). 113 // French).
114 void SetupInputMethodsForScreenLocker() { 114 void SetupInputMethodsForScreenLocker() {
115 if (chromeos::CrosLibrary::Get()->EnsureLoaded() && 115 if (chromeos::CrosLibrary::Get()->EnsureLoaded() &&
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 class LockWindow : public views::WidgetGtk { 199 class LockWindow : public views::WidgetGtk {
200 public: 200 public:
201 LockWindow() 201 LockWindow()
202 : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), 202 : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW),
203 toplevel_focus_widget_(NULL) { 203 toplevel_focus_widget_(NULL) {
204 EnableDoubleBuffer(true); 204 EnableDoubleBuffer(true);
205 } 205 }
206 206
207 // GTK propagates key events from parents to children. 207 // GTK propagates key events from parents to children.
208 // Make sure LockWindow will never handle key events. 208 // Make sure LockWindow will never handle key events.
209 virtual gboolean OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { 209 virtual gboolean OnEventKey(GtkWidget* widget, GdkEventKey* event) OVERRIDE {
210 // Don't handle key event in the lock window. 210 // Don't handle key event in the lock window.
211 return false; 211 return false;
212 } 212 }
213 213
214 virtual void OnDestroy(GtkWidget* object) { 214 virtual void OnDestroy(GtkWidget* object) OVERRIDE {
215 VLOG(1) << "OnDestroy: LockWindow destroyed"; 215 VLOG(1) << "OnDestroy: LockWindow destroyed";
216 views::WidgetGtk::OnDestroy(object); 216 views::WidgetGtk::OnDestroy(object);
217 } 217 }
218 218
219 virtual void ClearNativeFocus() { 219 virtual void ClearNativeFocus() OVERRIDE {
220 DCHECK(toplevel_focus_widget_); 220 DCHECK(toplevel_focus_widget_);
221 gtk_widget_grab_focus(toplevel_focus_widget_); 221 gtk_widget_grab_focus(toplevel_focus_widget_);
222 } 222 }
223 223
224 // Sets the widget to move the focus to when clearning the native 224 // Sets the widget to move the focus to when clearning the native
225 // widget's focus. 225 // widget's focus.
226 void set_toplevel_focus_widget(GtkWidget* widget) { 226 void set_toplevel_focus_widget(GtkWidget* widget) {
227 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); 227 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
228 toplevel_focus_widget_ = widget; 228 toplevel_focus_widget_ = widget;
229 } 229 }
(...skipping 17 matching lines...) Expand all
247 public: 247 public:
248 explicit GrabWidgetRootView(chromeos::ScreenLockView* screen_lock_view) 248 explicit GrabWidgetRootView(chromeos::ScreenLockView* screen_lock_view)
249 : screen_lock_view_(screen_lock_view), 249 : screen_lock_view_(screen_lock_view),
250 shutdown_button_(new chromeos::ShutdownButton()) { 250 shutdown_button_(new chromeos::ShutdownButton()) {
251 shutdown_button_->Init(); 251 shutdown_button_->Init();
252 AddChildView(screen_lock_view_); 252 AddChildView(screen_lock_view_);
253 AddChildView(shutdown_button_); 253 AddChildView(shutdown_button_);
254 } 254 }
255 255
256 // views::View implementation. 256 // views::View implementation.
257 virtual void Layout() { 257 virtual void Layout() OVERRIDE {
258 gfx::Size size = screen_lock_view_->GetPreferredSize(); 258 gfx::Size size = screen_lock_view_->GetPreferredSize();
259 screen_lock_view_->SetBounds(0, 0, size.width(), size.height()); 259 screen_lock_view_->SetBounds(0, 0, size.width(), size.height());
260 shutdown_button_->LayoutIn(this); 260 shutdown_button_->LayoutIn(this);
261 } 261 }
262 262
263 // ScreenLocker::ScreenLockViewContainer implementation: 263 // ScreenLocker::ScreenLockViewContainer implementation:
264 void SetScreenLockView(views::View* screen_lock_view) { 264 void SetScreenLockView(views::View* screen_lock_view) OVERRIDE {
265 if (screen_lock_view_) { 265 if (screen_lock_view_) {
266 RemoveChildView(screen_lock_view_); 266 RemoveChildView(screen_lock_view_);
267 } 267 }
268 screen_lock_view_ = screen_lock_view; 268 screen_lock_view_ = screen_lock_view;
269 if (screen_lock_view_) { 269 if (screen_lock_view_) {
270 AddChildViewAt(screen_lock_view_, 0); 270 AddChildViewAt(screen_lock_view_, 0);
271 } 271 }
272 Layout(); 272 Layout();
273 } 273 }
274 274
(...skipping 12 matching lines...) Expand all
287 : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD), 287 : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD),
288 screen_locker_(screen_locker), 288 screen_locker_(screen_locker),
289 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 289 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
290 grab_failure_count_(0), 290 grab_failure_count_(0),
291 kbd_grab_status_(GDK_GRAB_INVALID_TIME), 291 kbd_grab_status_(GDK_GRAB_INVALID_TIME),
292 mouse_grab_status_(GDK_GRAB_INVALID_TIME), 292 mouse_grab_status_(GDK_GRAB_INVALID_TIME),
293 signout_link_(NULL), 293 signout_link_(NULL),
294 shutdown_(NULL) { 294 shutdown_(NULL) {
295 } 295 }
296 296
297 virtual void Show() { 297 virtual void Show() OVERRIDE {
298 views::WidgetGtk::Show(); 298 views::WidgetGtk::Show();
299 signout_link_ = 299 signout_link_ =
300 screen_locker_->GetViewByID(VIEW_ID_SCREEN_LOCKER_SIGNOUT_LINK); 300 screen_locker_->GetViewByID(VIEW_ID_SCREEN_LOCKER_SIGNOUT_LINK);
301 shutdown_ = screen_locker_->GetViewByID(VIEW_ID_SCREEN_LOCKER_SHUTDOWN); 301 shutdown_ = screen_locker_->GetViewByID(VIEW_ID_SCREEN_LOCKER_SHUTDOWN);
302 // These can be null in guest mode. 302 // These can be null in guest mode.
303 } 303 }
304 304
305 void ClearGtkGrab() { 305 void ClearGtkGrab() {
306 GtkWidget* current_grab_window; 306 GtkWidget* current_grab_window;
307 // Grab gtk input first so that the menu holding gtk grab will 307 // Grab gtk input first so that the menu holding gtk grab will
308 // close itself. 308 // close itself.
309 gtk_grab_add(window_contents()); 309 gtk_grab_add(window_contents());
310 310
311 // Make sure there is no gtk grab widget so that gtk simply propagates 311 // Make sure there is no gtk grab widget so that gtk simply propagates
312 // an event. This is necessary to allow message bubble and password 312 // an event. This is necessary to allow message bubble and password
313 // field, button to process events simultaneously. GTK 313 // field, button to process events simultaneously. GTK
314 // maintains grab widgets in a linked-list, so we need to remove 314 // maintains grab widgets in a linked-list, so we need to remove
315 // until it's empty. 315 // until it's empty.
316 while ((current_grab_window = gtk_grab_get_current()) != NULL) 316 while ((current_grab_window = gtk_grab_get_current()) != NULL)
317 gtk_grab_remove(current_grab_window); 317 gtk_grab_remove(current_grab_window);
318 } 318 }
319 319
320 virtual gboolean OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { 320 virtual gboolean OnEventKey(GtkWidget* widget, GdkEventKey* event) OVERRIDE {
321 views::KeyEvent key_event(reinterpret_cast<GdkEvent*>(event)); 321 views::KeyEvent key_event(reinterpret_cast<GdkEvent*>(event));
322 // This is a hack to workaround the issue crosbug.com/10655 due to 322 // This is a hack to workaround the issue crosbug.com/10655 due to
323 // the limitation that a focus manager cannot handle views in 323 // the limitation that a focus manager cannot handle views in
324 // TYPE_CHILD WidgetGtk correctly. 324 // TYPE_CHILD WidgetGtk correctly.
325 if (signout_link_ && 325 if (signout_link_ &&
326 event->type == GDK_KEY_PRESS && 326 event->type == GDK_KEY_PRESS &&
327 (event->keyval == GDK_Tab || 327 (event->keyval == GDK_Tab ||
328 event->keyval == GDK_ISO_Left_Tab || 328 event->keyval == GDK_ISO_Left_Tab ||
329 event->keyval == GDK_KP_Tab)) { 329 event->keyval == GDK_KP_Tab)) {
330 DCHECK(shutdown_); 330 DCHECK(shutdown_);
331 bool reverse = event->state & GDK_SHIFT_MASK; 331 bool reverse = event->state & GDK_SHIFT_MASK;
332 if (reverse && signout_link_->HasFocus()) { 332 if (reverse && signout_link_->HasFocus()) {
333 shutdown_->RequestFocus(); 333 shutdown_->RequestFocus();
334 return true; 334 return true;
335 } 335 }
336 if (!reverse && shutdown_->HasFocus()) { 336 if (!reverse && shutdown_->HasFocus()) {
337 signout_link_->RequestFocus(); 337 signout_link_->RequestFocus();
338 return true; 338 return true;
339 } 339 }
340 } 340 }
341 return views::WidgetGtk::OnKeyEvent(widget, event); 341 return views::WidgetGtk::OnEventKey(widget, event);
342 } 342 }
343 343
344 virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { 344 virtual gboolean OnButtonPress(GtkWidget* widget,
345 GdkEventButton* event) OVERRIDE {
345 WidgetGtk::OnButtonPress(widget, event); 346 WidgetGtk::OnButtonPress(widget, event);
346 // Never propagate event to parent. 347 // Never propagate event to parent.
347 return true; 348 return true;
348 } 349 }
349 350
350 // Try to grab all inputs. It initiates another try if it fails to 351 // Try to grab all inputs. It initiates another try if it fails to
351 // grab and the retry count is within a limit, or fails with CHECK. 352 // grab and the retry count is within a limit, or fails with CHECK.
352 void TryGrabAllInputs(); 353 void TryGrabAllInputs();
353 354
354 // This method tries to steal pointer/keyboard grab from other 355 // This method tries to steal pointer/keyboard grab from other
355 // client by sending events that will hopefully close menus or windows 356 // client by sending events that will hopefully close menus or windows
356 // that have the grab. 357 // that have the grab.
357 void TryUngrabOtherClients(); 358 void TryUngrabOtherClients();
358 359
359 private: 360 private:
360 virtual void HandleGtkGrabBroke() { 361 virtual void HandleGtkGrabBroke() OVERRIDE {
361 // Input should never be stolen from ScreenLocker once it's 362 // Input should never be stolen from ScreenLocker once it's
362 // grabbed. If this happens, it's a bug and has to be fixed. We 363 // grabbed. If this happens, it's a bug and has to be fixed. We
363 // let chrome crash to get a crash report and dump, and 364 // let chrome crash to get a crash report and dump, and
364 // SessionManager will terminate the session to logout. 365 // SessionManager will terminate the session to logout.
365 CHECK_NE(GDK_GRAB_SUCCESS, kbd_grab_status_); 366 CHECK_NE(GDK_GRAB_SUCCESS, kbd_grab_status_);
366 CHECK_NE(GDK_GRAB_SUCCESS, mouse_grab_status_); 367 CHECK_NE(GDK_GRAB_SUCCESS, mouse_grab_status_);
367 } 368 }
368 369
369 chromeos::ScreenLocker* screen_locker_; 370 chromeos::ScreenLocker* screen_locker_;
370 ScopedRunnableMethodFactory<GrabWidget> task_factory_; 371 ScopedRunnableMethodFactory<GrabWidget> task_factory_;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 class ScreenLockerBackgroundView 477 class ScreenLockerBackgroundView
477 : public chromeos::BackgroundView, 478 : public chromeos::BackgroundView,
478 public chromeos::ScreenLocker::ScreenLockViewContainer { 479 public chromeos::ScreenLocker::ScreenLockViewContainer {
479 public: 480 public:
480 ScreenLockerBackgroundView(views::WidgetGtk* lock_widget, 481 ScreenLockerBackgroundView(views::WidgetGtk* lock_widget,
481 views::View* screen_lock_view) 482 views::View* screen_lock_view)
482 : lock_widget_(lock_widget), 483 : lock_widget_(lock_widget),
483 screen_lock_view_(screen_lock_view) { 484 screen_lock_view_(screen_lock_view) {
484 } 485 }
485 486
486 virtual ScreenMode GetScreenMode() const { 487 virtual ScreenMode GetScreenMode() const OVERRIDE {
487 return kScreenLockerMode; 488 return kScreenLockerMode;
488 } 489 }
489 490
490 virtual void Layout() { 491 virtual void Layout() OVERRIDE {
491 chromeos::BackgroundView::Layout(); 492 chromeos::BackgroundView::Layout();
492 gfx::Rect screen = bounds(); 493 gfx::Rect screen = bounds();
493 if (screen_lock_view_) { 494 if (screen_lock_view_) {
494 gfx::Size size = screen_lock_view_->GetPreferredSize(); 495 gfx::Size size = screen_lock_view_->GetPreferredSize();
495 gfx::Point origin((screen.width() - size.width()) / 2, 496 gfx::Point origin((screen.width() - size.width()) / 2,
496 (screen.height() - size.height()) / 2); 497 (screen.height() - size.height()) / 2);
497 gfx::Size widget_size(screen.size()); 498 gfx::Size widget_size(screen.size());
498 widget_size.Enlarge(-origin.x(), -origin.y()); 499 widget_size.Enlarge(-origin.x(), -origin.y());
499 lock_widget_->SetBounds(gfx::Rect(origin, widget_size)); 500 lock_widget_->SetBounds(gfx::Rect(origin, widget_size));
500 } else { 501 } else {
501 // No password entry. Move the lock widget to off screen. 502 // No password entry. Move the lock widget to off screen.
502 lock_widget_->SetBounds(gfx::Rect(-100, -100, 1, 1)); 503 lock_widget_->SetBounds(gfx::Rect(-100, -100, 1, 1));
503 } 504 }
504 } 505 }
505 506
506 // ScreenLocker::ScreenLockViewContainer implementation: 507 // ScreenLocker::ScreenLockViewContainer implementation:
507 void SetScreenLockView(views::View* screen_lock_view) { 508 virtual void SetScreenLockView(views::View* screen_lock_view) OVERRIDE {
508 screen_lock_view_ = screen_lock_view; 509 screen_lock_view_ = screen_lock_view;
509 Layout(); 510 Layout();
510 } 511 }
511 512
512 private: 513 private:
513 views::WidgetGtk* lock_widget_; 514 views::WidgetGtk* lock_widget_;
514 515
515 views::View* screen_lock_view_; 516 views::View* screen_lock_view_;
516 517
517 DISALLOW_COPY_AND_ASSIGN(ScreenLockerBackgroundView); 518 DISALLOW_COPY_AND_ASSIGN(ScreenLockerBackgroundView);
(...skipping 11 matching lines...) Expand all
529 class MouseEventRelay : public MessageLoopForUI::Observer { 530 class MouseEventRelay : public MessageLoopForUI::Observer {
530 public: 531 public:
531 MouseEventRelay(GdkWindow* src, GdkWindow* dest) 532 MouseEventRelay(GdkWindow* src, GdkWindow* dest)
532 : src_(src), 533 : src_(src),
533 dest_(dest), 534 dest_(dest),
534 initialized_(false) { 535 initialized_(false) {
535 DCHECK(src_); 536 DCHECK(src_);
536 DCHECK(dest_); 537 DCHECK(dest_);
537 } 538 }
538 539
539 virtual void WillProcessEvent(GdkEvent* event) {} 540 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
540 541
541 virtual void DidProcessEvent(GdkEvent* event) { 542 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
542 if (event->any.window != src_) 543 if (event->any.window != src_)
543 return; 544 return;
544 if (!initialized_) { 545 if (!initialized_) {
545 gint src_x, src_y, dest_x, dest_y, width, height, depth; 546 gint src_x, src_y, dest_x, dest_y, width, height, depth;
546 gdk_window_get_geometry(dest_, &dest_x, &dest_y, &width, &height, &depth); 547 gdk_window_get_geometry(dest_, &dest_x, &dest_y, &width, &height, &depth);
547 // wait to compute offset until the info bubble widget's location 548 // wait to compute offset until the info bubble widget's location
548 // is available. 549 // is available.
549 if (dest_x < 0 || dest_y < 0) 550 if (dest_x < 0 || dest_y < 0)
550 return; 551 return;
551 gdk_window_get_geometry(src_, &src_x, &src_y, &width, &height, &depth); 552 gdk_window_get_geometry(src_, &src_x, &src_y, &width, &height, &depth);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // A event observer used to unlock the screen upon user's action 589 // A event observer used to unlock the screen upon user's action
589 // without asking password. Used in BWSI and auto login mode. 590 // without asking password. Used in BWSI and auto login mode.
590 // TODO(oshima): consolidate InputEventObserver and LockerInputEventObserver. 591 // TODO(oshima): consolidate InputEventObserver and LockerInputEventObserver.
591 class InputEventObserver : public MessageLoopForUI::Observer { 592 class InputEventObserver : public MessageLoopForUI::Observer {
592 public: 593 public:
593 explicit InputEventObserver(ScreenLocker* screen_locker) 594 explicit InputEventObserver(ScreenLocker* screen_locker)
594 : screen_locker_(screen_locker), 595 : screen_locker_(screen_locker),
595 activated_(false) { 596 activated_(false) {
596 } 597 }
597 598
598 virtual void WillProcessEvent(GdkEvent* event) { 599 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
599 if ((event->type == GDK_KEY_PRESS || 600 if ((event->type == GDK_KEY_PRESS ||
600 event->type == GDK_BUTTON_PRESS || 601 event->type == GDK_BUTTON_PRESS ||
601 event->type == GDK_MOTION_NOTIFY) && 602 event->type == GDK_MOTION_NOTIFY) &&
602 !activated_) { 603 !activated_) {
603 activated_ = true; 604 activated_ = true;
604 std::string not_used_string; 605 std::string not_used_string;
605 GaiaAuthConsumer::ClientLoginResult not_used; 606 GaiaAuthConsumer::ClientLoginResult not_used;
606 screen_locker_->OnLoginSuccess(not_used_string, 607 screen_locker_->OnLoginSuccess(not_used_string,
607 not_used_string, 608 not_used_string,
608 not_used, 609 not_used,
609 false); 610 false);
610 } 611 }
611 } 612 }
612 613
613 virtual void DidProcessEvent(GdkEvent* event) { 614 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
614 } 615 }
615 616
616 private: 617 private:
617 chromeos::ScreenLocker* screen_locker_; 618 chromeos::ScreenLocker* screen_locker_;
618 619
619 bool activated_; 620 bool activated_;
620 621
621 DISALLOW_COPY_AND_ASSIGN(InputEventObserver); 622 DISALLOW_COPY_AND_ASSIGN(InputEventObserver);
622 }; 623 };
623 624
624 // A event observer used to show the screen locker upon 625 // A event observer used to show the screen locker upon
625 // user action: mouse or keyboard interactions. 626 // user action: mouse or keyboard interactions.
626 // TODO(oshima): this has to be disabled while authenticating. 627 // TODO(oshima): this has to be disabled while authenticating.
627 class LockerInputEventObserver : public MessageLoopForUI::Observer { 628 class LockerInputEventObserver : public MessageLoopForUI::Observer {
628 public: 629 public:
629 explicit LockerInputEventObserver(ScreenLocker* screen_locker) 630 explicit LockerInputEventObserver(ScreenLocker* screen_locker)
630 : screen_locker_(screen_locker), 631 : screen_locker_(screen_locker),
631 ALLOW_THIS_IN_INITIALIZER_LIST( 632 ALLOW_THIS_IN_INITIALIZER_LIST(
632 timer_(base::TimeDelta::FromSeconds(kScreenSaverIdleTimeout), this, 633 timer_(base::TimeDelta::FromSeconds(kScreenSaverIdleTimeout), this,
633 &LockerInputEventObserver::StartScreenSaver)) { 634 &LockerInputEventObserver::StartScreenSaver)) {
634 } 635 }
635 636
636 virtual void WillProcessEvent(GdkEvent* event) { 637 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
637 if ((event->type == GDK_KEY_PRESS || 638 if ((event->type == GDK_KEY_PRESS ||
638 event->type == GDK_BUTTON_PRESS || 639 event->type == GDK_BUTTON_PRESS ||
639 event->type == GDK_MOTION_NOTIFY)) { 640 event->type == GDK_MOTION_NOTIFY)) {
640 timer_.Reset(); 641 timer_.Reset();
641 screen_locker_->StopScreenSaver(); 642 screen_locker_->StopScreenSaver();
642 } 643 }
643 } 644 }
644 645
645 virtual void DidProcessEvent(GdkEvent* event) { 646 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
646 } 647 }
647 648
648 private: 649 private:
649 void StartScreenSaver() { 650 void StartScreenSaver() {
650 screen_locker_->StartScreenSaver(); 651 screen_locker_->StartScreenSaver();
651 } 652 }
652 653
653 chromeos::ScreenLocker* screen_locker_; 654 chromeos::ScreenLocker* screen_locker_;
654 base::DelayTimer<LockerInputEventObserver> timer_; 655 base::DelayTimer<LockerInputEventObserver> timer_;
655 656
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 1145
1145 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { 1146 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) {
1146 if (!background_view_->IsScreenSaverVisible()) { 1147 if (!background_view_->IsScreenSaverVisible()) {
1147 StartScreenSaver(); 1148 StartScreenSaver();
1148 return true; 1149 return true;
1149 } 1150 }
1150 return false; 1151 return false;
1151 } 1152 }
1152 1153
1153 } // namespace chromeos 1154 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_input_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698