Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / automation_internal / automation_event_router.h
blob1389b43205944e6b76b9c728074c2a54b3bd1f41
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_
8 #include <vector>
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"
17 namespace content {
18 class BrowserContext;
19 } // namespace content
21 struct ExtensionMsg_AccessibilityEventParams;
23 namespace extensions {
25 struct AutomationListener;
27 class AutomationEventRouter : public content::NotificationObserver {
28 public:
29 static AutomationEventRouter* GetInstance();
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);
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);
45 void DispatchAccessibilityEvent(
46 const ExtensionMsg_AccessibilityEventParams& params);
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);
54 private:
55 struct AutomationListener {
56 AutomationListener();
57 ~AutomationListener();
59 int routing_id;
60 int process_id;
61 bool desktop;
62 std::set<int> tree_ids;
65 AutomationEventRouter();
66 ~AutomationEventRouter() override;
68 void Register(
69 int listener_process_id,
70 int listener_routing_id,
71 int source_ax_tree_id,
72 bool desktop);
74 // content::NotificationObserver interface.
75 void Observe(int type,
76 const content::NotificationSource& source,
77 const content::NotificationDetails& details) override;
79 content::NotificationRegistrar registrar_;
80 std::vector<AutomationListener> listeners_;
82 friend struct DefaultSingletonTraits<AutomationEventRouter>;
84 DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter);
87 } // namespace extensions
89 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTER_H_