| 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 <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/aura/client/focus_change_observer.h" | 14 #include "ui/aura/client/focus_change_observer.h" |
| 15 #include "ui/aura/window_observer.h" |
| 15 #include "ui/views/views_export.h" | 16 #include "ui/views/views_export.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 template <typename T> struct DefaultSingletonTraits; | 19 template <typename T> struct DefaultSingletonTraits; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 namespace client { | 23 namespace client { |
| 23 class FocusClient; | 24 class FocusClient; |
| 24 } | 25 } |
| 25 class Window; | 26 class Window; |
| 26 } // namespace aura | 27 } // namespace aura |
| 27 | 28 |
| 28 namespace views { | 29 namespace views { |
| 29 class AXAuraObjWrapper; | 30 class AXAuraObjWrapper; |
| 30 class View; | 31 class View; |
| 31 class Widget; | 32 class Widget; |
| 32 | 33 |
| 33 // A cache responsible for assigning id's to a set of interesting Aura views. | 34 // A cache responsible for assigning id's to a set of interesting Aura views. |
| 34 class VIEWS_EXPORT AXAuraObjCache | 35 class VIEWS_EXPORT AXAuraObjCache |
| 35 : public aura::client::FocusChangeObserver { | 36 : public aura::client::FocusChangeObserver, |
| 37 public aura::WindowObserver { |
| 36 public: | 38 public: |
| 37 // Get the single instance of this class. | 39 // Get the single instance of this class. |
| 38 static AXAuraObjCache* GetInstance(); | 40 static AXAuraObjCache* GetInstance(); |
| 39 | 41 |
| 40 // Get or create an entry in the cache based on an Aura view. | 42 // Get or create an entry in the cache based on an Aura view. |
| 41 AXAuraObjWrapper* GetOrCreate(View* view); | 43 AXAuraObjWrapper* GetOrCreate(View* view); |
| 42 AXAuraObjWrapper* GetOrCreate(Widget* widget); | 44 AXAuraObjWrapper* GetOrCreate(Widget* widget); |
| 43 AXAuraObjWrapper* GetOrCreate(aura::Window* window); | 45 AXAuraObjWrapper* GetOrCreate(aura::Window* window); |
| 44 | 46 |
| 45 // Gets an id given an Aura view. | 47 // Gets an id given an Aura view. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 81 |
| 80 AXAuraObjCache(); | 82 AXAuraObjCache(); |
| 81 ~AXAuraObjCache() override; | 83 ~AXAuraObjCache() override; |
| 82 | 84 |
| 83 View* GetFocusedView(); | 85 View* GetFocusedView(); |
| 84 | 86 |
| 85 // aura::client::FocusChangeObserver override. | 87 // aura::client::FocusChangeObserver override. |
| 86 void OnWindowFocused(aura::Window* gained_focus, | 88 void OnWindowFocused(aura::Window* gained_focus, |
| 87 aura::Window* lost_focus) override; | 89 aura::Window* lost_focus) override; |
| 88 | 90 |
| 91 // aura::WindowObserver override. |
| 92 void OnWindowDestroying(aura::Window* window) override; |
| 93 |
| 89 template <typename AuraViewWrapper, typename AuraView> | 94 template <typename AuraViewWrapper, typename AuraView> |
| 90 AXAuraObjWrapper* CreateInternal( | 95 AXAuraObjWrapper* CreateInternal( |
| 91 AuraView* aura_view, | 96 AuraView* aura_view, |
| 92 std::map<AuraView*, int32_t>& aura_view_to_id_map); | 97 std::map<AuraView*, int32_t>& aura_view_to_id_map); |
| 93 | 98 |
| 94 template <typename AuraView> | 99 template <typename AuraView> |
| 95 int32_t GetIDInternal( | 100 int32_t GetIDInternal( |
| 96 AuraView* aura_view, | 101 AuraView* aura_view, |
| 97 const std::map<AuraView*, int32_t>& aura_view_to_id_map) const; | 102 const std::map<AuraView*, int32_t>& aura_view_to_id_map) const; |
| 98 | 103 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 | 116 |
| 112 // True immediately when entering this object's destructor. | 117 // True immediately when entering this object's destructor. |
| 113 bool is_destroying_; | 118 bool is_destroying_; |
| 114 | 119 |
| 115 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); | 120 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 } // namespace views | 123 } // namespace views |
| 119 | 124 |
| 120 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ | 125 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ |
| OLD | NEW |