OLD | NEW |
1 // Copyright (c) 2011 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 #include "chrome/browser/extensions/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_accessibility_api.h" | 11 #include "chrome/browser/extensions/extension_accessibility_api.h" |
12 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" | 12 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" |
13 #include "chrome/browser/extensions/extension_event_router.h" | 13 #include "chrome/browser/extensions/extension_event_router.h" |
14 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
20 #include "content/common/notification_service.h" | 21 #include "content/common/notification_service.h" |
21 | 22 |
22 namespace keys = extension_accessibility_api_constants; | 23 namespace keys = extension_accessibility_api_constants; |
23 | 24 |
24 // Returns the AccessibilityControlInfo serialized into a JSON string, | 25 // Returns the AccessibilityControlInfo serialized into a JSON string, |
25 // consisting of an array of a single object of type AccessibilityObject, | 26 // consisting of an array of a single object of type AccessibilityObject, |
26 // as defined in the accessibility extension api's json schema. | 27 // as defined in the accessibility extension api's json schema. |
27 std::string ControlInfoToJsonString(const AccessibilityControlInfo* info) { | 28 std::string ControlInfoToJsonString(const AccessibilityControlInfo* info) { |
28 ListValue args; | 29 ListValue args; |
(...skipping 16 matching lines...) Expand all Loading... |
45 ExtensionAccessibilityEventRouter::~ExtensionAccessibilityEventRouter() { | 46 ExtensionAccessibilityEventRouter::~ExtensionAccessibilityEventRouter() { |
46 STLDeleteElements(&on_enabled_listeners_); | 47 STLDeleteElements(&on_enabled_listeners_); |
47 STLDeleteElements(&on_disabled_listeners_); | 48 STLDeleteElements(&on_disabled_listeners_); |
48 } | 49 } |
49 | 50 |
50 void ExtensionAccessibilityEventRouter::ObserveProfile(Profile* profile) { | 51 void ExtensionAccessibilityEventRouter::ObserveProfile(Profile* profile) { |
51 last_focused_control_dict_.Clear(); | 52 last_focused_control_dict_.Clear(); |
52 | 53 |
53 if (registrar_.IsEmpty()) { | 54 if (registrar_.IsEmpty()) { |
54 registrar_.Add(this, | 55 registrar_.Add(this, |
55 NotificationType::ACCESSIBILITY_WINDOW_OPENED, | 56 chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_OPENED, |
56 NotificationService::AllSources()); | 57 NotificationService::AllSources()); |
57 registrar_.Add(this, | 58 registrar_.Add(this, |
58 NotificationType::ACCESSIBILITY_WINDOW_CLOSED, | 59 chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_CLOSED, |
59 NotificationService::AllSources()); | 60 NotificationService::AllSources()); |
60 registrar_.Add(this, | 61 registrar_.Add(this, |
61 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, | 62 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
62 NotificationService::AllSources()); | 63 NotificationService::AllSources()); |
63 registrar_.Add(this, | 64 registrar_.Add(this, |
64 NotificationType::ACCESSIBILITY_CONTROL_ACTION, | 65 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_ACTION, |
65 NotificationService::AllSources()); | 66 NotificationService::AllSources()); |
66 registrar_.Add(this, | 67 registrar_.Add(this, |
67 NotificationType::ACCESSIBILITY_TEXT_CHANGED, | 68 chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED, |
68 NotificationService::AllSources()); | 69 NotificationService::AllSources()); |
69 registrar_.Add(this, | 70 registrar_.Add(this, |
70 NotificationType::ACCESSIBILITY_MENU_OPENED, | 71 chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED, |
71 NotificationService::AllSources()); | 72 NotificationService::AllSources()); |
72 registrar_.Add(this, | 73 registrar_.Add(this, |
73 NotificationType::ACCESSIBILITY_MENU_CLOSED, | 74 chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED, |
74 NotificationService::AllSources()); | 75 NotificationService::AllSources()); |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 void ExtensionAccessibilityEventRouter::Observe( | 79 void ExtensionAccessibilityEventRouter::Observe( |
79 NotificationType type, | 80 int type, |
80 const NotificationSource& source, | 81 const NotificationSource& source, |
81 const NotificationDetails& details) { | 82 const NotificationDetails& details) { |
82 switch (type.value) { | 83 switch (type) { |
83 case NotificationType::ACCESSIBILITY_WINDOW_OPENED: | 84 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_OPENED: |
84 OnWindowOpened(Details<const AccessibilityWindowInfo>(details).ptr()); | 85 OnWindowOpened(Details<const AccessibilityWindowInfo>(details).ptr()); |
85 break; | 86 break; |
86 case NotificationType::ACCESSIBILITY_WINDOW_CLOSED: | 87 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_CLOSED: |
87 OnWindowClosed(Details<const AccessibilityWindowInfo>(details).ptr()); | 88 OnWindowClosed(Details<const AccessibilityWindowInfo>(details).ptr()); |
88 break; | 89 break; |
89 case NotificationType::ACCESSIBILITY_CONTROL_FOCUSED: | 90 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED: |
90 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); | 91 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); |
91 break; | 92 break; |
92 case NotificationType::ACCESSIBILITY_CONTROL_ACTION: | 93 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_ACTION: |
93 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); | 94 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); |
94 break; | 95 break; |
95 case NotificationType::ACCESSIBILITY_TEXT_CHANGED: | 96 case chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED: |
96 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); | 97 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); |
97 break; | 98 break; |
98 case NotificationType::ACCESSIBILITY_MENU_OPENED: | 99 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED: |
99 OnMenuOpened(Details<const AccessibilityMenuInfo>(details).ptr()); | 100 OnMenuOpened(Details<const AccessibilityMenuInfo>(details).ptr()); |
100 break; | 101 break; |
101 case NotificationType::ACCESSIBILITY_MENU_CLOSED: | 102 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED: |
102 OnMenuClosed(Details<const AccessibilityMenuInfo>(details).ptr()); | 103 OnMenuClosed(Details<const AccessibilityMenuInfo>(details).ptr()); |
103 break; | 104 break; |
104 default: | 105 default: |
105 NOTREACHED(); | 106 NOTREACHED(); |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { | 110 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { |
110 if (enabled_ != enabled) { | 111 if (enabled_ != enabled) { |
111 enabled_ = enabled; | 112 enabled_ = enabled; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ExtensionAccessibilityEventRouter::GetInstance(); | 206 ExtensionAccessibilityEventRouter::GetInstance(); |
206 DictionaryValue *last_focused_control_dict = | 207 DictionaryValue *last_focused_control_dict = |
207 accessibility_event_router->last_focused_control_dict(); | 208 accessibility_event_router->last_focused_control_dict(); |
208 if (last_focused_control_dict->size()) { | 209 if (last_focused_control_dict->size()) { |
209 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 210 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
210 } else { | 211 } else { |
211 result_.reset(Value::CreateNullValue()); | 212 result_.reset(Value::CreateNullValue()); |
212 } | 213 } |
213 return true; | 214 return true; |
214 } | 215 } |
OLD | NEW |