OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTE
R_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTE
R_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/singleton.h" |
| 11 #include "chrome/common/extensions/api/automation_internal.h" |
| 12 #include "content/public/browser/ax_event_notification_details.h" |
| 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "extensions/common/extension.h" |
| 16 |
| 17 namespace content { |
| 18 class BrowserContext; |
| 19 } // namespace content |
| 20 |
| 21 struct ExtensionMsg_AccessibilityEventParams; |
| 22 |
| 23 namespace extensions { |
| 24 |
| 25 struct AutomationListener; |
| 26 |
| 27 class AutomationEventRouter : public content::NotificationObserver { |
| 28 public: |
| 29 static AutomationEventRouter* GetInstance(); |
| 30 |
| 31 // Indicates that the listener at |listener_process_id|, |listener_routing_id| |
| 32 // wants to receive automation events from the accessibility tree indicated |
| 33 // by |source_ax_tree_id|. Automation events are forwarded from now on |
| 34 // until the listener process dies. |
| 35 void RegisterListenerForOneTree(int listener_process_id, |
| 36 int listener_routing_id, |
| 37 int source_ax_tree_id); |
| 38 |
| 39 // Indicates that the listener at |listener_process_id|, |listener_routing_id| |
| 40 // wants to receive automation events from all accessibility trees because |
| 41 // it has Desktop permission. |
| 42 void RegisterListenerWithDesktopPermission(int listener_process_id, |
| 43 int listener_routing_id); |
| 44 |
| 45 void DispatchAccessibilityEvent( |
| 46 const ExtensionMsg_AccessibilityEventParams& params); |
| 47 |
| 48 // Notify all automation extensions that an accessibility tree was |
| 49 // destroyed. If |browser_context| is null, |
| 50 void DispatchTreeDestroyedEvent( |
| 51 int tree_id, |
| 52 content::BrowserContext* browser_context); |
| 53 |
| 54 private: |
| 55 struct AutomationListener { |
| 56 AutomationListener(); |
| 57 ~AutomationListener(); |
| 58 |
| 59 int routing_id; |
| 60 int process_id; |
| 61 bool desktop; |
| 62 std::set<int> tree_ids; |
| 63 }; |
| 64 |
| 65 AutomationEventRouter(); |
| 66 ~AutomationEventRouter() override; |
| 67 |
| 68 void Register( |
| 69 int listener_process_id, |
| 70 int listener_routing_id, |
| 71 int source_ax_tree_id, |
| 72 bool desktop); |
| 73 |
| 74 // content::NotificationObserver interface. |
| 75 void Observe(int type, |
| 76 const content::NotificationSource& source, |
| 77 const content::NotificationDetails& details) override; |
| 78 |
| 79 content::NotificationRegistrar registrar_; |
| 80 std::vector<AutomationListener> listeners_; |
| 81 |
| 82 friend struct DefaultSingletonTraits<AutomationEventRouter>; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter); |
| 85 }; |
| 86 |
| 87 } // namespace extensions |
| 88 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_RO
UTER_H_ |
OLD | NEW |