OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/accessibility/accessibility_extension_api.h" | 5 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" |
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
12 #include "chrome/browser/extensions/event_router.h" | 12 #include "chrome/browser/extensions/event_router.h" |
| 13 #include "chrome/browser/extensions/extension_host.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 17 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
16 #include "chrome/browser/infobars/infobar_delegate.h" | 18 #include "chrome/browser/infobars/infobar_delegate.h" |
17 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/extensions/api/experimental_accessibility.h" | 21 #include "chrome/common/extensions/api/experimental_accessibility.h" |
| 22 #include "chrome/common/extensions/background_info.h" |
20 #include "content/public/browser/browser_accessibility_state.h" | 23 #include "content/public/browser/browser_accessibility_state.h" |
| 24 #include "extensions/browser/lazy_background_task_queue.h" |
21 #include "extensions/common/error_utils.h" | 25 #include "extensions/common/error_utils.h" |
22 | 26 |
23 namespace keys = extension_accessibility_api_constants; | 27 namespace keys = extension_accessibility_api_constants; |
24 namespace experimental_accessibility = | 28 namespace experimental_accessibility = |
25 extensions::api::experimental_accessibility; | 29 extensions::api::experimental_accessibility; |
26 | 30 |
27 // Returns the AccessibilityControlInfo serialized into a JSON string, | 31 // Returns the AccessibilityControlInfo serialized into a JSON string, |
28 // consisting of an array of a single object of type AccessibilityObject, | 32 // consisting of an array of a single object of type AccessibilityObject, |
29 // as defined in the accessibility extension api's json schema. | 33 // as defined in the accessibility extension api's json schema. |
30 scoped_ptr<ListValue> ControlInfoToEventArguments( | 34 scoped_ptr<ListValue> ControlInfoToEventArguments( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 161 } |
158 | 162 |
159 void ExtensionAccessibilityEventRouter::OnMenuClosed( | 163 void ExtensionAccessibilityEventRouter::OnMenuClosed( |
160 const AccessibilityMenuInfo* info) { | 164 const AccessibilityMenuInfo* info) { |
161 scoped_ptr<ListValue> args(ControlInfoToEventArguments(info)); | 165 scoped_ptr<ListValue> args(ControlInfoToEventArguments(info)); |
162 DispatchEvent(info->profile(), | 166 DispatchEvent(info->profile(), |
163 experimental_accessibility::OnMenuClosed::kEventName, | 167 experimental_accessibility::OnMenuClosed::kEventName, |
164 args.Pass()); | 168 args.Pass()); |
165 } | 169 } |
166 | 170 |
| 171 void ExtensionAccessibilityEventRouter::OnChromeVoxLoadStateChanged( |
| 172 Profile* profile, |
| 173 bool loading, |
| 174 bool make_announcements) { |
| 175 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
| 176 event_args->Append(base::Value::CreateBooleanValue(loading)); |
| 177 event_args->Append(base::Value::CreateBooleanValue(make_announcements)); |
| 178 ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile, |
| 179 experimental_accessibility::OnChromeVoxLoadStateChanged::kEventName, |
| 180 event_args.Pass()); |
| 181 } |
| 182 |
| 183 // Static. |
| 184 void ExtensionAccessibilityEventRouter::DispatchEventToChromeVox( |
| 185 Profile* profile, |
| 186 const char* event_name, |
| 187 scoped_ptr<base::ListValue> event_args) { |
| 188 extensions::ExtensionSystem* system = |
| 189 extensions::ExtensionSystem::Get(profile); |
| 190 if (!system) |
| 191 return; |
| 192 scoped_ptr<extensions::Event> event(new extensions::Event(event_name, |
| 193 event_args.Pass())); |
| 194 system->event_router()->DispatchEventToExtension( |
| 195 extension_misc::kChromeVoxExtensionId, event.Pass()); |
| 196 } |
| 197 |
167 void ExtensionAccessibilityEventRouter::DispatchEvent( | 198 void ExtensionAccessibilityEventRouter::DispatchEvent( |
168 Profile* profile, | 199 Profile* profile, |
169 const char* event_name, | 200 const char* event_name, |
170 scoped_ptr<base::ListValue> event_args) { | 201 scoped_ptr<base::ListValue> event_args) { |
171 if (enabled_ && profile && | 202 if (enabled_ && profile && |
172 extensions::ExtensionSystem::Get(profile)->event_router()) { | 203 extensions::ExtensionSystem::Get(profile)->event_router()) { |
173 scoped_ptr<extensions::Event> event(new extensions::Event( | 204 scoped_ptr<extensions::Event> event(new extensions::Event( |
174 event_name, event_args.Pass())); | 205 event_name, event_args.Pass())); |
175 extensions::ExtensionSystem::Get(profile)->event_router()-> | 206 extensions::ExtensionSystem::Get(profile)->event_router()-> |
176 BroadcastEvent(event.Pass()); | 207 BroadcastEvent(event.Pass()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 DictionaryValue* alert_value = new DictionaryValue; | 276 DictionaryValue* alert_value = new DictionaryValue; |
246 const string16 message_text = confirm_infobar_delegate->GetMessageText(); | 277 const string16 message_text = confirm_infobar_delegate->GetMessageText(); |
247 alert_value->SetString(keys::kMessageKey, message_text); | 278 alert_value->SetString(keys::kMessageKey, message_text); |
248 alerts_value->Append(alert_value); | 279 alerts_value->Append(alert_value); |
249 } | 280 } |
250 } | 281 } |
251 | 282 |
252 SetResult(alerts_value); | 283 SetResult(alerts_value); |
253 return true; | 284 return true; |
254 } | 285 } |
OLD | NEW |