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

Side by Side Diff: ui/views/accessibility/ax_aura_obj_cache.h

Issue 2295183003: Update desktop tree when Aura windows are removed. (Closed)
Patch Set: Fix test. Created 4 years, 3 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
OLDNEW
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>
(...skipping 21 matching lines...) Expand all
32 class Widget; 32 class Widget;
33 33
34 // 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.
35 class VIEWS_EXPORT AXAuraObjCache 35 class VIEWS_EXPORT AXAuraObjCache
36 : public aura::client::FocusChangeObserver, 36 : public aura::client::FocusChangeObserver,
37 public aura::WindowObserver { 37 public aura::WindowObserver {
38 public: 38 public:
39 // Get the single instance of this class. 39 // Get the single instance of this class.
40 static AXAuraObjCache* GetInstance(); 40 static AXAuraObjCache* GetInstance();
41 41
42 class Delegate {
43 public:
44 virtual void OnChildWindowRemoved(AXAuraObjWrapper* parent) = 0;
45 };
46
42 // Get or create an entry in the cache based on an Aura view. 47 // Get or create an entry in the cache based on an Aura view.
43 AXAuraObjWrapper* GetOrCreate(View* view); 48 AXAuraObjWrapper* GetOrCreate(View* view);
44 AXAuraObjWrapper* GetOrCreate(Widget* widget); 49 AXAuraObjWrapper* GetOrCreate(Widget* widget);
45 AXAuraObjWrapper* GetOrCreate(aura::Window* window); 50 AXAuraObjWrapper* GetOrCreate(aura::Window* window);
46 51
47 // Gets an id given an Aura view. 52 // Gets an id given an Aura view.
48 int32_t GetID(View* view) const; 53 int32_t GetID(View* view) const;
49 int32_t GetID(Widget* widget) const; 54 int32_t GetID(Widget* widget) const;
50 int32_t GetID(aura::Window* window) const; 55 int32_t GetID(aura::Window* window) const;
51 56
52 // Gets the next unique id for this cache. Useful for non-Aura view backed 57 // Gets the next unique id for this cache. Useful for non-Aura view backed
53 // views. 58 // views.
54 int32_t GetNextID() { return current_id_++; } 59 int32_t GetNextID() { return current_id_++; }
55 60
56 // Removes an entry from this cache based on an Aura view. 61 // Removes an entry from this cache based on an Aura view.
57 void Remove(View* view); 62 void Remove(View* view);
58 void Remove(Widget* widget); 63 void Remove(Widget* widget);
59 void Remove(aura::Window* window); 64
65 // Removes |window| and optionally notifies delegate by sending an event on
66 // the |parent| if provided.
67 void Remove(aura::Window* window, aura::Window* parent);
60 68
61 // Removes a view and all of its descendants from the cache. 69 // Removes a view and all of its descendants from the cache.
62 void RemoveViewSubtree(View* view); 70 void RemoveViewSubtree(View* view);
63 71
64 // Lookup a cached entry based on an id. 72 // Lookup a cached entry based on an id.
65 AXAuraObjWrapper* Get(int32_t id); 73 AXAuraObjWrapper* Get(int32_t id);
66 74
67 // Remove a cached entry based on an id. 75 // Remove a cached entry based on an id.
68 void Remove(int32_t id); 76 void Remove(int32_t id);
69 77
70 // Get all top level windows this cache knows about. 78 // Get all top level windows this cache knows about.
71 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children); 79 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children);
72 80
73 // Get the object that has focus. 81 // Get the object that has focus.
74 AXAuraObjWrapper* GetFocus(); 82 AXAuraObjWrapper* GetFocus();
75 83
76 // Indicates if this object's currently being destroyed. 84 // Indicates if this object's currently being destroyed.
77 bool is_destroying() { return is_destroying_; } 85 bool is_destroying() { return is_destroying_; }
78 86
87 void SetDelegate(Delegate* delegate) { delegate_ = delegate; }
88
79 private: 89 private:
80 friend struct base::DefaultSingletonTraits<AXAuraObjCache>; 90 friend struct base::DefaultSingletonTraits<AXAuraObjCache>;
81 91
82 AXAuraObjCache(); 92 AXAuraObjCache();
83 ~AXAuraObjCache() override; 93 ~AXAuraObjCache() override;
84 94
85 View* GetFocusedView(); 95 View* GetFocusedView();
86 96
87 // aura::client::FocusChangeObserver override. 97 // aura::client::FocusChangeObserver override.
88 void OnWindowFocused(aura::Window* gained_focus, 98 void OnWindowFocused(aura::Window* gained_focus,
(...skipping 21 matching lines...) Expand all
110 std::map<aura::Window*, int32_t> window_to_id_map_; 120 std::map<aura::Window*, int32_t> window_to_id_map_;
111 121
112 std::map<int32_t, AXAuraObjWrapper*> cache_; 122 std::map<int32_t, AXAuraObjWrapper*> cache_;
113 int32_t current_id_; 123 int32_t current_id_;
114 124
115 aura::client::FocusClient* focus_client_; 125 aura::client::FocusClient* focus_client_;
116 126
117 // True immediately when entering this object's destructor. 127 // True immediately when entering this object's destructor.
118 bool is_destroying_; 128 bool is_destroying_;
119 129
130 Delegate* delegate_;
131
120 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); 132 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache);
121 }; 133 };
122 134
123 } // namespace views 135 } // namespace views
124 136
125 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ 137 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/aura/accessibility/automation_manager_aura.cc ('k') | ui/views/accessibility/ax_aura_obj_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698