OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/chromeos/login/lock_window.h" | |
12 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" | |
13 #include "ui/views/widget/native_widget_gtk.h" | |
14 | |
15 namespace chromeos { | |
16 | |
17 namespace test { | |
18 class WebUIScreenLockerTester; | |
19 } | |
20 | |
21 // A ScreenLock window that covers entire screen to keep the keyboard | |
22 // focus/events inside the grab widget. | |
23 class LockWindowGtk : public views::NativeWidgetGtk, | |
24 public LockWindow { | |
25 public: | |
26 // LockWindow implementation: | |
27 virtual void Grab(DOMView* dom_view) OVERRIDE; | |
28 virtual views::Widget* GetWidget() OVERRIDE; | |
29 | |
30 protected: | |
31 // NativeWidgetGtk overrides: | |
32 virtual gboolean OnButtonPress(GtkWidget* widget, | |
33 GdkEventButton* event) OVERRIDE; | |
34 virtual void OnDestroy(GtkWidget* object) OVERRIDE; | |
35 virtual void ClearNativeFocus() OVERRIDE; | |
36 virtual void HandleGtkGrabBroke() OVERRIDE; | |
37 | |
38 private: | |
39 friend class test::WebUIScreenLockerTester; | |
40 friend class LockWindow; | |
41 | |
42 LockWindowGtk(); | |
43 virtual ~LockWindowGtk(); | |
44 | |
45 // Initialize the lock window. | |
46 void Init(); | |
47 | |
48 // Called when the window manager is ready to handle locked state. | |
49 void OnWindowManagerReady(); | |
50 | |
51 // Called when the all inputs are grabbed. | |
52 void OnGrabInputs(); | |
53 | |
54 // Clear current GTK grab. | |
55 void ClearGtkGrab(); | |
56 | |
57 // Try to grab all inputs. It initiates another try if it fails to | |
58 // grab and the retry count is within a limit, or fails with CHECK. | |
59 void TryGrabAllInputs(); | |
60 | |
61 // This method tries to steal pointer/keyboard grab from other | |
62 // client by sending events that will hopefully close menus or windows | |
63 // that have the grab. | |
64 void TryUngrabOtherClients(); | |
65 | |
66 // Event handler for client-event. | |
67 CHROMEGTK_CALLBACK_1(LockWindowGtk, void, OnClientEvent, GdkEventClient*) | |
68 | |
69 // The screen locker window. | |
70 views::Widget* lock_window_; | |
71 | |
72 // The widget to grab inputs on. This is initialized by Grab to be the | |
73 // RenderHostView displaying the WebUI. | |
74 GtkWidget* grab_widget_; | |
75 | |
76 // True if the screen locker's window has been drawn. | |
77 bool drawn_; | |
78 | |
79 // True if both mouse input and keyboard input are grabbed. | |
80 bool input_grabbed_; | |
81 | |
82 base::WeakPtrFactory<LockWindowGtk> weak_factory_; | |
83 | |
84 // The number times the widget tried to grab all focus. | |
85 int grab_failure_count_; | |
86 | |
87 // Status of keyboard and mouse grab. | |
88 GdkGrabStatus kbd_grab_status_; | |
89 GdkGrabStatus mouse_grab_status_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(LockWindowGtk); | |
92 }; | |
93 | |
94 } // namespace chromeos | |
95 | |
96 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
OLD | NEW |