Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: chrome/browser/extensions/api/automation_internal/automation_event_router.h

Issue 1151523009: Forward accessibility events to the automation extension process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@step1
Patch Set: Own a message filter rather than inheriting Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/automation_internal/automation_event_router.h
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 0000000000000000000000000000000000000000..92115b0422127a3503979828e92fe06f0d128911
--- /dev/null
+++ b/chrome/browser/extensions/api/automation_internal/automation_event_router.h
@@ -0,0 +1,79 @@
+// 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|, or all accessibility trees if |desktop| is true.
+ // Automation events are forwarded from now on until the listener process
+ // dies.
+ void AddListener(int listener_process_id,
not at google - send to devlin 2015/06/04 23:03:28 A name like "AddListener" implies to me that it sh
dmazzoni 2015/06/08 18:02:57 I like "Register", since the name of the class (Au
+ int listener_routing_id,
+ int source_ax_tree_id,
+ bool desktop);
not at google - send to devlin 2015/06/04 23:03:28 On reading call sites, I'd find it nicer if this w
dmazzoni 2015/06/08 18:02:57 Sure. Made into two methods.
+
+ void DispatchAccessibilityEventToAutomation(
not at google - send to devlin 2015/06/04 23:03:28 Well I'd drop the "ToAutomation", but up to you.
dmazzoni 2015/06/08 18:02:57 Done.
+ const ExtensionMsg_AccessibilityEventParams& params);
+
+ // Notify all automation extensions that an accessibility tree was
+ // destroyed. If |browser_context| is null,
+ void DispatchTreeDestroyedEventToAutomation(
+ 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;
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698