OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 5 #ifndef UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "ui/accessibility/ax_enums.h" |
15 #include "ui/aura/client/focus_change_observer.h" | 16 #include "ui/aura/client/focus_change_observer.h" |
16 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
17 #include "ui/views/views_export.h" | 18 #include "ui/views/views_export.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 template <typename T> struct DefaultSingletonTraits; | 21 template <typename T> struct DefaultSingletonTraits; |
21 } | 22 } |
22 | 23 |
23 namespace aura { | 24 namespace aura { |
24 namespace client { | 25 namespace client { |
(...skipping 11 matching lines...) Expand all Loading... |
36 class VIEWS_EXPORT AXAuraObjCache | 37 class VIEWS_EXPORT AXAuraObjCache |
37 : public aura::client::FocusChangeObserver, | 38 : public aura::client::FocusChangeObserver, |
38 public aura::WindowObserver { | 39 public aura::WindowObserver { |
39 public: | 40 public: |
40 // Get the single instance of this class. | 41 // Get the single instance of this class. |
41 static AXAuraObjCache* GetInstance(); | 42 static AXAuraObjCache* GetInstance(); |
42 | 43 |
43 class Delegate { | 44 class Delegate { |
44 public: | 45 public: |
45 virtual void OnChildWindowRemoved(AXAuraObjWrapper* parent) = 0; | 46 virtual void OnChildWindowRemoved(AXAuraObjWrapper* parent) = 0; |
| 47 virtual void OnEvent(AXAuraObjWrapper* aura_obj, |
| 48 ui::AXEvent event_type) = 0; |
46 }; | 49 }; |
47 | 50 |
48 // Get or create an entry in the cache based on an Aura view. | 51 // Get or create an entry in the cache based on an Aura view. |
49 AXAuraObjWrapper* GetOrCreate(View* view); | 52 AXAuraObjWrapper* GetOrCreate(View* view); |
50 AXAuraObjWrapper* GetOrCreate(Widget* widget); | 53 AXAuraObjWrapper* GetOrCreate(Widget* widget); |
51 AXAuraObjWrapper* GetOrCreate(aura::Window* window); | 54 AXAuraObjWrapper* GetOrCreate(aura::Window* window); |
52 | 55 |
53 // Gets an id given an Aura view. | 56 // Gets an id given an Aura view. |
54 int32_t GetID(View* view) const; | 57 int32_t GetID(View* view) const; |
55 int32_t GetID(Widget* widget) const; | 58 int32_t GetID(Widget* widget) const; |
(...skipping 22 matching lines...) Expand all Loading... |
78 | 81 |
79 // Get all top level windows this cache knows about. | 82 // Get all top level windows this cache knows about. |
80 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children); | 83 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children); |
81 | 84 |
82 // Get the object that has focus. | 85 // Get the object that has focus. |
83 AXAuraObjWrapper* GetFocus(); | 86 AXAuraObjWrapper* GetFocus(); |
84 | 87 |
85 // Send a notification that the focused view may have changed. | 88 // Send a notification that the focused view may have changed. |
86 void OnFocusedViewChanged(); | 89 void OnFocusedViewChanged(); |
87 | 90 |
| 91 // Tell our delegate to fire an event on a given object. |
| 92 void FireEvent(AXAuraObjWrapper* aura_obj, ui::AXEvent event_type); |
| 93 |
88 // Indicates if this object's currently being destroyed. | 94 // Indicates if this object's currently being destroyed. |
89 bool is_destroying() { return is_destroying_; } | 95 bool is_destroying() { return is_destroying_; } |
90 | 96 |
91 void SetDelegate(Delegate* delegate) { delegate_ = delegate; } | 97 void SetDelegate(Delegate* delegate) { delegate_ = delegate; } |
92 | 98 |
93 private: | 99 private: |
94 friend struct base::DefaultSingletonTraits<AXAuraObjCache>; | 100 friend struct base::DefaultSingletonTraits<AXAuraObjCache>; |
95 | 101 |
96 AXAuraObjCache(); | 102 AXAuraObjCache(); |
97 ~AXAuraObjCache() override; | 103 ~AXAuraObjCache() override; |
98 | 104 |
99 View* GetFocusedView(); | 105 View* GetFocusedView(); |
100 | 106 |
101 // aura::client::FocusChangeObserver override. | 107 // aura::client::FocusChangeObserver override. |
102 void OnWindowFocused(aura::Window* gained_focus, | 108 void OnWindowFocused(aura::Window* gained_focus, |
103 aura::Window* lost_focus) override; | 109 aura::Window* lost_focus) override; |
104 | 110 |
105 // aura::WindowObserver override. | 111 // aura::WindowObserver override. |
106 void OnWindowDestroying(aura::Window* window) override; | 112 void OnWindowDestroying(aura::Window* window) override; |
| 113 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
107 | 114 |
108 template <typename AuraViewWrapper, typename AuraView> | 115 template <typename AuraViewWrapper, typename AuraView> |
109 AXAuraObjWrapper* CreateInternal( | 116 AXAuraObjWrapper* CreateInternal( |
110 AuraView* aura_view, | 117 AuraView* aura_view, |
111 std::map<AuraView*, int32_t>& aura_view_to_id_map); | 118 std::map<AuraView*, int32_t>& aura_view_to_id_map); |
112 | 119 |
113 template <typename AuraView> | 120 template <typename AuraView> |
114 int32_t GetIDInternal( | 121 int32_t GetIDInternal( |
115 AuraView* aura_view, | 122 AuraView* aura_view, |
116 const std::map<AuraView*, int32_t>& aura_view_to_id_map) const; | 123 const std::map<AuraView*, int32_t>& aura_view_to_id_map) const; |
(...skipping 15 matching lines...) Expand all Loading... |
132 bool is_destroying_; | 139 bool is_destroying_; |
133 | 140 |
134 Delegate* delegate_; | 141 Delegate* delegate_; |
135 | 142 |
136 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); | 143 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); |
137 }; | 144 }; |
138 | 145 |
139 } // namespace views | 146 } // namespace views |
140 | 147 |
141 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 148 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
OLD | NEW |