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

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: 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 of |window|. If parent of |window| does not exist, the root of
67 // the tree will be notified.
68 void Remove(aura::Window* window, bool notify);
60 69
61 // Removes a view and all of its descendants from the cache. 70 // Removes a view and all of its descendants from the cache.
62 void RemoveViewSubtree(View* view); 71 void RemoveViewSubtree(View* view);
63 72
64 // Lookup a cached entry based on an id. 73 // Lookup a cached entry based on an id.
65 AXAuraObjWrapper* Get(int32_t id); 74 AXAuraObjWrapper* Get(int32_t id);
66 75
67 // Remove a cached entry based on an id. 76 // Remove a cached entry based on an id.
68 void Remove(int32_t id); 77 void Remove(int32_t id);
69 78
70 // Get all top level windows this cache knows about. 79 // Get all top level windows this cache knows about.
71 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children); 80 void GetTopLevelWindows(std::vector<AXAuraObjWrapper*>* children);
72 81
73 // Get the object that has focus. 82 // Get the object that has focus.
74 AXAuraObjWrapper* GetFocus(); 83 AXAuraObjWrapper* GetFocus();
75 84
76 // Indicates if this object's currently being destroyed. 85 // Indicates if this object's currently being destroyed.
77 bool is_destroying() { return is_destroying_; } 86 bool is_destroying() { return is_destroying_; }
78 87
88 void SetDelegate(Delegate* delegate) { delegate_ = delegate; }
89
79 private: 90 private:
80 friend struct base::DefaultSingletonTraits<AXAuraObjCache>; 91 friend struct base::DefaultSingletonTraits<AXAuraObjCache>;
81 92
82 AXAuraObjCache(); 93 AXAuraObjCache();
83 ~AXAuraObjCache() override; 94 ~AXAuraObjCache() override;
84 95
85 View* GetFocusedView(); 96 View* GetFocusedView();
86 97
87 // aura::client::FocusChangeObserver override. 98 // aura::client::FocusChangeObserver override.
88 void OnWindowFocused(aura::Window* gained_focus, 99 void OnWindowFocused(aura::Window* gained_focus,
(...skipping 21 matching lines...) Expand all
110 std::map<aura::Window*, int32_t> window_to_id_map_; 121 std::map<aura::Window*, int32_t> window_to_id_map_;
111 122
112 std::map<int32_t, AXAuraObjWrapper*> cache_; 123 std::map<int32_t, AXAuraObjWrapper*> cache_;
113 int32_t current_id_; 124 int32_t current_id_;
114 125
115 aura::client::FocusClient* focus_client_; 126 aura::client::FocusClient* focus_client_;
116 127
117 // True immediately when entering this object's destructor. 128 // True immediately when entering this object's destructor.
118 bool is_destroying_; 129 bool is_destroying_;
119 130
131 Delegate* delegate_;
132
120 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache); 133 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache);
121 }; 134 };
122 135
123 } // namespace views 136 } // namespace views
124 137
125 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_ 138 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698