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

Side by Side Diff: chrome/browser/ui/views/accessibility_event_router_views.h

Issue 6312160: Map Views to Profiles directly from their window, eliminating the need... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/hash_tables.h"
14 #include "base/singleton.h" 13 #include "base/singleton.h"
15 #include "base/task.h" 14 #include "base/task.h"
16 #include "chrome/browser/accessibility_events.h" 15 #include "chrome/browser/accessibility_events.h"
17 #include "views/accessibility/accessibility_types.h" 16 #include "views/accessibility/accessibility_types.h"
18 17
19 class Profile; 18 class Profile;
20 namespace views { 19 namespace views {
21 class View; 20 class View;
22 } 21 }
23 22
24 // Allows us to use (View*) in a hash_map with gcc.
25 #if defined(COMPILER_GCC)
26 namespace __gnu_cxx {
27 template<>
28 struct hash<views::View*> {
29 size_t operator()(views::View* view) const {
30 return reinterpret_cast<size_t>(view);
31 }
32 };
33 } // namespace __gnu_cxx
34 #endif // defined(COMPILER_GCC)
35
36 // NOTE: This class is part of the Accessibility Extension API, which lets 23 // NOTE: This class is part of the Accessibility Extension API, which lets
37 // extensions receive accessibility events. It's distinct from code that 24 // extensions receive accessibility events. It's distinct from code that
38 // implements platform accessibility APIs like MSAA or ATK. 25 // implements platform accessibility APIs like MSAA or ATK.
39 // 26 //
40 // Singleton class that adds listeners to many views, then sends an 27 // Singleton class that adds listeners to many views, then sends an
41 // accessibility notification whenever a relevant event occurs in an 28 // accessibility notification whenever a relevant event occurs in an
42 // accessible view. 29 // accessible view.
43 // 30 //
44 // Views are not accessible by default. When you register a root widget, 31 // Views are not accessible by default. When you register a root widget,
45 // that widget and all of its descendants will start sending accessibility 32 // that widget and all of its descendants will start sending accessibility
(...skipping 12 matching lines...) Expand all
58 // If nonempty, will use this name instead of the view's label. 45 // If nonempty, will use this name instead of the view's label.
59 std::string name; 46 std::string name;
60 47
61 // If true, will ignore this widget and not send accessibility events. 48 // If true, will ignore this widget and not send accessibility events.
62 bool ignore; 49 bool ignore;
63 }; 50 };
64 51
65 // Get the single instance of this class. 52 // Get the single instance of this class.
66 static AccessibilityEventRouterViews* GetInstance(); 53 static AccessibilityEventRouterViews* GetInstance();
67 54
68 // Start sending accessibility events for this view and all of its
69 // descendants. Notifications will go to the specified profile.
70 // Returns true on success, false if "view" was already registered.
71 // It is the responsibility of the caller to call RemoveViewTree if
72 // this view is ever deleted; consider using AccessibleViewHelper.
73 bool AddViewTree(views::View* view, Profile* profile);
74
75 // Stop sending accessibility events for this view and all of its
76 // descendants.
77 void RemoveViewTree(views::View* view);
78
79 // Don't send any events for this view.
80 void IgnoreView(views::View* view);
81
82 // Use the following string as the name of this view, instead of the
83 // gtk label associated with the view.
84 void SetViewName(views::View* view, std::string name);
85
86 // Forget all information about this view.
87 void RemoveView(views::View* view);
88
89 // Handle an accessibility event generated by a view. 55 // Handle an accessibility event generated by a view.
90 void HandleAccessibilityEvent( 56 void HandleAccessibilityEvent(
91 views::View* view, AccessibilityTypes::Event event_type); 57 views::View* view, AccessibilityTypes::Event event_type);
92 58
93 private: 59 private:
94 AccessibilityEventRouterViews(); 60 AccessibilityEventRouterViews();
95 virtual ~AccessibilityEventRouterViews(); 61 virtual ~AccessibilityEventRouterViews();
96 62
97 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; 63 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>;
98 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, 64 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest,
99 TestFocusNotification); 65 TestFocusNotification);
100 66
101 // Given a view, determine if it's part of a view tree that's mapped to
102 // a profile and if so, if it's marked as accessible.
103 void FindView(views::View* view, Profile** profile, bool* is_accessible);
104
105 // Checks the type of the view and calls one of the more specific 67 // Checks the type of the view and calls one of the more specific
106 // Send*Notification methods, below. 68 // Send*Notification methods, below.
107 void DispatchAccessibilityNotification( 69 void DispatchAccessibilityNotification(
108 views::View* view, NotificationType type); 70 views::View* view, NotificationType type);
109 71
110 // Return the name of a view. 72 // Return the name of a view.
111 std::string GetViewName(views::View* view); 73 std::string GetViewName(views::View* view);
112 74
113 // Each of these methods constructs an AccessibilityControlInfo object 75 // Each of these methods constructs an AccessibilityControlInfo object
114 // and sends a notification of a specific accessibility event. 76 // and sends a notification of a specific accessibility event.
(...skipping 12 matching lines...) Expand all
127 bool IsMenuEvent(views::View* view, NotificationType type); 89 bool IsMenuEvent(views::View* view, NotificationType type);
128 90
129 // Recursively explore all menu items of |menu| and return in |count| 91 // Recursively explore all menu items of |menu| and return in |count|
130 // the total number of items, and in |index| the 0-based index of 92 // the total number of items, and in |index| the 0-based index of
131 // |item|, if found. Initialize |count| to zero before calling this 93 // |item|, if found. Initialize |count| to zero before calling this
132 // method. |index| will be unchanged if the item is not found, so 94 // method. |index| will be unchanged if the item is not found, so
133 // initialize it to -1 to detect this case. 95 // initialize it to -1 to detect this case.
134 void RecursiveGetMenuItemIndexAndCount( 96 void RecursiveGetMenuItemIndexAndCount(
135 views::View* menu, views::View* item, int* index, int* count); 97 views::View* menu, views::View* item, int* index, int* count);
136 98
137 // The set of all view tree roots; only descendants of these will generate
138 // accessibility notifications.
139 base::hash_map<views::View*, Profile*> view_tree_profile_map_;
140
141 // Extra information about specific views.
142 base::hash_map<views::View*, ViewInfo> view_info_map_;
143
144 // The profile associated with the most recent window event - used to 99 // The profile associated with the most recent window event - used to
145 // figure out where to route a few events that can't be directly traced 100 // figure out where to route a few events that can't be directly traced
146 // to a window with a profile (like menu events). 101 // to a window with a profile (like menu events).
147 Profile* most_recent_profile_; 102 Profile* most_recent_profile_;
148 103
149 // Used to defer handling of some events until the next time 104 // Used to defer handling of some events until the next time
150 // through the event loop. 105 // through the event loop.
151 ScopedRunnableMethodFactory<AccessibilityEventRouterViews> method_factory_; 106 ScopedRunnableMethodFactory<AccessibilityEventRouterViews> method_factory_;
152 }; 107 };
153 108
154 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ 109 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/about_chrome_view.cc ('k') | chrome/browser/ui/views/accessibility_event_router_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698