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

Side by Side Diff: chrome/browser/gtk/accessibility_event_router_gtk.h

Issue 402099: Add an accessibility API for events raised outside of the web content. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 CHROME_BROWSER_GTK_ACCESSIBILITY_EVENT_ROUTER_GTK_H_
6 #define CHROME_BROWSER_GTK_ACCESSIBILITY_EVENT_ROUTER_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/hash_tables.h"
15 #include "base/singleton.h"
16 #include "chrome/common/accessibility_events.h"
17
18 class Profile;
19
20 // Allows us to use (GtkWidget*) in a hash_map with gcc.
21 namespace __gnu_cxx {
22 template<>
23 struct hash<GtkWidget*> {
24 size_t operator()(GtkWidget* widget) const {
25 return reinterpret_cast<size_t>(widget);
26 }
27 };
28 } // namespace __gnu_cxx
29
30 // Singleton class that adds a signal emission hook to many gtk events, and
31 // then sends an accessibility notification whenever a relevant event is
32 // sent to an accessible control.
33 //
34 // Gtk widgets are not accessible by default. When you register a root widget,
35 // that widget and all of its descendants will start sending accessibility
36 // event notifications. You can then override the default behavior for
37 // specific descendants using other methods.
38 //
39 // You can use Profile::PauseAccessibilityEvents to prevent a flurry
40 // of accessibility events when a window is being created or initialized.
41 class AccessibilityEventRouter {
42 public:
43 // Internal information about a particular widget to override the
44 // information we get directly from gtk.
45 struct WidgetInfo {
46 // If nonempty, will use this name instead of the widget's label.
47 std::string name;
48
49 // If true, will ignore this widget and not send accessibility events.
50 bool ignore;
51 };
52
53 // Get the single instance of this class.
54 static AccessibilityEventRouter* GetInstance();
55
56 // Start sending accessibility events for this widget and all of its
57 // descendants. Notifications will go to the specified profile.
58 void AddRootWidget(GtkWidget* root_widget, Profile* profile);
59
60 // Stop sending accessibility events for this widget and all of its
61 // descendants.
62 void RemoveRootWidget(GtkWidget* root_widget);
63
64 // Don't send any events for this widget.
65 void IgnoreWidget(GtkWidget* widget);
66
67 // Use the following string as the name of this widget, instead of the
68 // gtk label associated with the widget.
69 void SetWidgetName(GtkWidget* widget, std::string name);
70
71 // Forget all information about this widget.
72 void RemoveWidget(GtkWidget* widget);
73
74 //
75 // The following methods are only for use by gtk signal handlers.
76 //
77
78 // Returns true if this widget is a descendant of one of our registered
79 // root widgets and not in the set of ignored widgets. If |profile| is
80 // not null, return the profile where notifications associated with this
81 // widget should be sent.
82 bool IsWidgetAccessible(GtkWidget* widget, Profile** profile);
83
84 // Return the name of a widget.
85 std::string GetWidgetName(GtkWidget* widget);
86
87 // Called by the signal handler. Checks the type of the widget and
88 // calls one of the more specific Send*Notification methods, below.
89 void DispatchAccessibilityNotification(
90 GtkWidget* widget, NotificationType type);
91
92 // Each of these methods constructs an AccessibilityControlInfo object
93 // and sends a notification of a specific accessibility event.
94 void SendRadioButtonNotification(
95 GtkWidget* widget, NotificationType type, Profile* profile);
96 void SendCheckboxNotification(
97 GtkWidget* widget, NotificationType type, Profile* profile);
98 void SendButtonNotification(
99 GtkWidget* widget, NotificationType type, Profile* profile);
100 void SendTextBoxNotification(
101 GtkWidget* widget, NotificationType type, Profile* profile);
102 void SendTabNotification(
103 GtkWidget* widget, NotificationType type, Profile* profile);
104
105 void InstallEventListeners();
106 void RemoveEventListeners();
107
108 private:
109 AccessibilityEventRouter();
110 virtual ~AccessibilityEventRouter() {}
111
112 friend struct DefaultSingletonTraits<AccessibilityEventRouter>;
113
114 // The set of all root widgets; only descendants of these will generate
115 // accessibility notifications.
116 base::hash_map<GtkWidget*, Profile*> root_widget_profile_map_;
117
118 // Extra information about specific widgets.
119 base::hash_map<GtkWidget*, WidgetInfo> widget_info_map_;
120
121 // Installed event listener hook ids so we can remove them later.
122 gulong focus_hook_;
123 gulong click_hook_;
124 gulong toggle_hook_;
125 gulong switch_page_hook_;
126
127 std::vector<gulong> event_listener_hook_ids_;
128 };
129
130 #endif // CHROME_BROWSER_GTK_ACCESSIBILITY_EVENT_ROUTER_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/gtk/accessibility_event_router_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698