app_shell: Add version number in user agent
[chromium-blink-merge.git] / chrome / browser / accessibility / accessibility_extension_api.h
blob668bb080c1bfa99f462b06248a0ad604781d9418
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EXTENSION_API_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EXTENSION_API_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/singleton.h"
12 #include "base/values.h"
13 #include "chrome/browser/accessibility/accessibility_events.h"
14 #include "chrome/browser/extensions/chrome_extension_function.h"
15 #include "ui/accessibility/ax_enums.h"
17 namespace extensions {
18 class ExtensionHost;
19 } // namespace extensions
21 // Observes the profile and routes accessibility notifications as events
22 // to the extension system.
23 class ExtensionAccessibilityEventRouter {
24 public:
25 typedef base::Callback<void(ui::AXEvent,
26 const AccessibilityControlInfo*)>
27 ControlEventCallback;
28 // Single instance of the event router.
29 static ExtensionAccessibilityEventRouter* GetInstance();
31 // Get the dict representing the last control that received an
32 // OnControlFocus event.
33 base::DictionaryValue* last_focused_control_dict() {
34 return &last_focused_control_dict_;
37 // Accessibility support is disabled until an extension expicitly enables
38 // it, so that this extension api has no impact on Chrome's performance
39 // otherwise. These methods handle enabling, disabling, and querying the
40 // status.
41 void SetAccessibilityEnabled(bool enabled);
42 bool IsAccessibilityEnabled() const;
44 // Set and remove callbacks (used for testing, to confirm that events are
45 // getting through).
46 void SetControlEventCallbackForTesting(ControlEventCallback callback);
47 void ClearControlEventCallback();
49 // Route a window-related accessibility event.
50 void HandleWindowEvent(ui::AXEvent event,
51 const AccessibilityWindowInfo* info);
53 // Route a menu-related accessibility event.
54 void HandleMenuEvent(ui::AXEvent event,
55 const AccessibilityMenuInfo* info);
57 // Route a control-related accessibility event.
58 void HandleControlEvent(ui::AXEvent event,
59 const AccessibilityControlInfo* info);
61 void OnChromeVoxLoadStateChanged(
62 Profile* profile,
63 bool loading,
64 bool make_announcements);
66 static void DispatchEventToChromeVox(
67 Profile* profile,
68 const char* event_name,
69 scoped_ptr<base::ListValue> event_args);
71 private:
72 friend struct DefaultSingletonTraits<ExtensionAccessibilityEventRouter>;
74 ExtensionAccessibilityEventRouter();
75 virtual ~ExtensionAccessibilityEventRouter();
77 void OnWindowOpened(const AccessibilityWindowInfo* details);
78 void OnControlFocused(const AccessibilityControlInfo* details);
79 void OnControlAction(const AccessibilityControlInfo* details);
80 void OnControlHover(const AccessibilityControlInfo* details);
81 void OnTextChanged(const AccessibilityControlInfo* details);
82 void OnMenuOpened(const AccessibilityMenuInfo* details);
83 void OnMenuClosed(const AccessibilityMenuInfo* details);
85 void DispatchEvent(Profile* profile,
86 const char* event_name,
87 scoped_ptr<base::ListValue> event_args);
89 base::DictionaryValue last_focused_control_dict_;
91 bool enabled_;
93 // For testing.
94 ControlEventCallback control_event_callback_;
96 DISALLOW_COPY_AND_ASSIGN(ExtensionAccessibilityEventRouter);
99 // API function that enables or disables accessibility support. Event
100 // listeners are only installed when accessibility support is enabled, to
101 // minimize the impact.
102 class AccessibilityPrivateSetAccessibilityEnabledFunction
103 : public ChromeSyncExtensionFunction {
104 virtual ~AccessibilityPrivateSetAccessibilityEnabledFunction() {}
105 virtual bool RunSync() OVERRIDE;
106 DECLARE_EXTENSION_FUNCTION("accessibilityPrivate.setAccessibilityEnabled",
107 EXPERIMENTAL_ACCESSIBILITY_SETACCESSIBILITYENABLED)
110 // API function that enables or disables web content accessibility support.
111 class AccessibilityPrivateSetNativeAccessibilityEnabledFunction
112 : public ChromeSyncExtensionFunction {
113 virtual ~AccessibilityPrivateSetNativeAccessibilityEnabledFunction() {}
114 virtual bool RunSync() OVERRIDE;
115 DECLARE_EXTENSION_FUNCTION(
116 "accessibilityPrivate.setNativeAccessibilityEnabled",
117 EXPERIMENTAL_ACCESSIBILITY_SETNATIVEACCESSIBILITYENABLED)
120 // API function that returns the most recent focused control.
121 class AccessibilityPrivateGetFocusedControlFunction
122 : public ChromeSyncExtensionFunction {
123 virtual ~AccessibilityPrivateGetFocusedControlFunction() {}
124 virtual bool RunSync() OVERRIDE;
125 DECLARE_EXTENSION_FUNCTION("accessibilityPrivate.getFocusedControl",
126 EXPERIMENTAL_ACCESSIBILITY_GETFOCUSEDCONTROL)
129 // API function that returns alerts being shown on the give tab.
130 class AccessibilityPrivateGetAlertsForTabFunction
131 : public ChromeSyncExtensionFunction {
132 virtual ~AccessibilityPrivateGetAlertsForTabFunction() {}
133 virtual bool RunSync() OVERRIDE;
134 DECLARE_EXTENSION_FUNCTION("accessibilityPrivate.getAlertsForTab",
135 EXPERIMENTAL_ACCESSIBILITY_GETALERTSFORTAB)
138 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EXTENSION_API_H_