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

Side by Side Diff: chrome/browser/extensions/api/automation_internal/automation_event_router.h

Issue 1268163002: Dispatch automation events to the last used profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTE R_H_ 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_ 6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_ROUTE R_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "chrome/common/extensions/api/automation_internal.h" 11 #include "chrome/common/extensions/api/automation_internal.h"
12 #include "content/public/browser/ax_event_notification_details.h" 12 #include "content/public/browser/ax_event_notification_details.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
16 16
17 #if defined(OS_CHROMEOS)
18 #include "ash/session/session_state_observer.h"
19 #endif
20
21 class Profile;
22
17 namespace content { 23 namespace content {
18 class BrowserContext; 24 class BrowserContext;
19 } // namespace content 25 } // namespace content
20 26
21 struct ExtensionMsg_AccessibilityEventParams; 27 struct ExtensionMsg_AccessibilityEventParams;
22 28
23 namespace extensions { 29 namespace extensions {
24 30
25 struct AutomationListener; 31 struct AutomationListener;
26 32
27 class AutomationEventRouter : public content::NotificationObserver { 33 class AutomationEventRouter
34 : public content::NotificationObserver
35 #if defined(OS_CHROMEOS)
David Tseng 2015/08/05 22:24:36 USE_ASH?
36 , public ash::SessionStateObserver
37 #endif
38 {
28 public: 39 public:
29 static AutomationEventRouter* GetInstance(); 40 static AutomationEventRouter* GetInstance();
30 41
31 // Indicates that the listener at |listener_process_id|, |listener_routing_id| 42 // Indicates that the listener at |listener_process_id|, |listener_routing_id|
32 // wants to receive automation events from the accessibility tree indicated 43 // wants to receive automation events from the accessibility tree indicated
33 // by |source_ax_tree_id|. Automation events are forwarded from now on 44 // by |source_ax_tree_id|. Automation events are forwarded from now on
34 // until the listener process dies. 45 // until the listener process dies.
35 void RegisterListenerForOneTree(int listener_process_id, 46 void RegisterListenerForOneTree(const ExtensionId& extension_id,
47 int listener_process_id,
36 int listener_routing_id, 48 int listener_routing_id,
37 int source_ax_tree_id); 49 int source_ax_tree_id);
38 50
39 // Indicates that the listener at |listener_process_id|, |listener_routing_id| 51 // Indicates that the listener at |listener_process_id|, |listener_routing_id|
40 // wants to receive automation events from all accessibility trees because 52 // wants to receive automation events from all accessibility trees because
41 // it has Desktop permission. 53 // it has Desktop permission.
42 void RegisterListenerWithDesktopPermission(int listener_process_id, 54 void RegisterListenerWithDesktopPermission(const ExtensionId& extension_id,
55 int listener_process_id,
43 int listener_routing_id); 56 int listener_routing_id);
44 57
45 void DispatchAccessibilityEvent( 58 void DispatchAccessibilityEvent(
46 const ExtensionMsg_AccessibilityEventParams& params); 59 const ExtensionMsg_AccessibilityEventParams& params);
47 60
48 // Notify all automation extensions that an accessibility tree was 61 // Notify all automation extensions that an accessibility tree was
49 // destroyed. If |browser_context| is null, 62 // destroyed. If |browser_context| is null,
50 void DispatchTreeDestroyedEvent( 63 void DispatchTreeDestroyedEvent(
51 int tree_id, 64 int tree_id,
52 content::BrowserContext* browser_context); 65 content::BrowserContext* browser_context);
53 66
54 private: 67 private:
55 struct AutomationListener { 68 struct AutomationListener {
56 AutomationListener(); 69 AutomationListener();
57 ~AutomationListener(); 70 ~AutomationListener();
58 71
72 ExtensionId extension_id;
59 int routing_id; 73 int routing_id;
60 int process_id; 74 int process_id;
61 bool desktop; 75 bool desktop;
62 std::set<int> tree_ids; 76 std::set<int> tree_ids;
77 bool is_active_profile;
63 }; 78 };
64 79
65 AutomationEventRouter(); 80 AutomationEventRouter();
66 ~AutomationEventRouter() override; 81 ~AutomationEventRouter() override;
67 82
68 void Register( 83 void Register(
84 const ExtensionId& extension_id,
69 int listener_process_id, 85 int listener_process_id,
70 int listener_routing_id, 86 int listener_routing_id,
71 int source_ax_tree_id, 87 int source_ax_tree_id,
72 bool desktop); 88 bool desktop);
73 89
74 // content::NotificationObserver interface. 90 // content::NotificationObserver interface.
75 void Observe(int type, 91 void Observe(int type,
76 const content::NotificationSource& source, 92 const content::NotificationSource& source,
77 const content::NotificationDetails& details) override; 93 const content::NotificationDetails& details) override;
78 94
95 // SessionStateObserver overrides:
96 void ActiveUserChanged(const std::string& user_id) override;
97
98 void UpdateActiveProfile();
David Tseng 2015/08/05 22:24:36 nit: comment?
dmazzoni 2015/08/05 22:53:39 Done.
99
79 content::NotificationRegistrar registrar_; 100 content::NotificationRegistrar registrar_;
80 std::vector<AutomationListener> listeners_; 101 std::vector<AutomationListener> listeners_;
81 102
103 Profile* active_profile_;
104
105 #if defined(OS_CHROMEOS)
106 scoped_ptr<ash::ScopedSessionStateObserver> session_state_observer_;
107 #endif
108
82 friend struct DefaultSingletonTraits<AutomationEventRouter>; 109 friend struct DefaultSingletonTraits<AutomationEventRouter>;
83 110
84 DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter); 111 DISALLOW_COPY_AND_ASSIGN(AutomationEventRouter);
85 }; 112 };
86 113
87 } // namespace extensions 114 } // namespace extensions
88 115
89 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_RO UTER_H_ 116 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOMATION_INTERNAL_AUTOMATION_EVENT_RO UTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698