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

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

Issue 246433012: Extend AXTreeSourceViews to handle aura::Window and views::Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move files from c/b/u/views/accessibility to c/b/u/ash/accessibility Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/accessibility/ax_view_state.h ('k') | ui/views/accessibility/ax_aura_obj_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_
6 #define UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "ui/views/views_export.h"
12
13 template <typename T> struct DefaultSingletonTraits;
14
15 namespace aura {
16 class Window;
17 } // namespace aura
18
19 namespace views {
20 class AXAuraObjWrapper;
21 class View;
22 class Widget;
23
24 // A cache responsible for assigning id's to a set of interesting Aura views.
25 class VIEWS_EXPORT AXAuraObjCache {
26 public:
27 // Get the single instance of this class.
28 static AXAuraObjCache* GetInstance();
29
30 // Get or create an entry in the cache based on an Aura view.
31 AXAuraObjWrapper* GetOrCreate(View* view);
32 AXAuraObjWrapper* GetOrCreate(Widget* widget);
33 AXAuraObjWrapper* GetOrCreate(aura::Window* window);
34
35 // Gets an id given an Aura view.
36 int32 GetID(View* view);
37 int32 GetID(Widget* widget);
38 int32 GetID(aura::Window* window);
39
40 // Gets the next unique id for this cache. Useful for non-Aura view backed
41 // views.
42 int32 GetNextID() { return current_id_++; }
43
44 // Removes an entry from this cache based on an Aura view.
45 void Remove(View* view);
46 void Remove(Widget* widget);
47 void Remove(aura::Window* window);
48
49 // Lookup a cached entry based on an id.
50 AXAuraObjWrapper* Get(int32 id);
51
52 // Remove a cached entry based on an id.
53 void Remove(int32 id);
54
55 private:
56 friend struct DefaultSingletonTraits<AXAuraObjCache>;
57
58 AXAuraObjCache();
59 virtual ~AXAuraObjCache();
60
61 template <typename AuraViewWrapper, typename AuraView>
62 AXAuraObjWrapper* CreateInternal(
63 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map);
64
65 template<typename AuraView> int32 GetIDInternal(
66 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map);
67
68 template<typename AuraView> void RemoveInternal(
69 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map);
70
71 std::map<views::View*, int32> view_to_id_map_;
72 std::map<views::Widget*, int32> widget_to_id_map_;
73 std::map<aura::Window*, int32> window_to_id_map_;
74
75 std::map<int32, AXAuraObjWrapper*> cache_;
76 int32 current_id_;
77
78 DISALLOW_COPY_AND_ASSIGN(AXAuraObjCache);
79 };
80
81 } // namespace views
82
83 #endif // UI_VIEWS_ACCESSIBILITY_AX_AURA_OBJ_CACHE_H_
OLDNEW
« no previous file with comments | « ui/accessibility/ax_view_state.h ('k') | ui/views/accessibility/ax_aura_obj_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698