summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/automation_internal/automation_event_router.h
diff options
context:
space:
mode:
authordmazzoni <dmazzoni@chromium.org>2015-06-09 17:17:05 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-10 00:17:40 +0000
commita6ea68fcf2fb2de16fbe59fa731fb2b75b96c14d (patch)
treef4a76fcbebf7b53f8ddea163a72793198fbf17f6 /chrome/browser/extensions/api/automation_internal/automation_event_router.h
parentb6d7272854375327f011df67a60108820124df91 (diff)
downloadchromium_src-a6ea68fcf2fb2de16fbe59fa731fb2b75b96c14d.zip
chromium_src-a6ea68fcf2fb2de16fbe59fa731fb2b75b96c14d.tar.gz
chromium_src-a6ea68fcf2fb2de16fbe59fa731fb2b75b96c14d.tar.bz2
Forward accessibility events to the automation extension process.
See bug for context. This patch adds code to keep track of extensions using the automation API that want to subscribe to accessibility events and implements an IPC to forward the accessibility events. The next CL will complete the implementation based on this new IPC and delete the code that forwards accessibility events using the extension event router. BUG=495323 Review URL: https://codereview.chromium.org/1151523009 Cr-Commit-Position: refs/heads/master@{#333616}
Diffstat (limited to 'chrome/browser/extensions/api/automation_internal/automation_event_router.h')
-rw-r--r--chrome/browser/extensions/api/automation_internal/automation_event_router.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/chrome/browser/extensions/api/automation_internal/automation_event_router.h b/chrome/browser/extensions/api/automation_internal/automation_event_router.h
new file mode 100644
index 0000000..1389b43
--- /dev/null
+++ b/chrome/browser/extensions/api/automation_internal/automation_event_router.h
@@ -0,0 +1,89 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_
+#define CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_
+
+#include <vector>
+
+#include "base/memory/singleton.h"
+#include "chrome/common/extensions/api/automation_internal.h"
+#include "content/public/browser/ax_event_notification_details.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "extensions/common/extension.h"
+
+namespace content {
+class BrowserContext;
+} // namespace content
+
+struct ExtensionMsg_AccessibilityEventParams;
+
+namespace extensions {
+
+struct AutomationListener;
+
+class AutomationEventRouter : public content::NotificationObserver {
+ public:
+ static AutomationEventRouter* GetInstance();
+
+ // Indicates that the listener at |listener_process_id|, |listener_routing_id|
+ // wants to receive automation events from the accessibility tree indicated
+ // by |source_ax_tree_id|. Automation events are forwarded from now on
+ // until the listener process dies.
+ void RegisterListenerForOneTree(int listener_process_id,
+ int listener_routing_id,
+ int source_ax_tree_id);
+
+ // Indicates that the listener at |listener_process_id|, |listener_routing_id|
+ // wants to receive automation events from all accessibility trees because
+ // it has Desktop permission.
+ void RegisterListenerWithDesktopPermission(int listener_process_id,
+ int listener_routing_id);
+
+ void DispatchAccessibilityEvent(
+ const ExtensionMsg_AccessibilityEventParams& params);
+
+ // Notify all automation extensions that an accessibility tree was
+ // destroyed. If |browser_context| is null,
+ void DispatchTreeDestroyedEvent(
+ int tree_id,
+ content::BrowserContext* browser_context);
+
+ private:
+ struct AutomationListener {
+ AutomationListener();
+ ~AutomationListener();
+
+ int routing_id;
+ int process_id;
+ bool desktop;
+ std::set<int> tree_ids;
+ };
+
+ AutomationEventRouter();
+ ~AutomationEventRouter() override;
+
+ void Register(
+ int listener_process_id,
+ int listener_routing_id,
+ int source_ax_tree_id,
+ bool desktop);
+
+ // content::NotificationObserver interface.
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ content::NotificationRegistrar registrar_;
+ std::vector<AutomationListener> listeners_;
+
+ friend struct DefaultSingletonTraits<AutomationEventRouter>;
+
+ DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_