Index: chrome/browser/accessibility/accessibility_extension_api.cc |
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc |
index 9726a5de069dc9b1080f2ec9d58cdd694a963a62..48a2896bd26db578dd8e3b28d276cb8359cda5bd 100644 |
--- a/chrome/browser/accessibility/accessibility_extension_api.cc |
+++ b/chrome/browser/accessibility/accessibility_extension_api.cc |
@@ -10,13 +10,17 @@ |
#include "chrome/browser/accessibility/accessibility_extension_api_constants.h" |
#include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
#include "chrome/browser/extensions/event_router.h" |
+#include "chrome/browser/extensions/extension_host.h" |
+#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/extensions/extension_tab_util.h" |
+#include "chrome/browser/extensions/lazy_background_task_queue.h" |
#include "chrome/browser/infobars/confirm_infobar_delegate.h" |
#include "chrome/browser/infobars/infobar_delegate.h" |
#include "chrome/browser/infobars/infobar_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/extensions/api/experimental_accessibility.h" |
+#include "chrome/common/extensions/background_info.h" |
#include "content/public/browser/browser_accessibility_state.h" |
#include "extensions/common/error_utils.h" |
@@ -164,6 +168,71 @@ void ExtensionAccessibilityEventRouter::OnMenuClosed( |
args.Pass()); |
} |
+void ExtensionAccessibilityEventRouter:: |
+ OnSpokenFeedbackEnabled(Profile* profile, bool make_announcements) { |
+ scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
+ event_args->Append(base::Value::CreateBooleanValue(make_announcements)); |
+ ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile, |
+ experimental_accessibility::OnSpokenFeedbackEnabled::kEventName, |
+ event_args.Pass(), |
+ true, |
+ NULL); |
+} |
+ |
+void ExtensionAccessibilityEventRouter:: |
+ OnSpokenFeedbackDisabled(Profile* profile) { |
+ scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
+ ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile, |
+ experimental_accessibility::OnSpokenFeedbackDisabled::kEventName, |
+ event_args.Pass(), |
+ true, |
+ NULL); |
+} |
+ |
+// Static. |
+void ExtensionAccessibilityEventRouter::DispatchEventToChromeVox( |
+ Profile* profile, |
+ const char* event_name, |
+ scoped_ptr<base::ListValue> event_args, |
+ bool first_call, |
+ extensions::ExtensionHost* host) { |
+ if (!first_call && !host) |
+ return; |
+ |
+ extensions::ExtensionSystem* system = |
+ extensions::ExtensionSystem::Get(profile); |
+ if (!system) |
+ return; |
+ |
+ const char* extension_id = extension_misc::kChromeVoxExtensionId; |
+ // If this is a persistent background page, we want to wait for it to load |
+ // (it might not be ready, since this is startup). But only enqueue once. |
+ // If it fails to load the first time, don't bother trying again. |
+ const extensions::Extension* extension = |
+ system->extension_service()->extensions()->GetByID(extension_id); |
+ if (extension && |
+ extensions::BackgroundInfo::HasPersistentBackgroundPage(extension) && |
+ first_call && |
+ system->lazy_background_task_queue()-> |
+ ShouldEnqueueTask(profile, extension)) { |
+ extensions::LazyBackgroundTaskQueue* queue = |
dmazzoni
2013/10/29 19:08:44
Move this to before the "if" because the condition
|
+ system->lazy_background_task_queue(); |
+ const extensions::LazyBackgroundTaskQueue::PendingTask callback = |
+ base::Bind(&DispatchEventToChromeVox, |
+ profile, |
+ event_name, |
+ base::Passed(&event_args), |
+ false); |
+ queue->AddPendingTask(profile, extension_id, callback); |
+ return; |
+ } |
+ |
+ scoped_ptr<extensions::Event> event(new extensions::Event(event_name, |
+ event_args.Pass())); |
+ system->event_router()->DispatchEventToExtension( |
+ extension_id, event.Pass()); |
+} |
+ |
void ExtensionAccessibilityEventRouter::DispatchEvent( |
Profile* profile, |
const char* event_name, |