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 UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ | 5 #ifndef UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ |
6 #define UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ | 6 #define UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/views/views_export.h" | 11 #include "ui/views/views_export.h" |
12 | 12 |
| 13 namespace base { |
13 template <typename T> struct DefaultSingletonTraits; | 14 template <typename T> struct DefaultSingletonTraits; |
| 15 } |
14 | 16 |
15 namespace views { | 17 namespace views { |
16 | 18 |
17 // This interface should be implemented by classes that want to be notified when | 19 // This interface should be implemented by classes that want to be notified when |
18 // the native focus is about to change. Listeners implementing this interface | 20 // the native focus is about to change. Listeners implementing this interface |
19 // will be invoked for all native focus changes across the entire Chrome | 21 // will be invoked for all native focus changes across the entire Chrome |
20 // application. FocusChangeListeners are only called for changes within the | 22 // application. FocusChangeListeners are only called for changes within the |
21 // children of a single top-level native-view. | 23 // children of a single top-level native-view. |
22 class WidgetFocusChangeListener { | 24 class WidgetFocusChangeListener { |
23 public: | 25 public: |
(...skipping 17 matching lines...) Expand all Loading... |
41 // null when focus is lost. | 43 // null when focus is lost. |
42 void OnNativeFocusChanged(gfx::NativeView focused_now); | 44 void OnNativeFocusChanged(gfx::NativeView focused_now); |
43 | 45 |
44 // Enable/Disable notification of registered listeners during calls | 46 // Enable/Disable notification of registered listeners during calls |
45 // to OnNativeFocusChanged. Used to prevent unwanted focus changes from | 47 // to OnNativeFocusChanged. Used to prevent unwanted focus changes from |
46 // propagating notifications. | 48 // propagating notifications. |
47 void EnableNotifications() { enabled_ = true; } | 49 void EnableNotifications() { enabled_ = true; } |
48 void DisableNotifications() { enabled_ = false; } | 50 void DisableNotifications() { enabled_ = false; } |
49 | 51 |
50 private: | 52 private: |
51 friend struct DefaultSingletonTraits<WidgetFocusManager>; | 53 friend struct base::DefaultSingletonTraits<WidgetFocusManager>; |
52 | 54 |
53 WidgetFocusManager(); | 55 WidgetFocusManager(); |
54 ~WidgetFocusManager(); | 56 ~WidgetFocusManager(); |
55 | 57 |
56 base::ObserverList<WidgetFocusChangeListener> focus_change_listeners_; | 58 base::ObserverList<WidgetFocusChangeListener> focus_change_listeners_; |
57 | 59 |
58 bool enabled_; | 60 bool enabled_; |
59 | 61 |
60 DISALLOW_COPY_AND_ASSIGN(WidgetFocusManager); | 62 DISALLOW_COPY_AND_ASSIGN(WidgetFocusManager); |
61 }; | 63 }; |
62 | 64 |
63 // A basic helper class that is used to disable native focus change | 65 // A basic helper class that is used to disable native focus change |
64 // notifications within a scope. | 66 // notifications within a scope. |
65 class VIEWS_EXPORT AutoNativeNotificationDisabler { | 67 class VIEWS_EXPORT AutoNativeNotificationDisabler { |
66 public: | 68 public: |
67 AutoNativeNotificationDisabler(); | 69 AutoNativeNotificationDisabler(); |
68 ~AutoNativeNotificationDisabler(); | 70 ~AutoNativeNotificationDisabler(); |
69 | 71 |
70 private: | 72 private: |
71 DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler); | 73 DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler); |
72 }; | 74 }; |
73 | 75 |
74 } // namespace views | 76 } // namespace views |
75 | 77 |
76 #endif // UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ | 78 #endif // UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_ |
OLD | NEW |