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|, or all accessibility trees if |desktop| is true. | |
34 // Automation events are forwarded from now on until the listener process | |
35 // dies. | |
36 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
| |
37 int listener_routing_id, | |
38 int source_ax_tree_id, | |
39 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.
| |
40 | |
41 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.
| |
42 const ExtensionMsg_AccessibilityEventParams& params); | |
43 | |
44 // Notify all automation extensions that an accessibility tree was | |
45 // destroyed. If |browser_context| is null, | |
46 void DispatchTreeDestroyedEventToAutomation( | |
47 int tree_id, | |
48 content::BrowserContext* browser_context); | |
49 | |
50 private: | |
51 struct AutomationListener { | |
52 AutomationListener(); | |
53 ~AutomationListener(); | |
54 | |
55 int routing_id; | |
56 int process_id; | |
57 bool desktop; | |
58 std::set<int> tree_ids; | |
59 }; | |
60 | |
61 AutomationEventRouter(); | |
62 ~AutomationEventRouter() override; | |
63 | |
64 // content::NotificationObserver interface. | |
65 void Observe(int type, | |
66 const content::NotificationSource& source, | |
67 const content::NotificationDetails& details) override; | |
68 | |
69 content::NotificationRegistrar registrar_; | |
70 std::vector<AutomationListener> listeners_; | |
71 | |
72 friend struct DefaultSingletonTraits<AutomationEventRouter>; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter); | |
75 }; | |
76 | |
77 } // namespace extensions | |
78 | |
79 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_RO UTER_H_ | |
OLD | NEW |