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

Side by Side Diff: components/arc/arc_bridge_service.h

Issue 1475583002: Add IPC messages for ARC notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years 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
« no previous file with comments | « components/arc/BUILD.gn ('k') | components/arc/arc_bridge_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
7 7
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "components/arc/common/arc_message_types.h" 12 #include "components/arc/common/arc_message_types.h"
13 #include "components/arc/common/arc_notification_types.h"
13 14
14 namespace base { 15 namespace base {
15 class CommandLine; 16 class CommandLine;
16 class SequencedTaskRunner; 17 class SequencedTaskRunner;
17 class SingleThreadTaskRunner; 18 class SingleThreadTaskRunner;
18 } // namespace base 19 } // namespace base
19 20
20 namespace arc { 21 namespace arc {
21 22
22 // The Chrome-side service that handles ARC instances and ARC bridge creation. 23 // The Chrome-side service that handles ARC instances and ARC bridge creation.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Called when the instance has reached a boot phase 74 // Called when the instance has reached a boot phase
74 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {} 75 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {}
75 76
76 // Called whenever ARC's availability has changed for this system. 77 // Called whenever ARC's availability has changed for this system.
77 virtual void OnAvailableChanged(bool available) {} 78 virtual void OnAvailableChanged(bool available) {}
78 79
79 protected: 80 protected:
80 virtual ~Observer() {} 81 virtual ~Observer() {}
81 }; 82 };
82 83
84 class NotificationObserver {
85 public:
86 // Called whenever a notification has been posted on Android side. This
87 // event is used for both creation and update.
88 virtual void OnNotificationPostedFromAndroid(
89 const ArcNotificationData& data) {}
90 // Called whenever a notification has been removed on Android side.
91 virtual void OnNotificationRemovedFromAndroid(const std::string& key) {}
92
93 protected:
94 virtual ~NotificationObserver() {}
95 };
96
83 // Notifies ARC apps related events. 97 // Notifies ARC apps related events.
84 class AppObserver { 98 class AppObserver {
85 public: 99 public:
86 // Called whenever ARC sends information about available apps. 100 // Called whenever ARC sends information about available apps.
87 virtual void OnAppListRefreshed(const std::vector<AppInfo>& apps) {} 101 virtual void OnAppListRefreshed(const std::vector<AppInfo>& apps) {}
88 102
89 // Called whenever ARC sends app icon data for specific scale factor. 103 // Called whenever ARC sends app icon data for specific scale factor.
90 virtual void OnAppIcon(const std::string& package, 104 virtual void OnAppIcon(const std::string& package,
91 const std::string& activity, 105 const std::string& activity,
92 ScaleFactor scale_factor, 106 ScaleFactor scale_factor,
(...skipping 29 matching lines...) Expand all
122 virtual void HandleStartup() = 0; 136 virtual void HandleStartup() = 0;
123 137
124 // Shutdown() should be called when the browser is shutting down. This can 138 // Shutdown() should be called when the browser is shutting down. This can
125 // only be called on the thread that this class was created on. 139 // only be called on the thread that this class was created on.
126 virtual void Shutdown() = 0; 140 virtual void Shutdown() = 0;
127 141
128 // Adds or removes observers. This can only be called on the thread that this 142 // Adds or removes observers. This can only be called on the thread that this
129 // class was created on. 143 // class was created on.
130 void AddObserver(Observer* observer); 144 void AddObserver(Observer* observer);
131 void RemoveObserver(Observer* observer); 145 void RemoveObserver(Observer* observer);
146 void AddNotificationObserver(NotificationObserver* observer);
147 void RemoveNotificationObserver(NotificationObserver* observer);
132 148
133 // Adds or removes ARC app observers. This can only be called on the thread 149 // Adds or removes ARC app observers. This can only be called on the thread
134 // that this class was created on. 150 // that this class was created on.
135 void AddAppObserver(AppObserver* observer); 151 void AddAppObserver(AppObserver* observer);
136 void RemoveAppObserver(AppObserver* observer); 152 void RemoveAppObserver(AppObserver* observer);
137 153
138 // Gets the current state of the bridge service. 154 // Gets the current state of the bridge service.
139 State state() const { return state_; } 155 State state() const { return state_; }
140 156
141 // Gets if ARC is available in this system. 157 // Gets if ARC is available in this system.
142 bool available() const { return available_; } 158 bool available() const { return available_; }
143 159
144 // Requests registration of an input device on the ARC instance. 160 // Requests registration of an input device on the ARC instance.
145 // TODO(denniskempin): Make this interface more typesafe. 161 // TODO(denniskempin): Make this interface more typesafe.
146 // |name| should be the displayable name of the emulated device (e.g. "Chrome 162 // |name| should be the displayable name of the emulated device (e.g. "Chrome
147 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") 163 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard")
148 // and |fd| a file descriptor that emulates the kernel events of the device. 164 // and |fd| a file descriptor that emulates the kernel events of the device.
149 // This can only be called on the thread that this class was created on. 165 // This can only be called on the thread that this class was created on.
150 virtual bool RegisterInputDevice(const std::string& name, 166 virtual bool RegisterInputDevice(const std::string& name,
151 const std::string& device_type, 167 const std::string& device_type,
152 base::ScopedFD fd) = 0; 168 base::ScopedFD fd) = 0;
153 169
170 // Sends a notification event to Android side.
171 virtual bool SendNotificationEventToAndroid(const std::string& key,
172 ArcNotificationEvent event) = 0;
173
154 // Requests to refresh an app list. 174 // Requests to refresh an app list.
155 virtual bool RefreshAppList() = 0; 175 virtual bool RefreshAppList() = 0;
156 176
157 // Requests to launch an app. 177 // Requests to launch an app.
158 virtual bool LaunchApp(const std::string& package, 178 virtual bool LaunchApp(const std::string& package,
159 const std::string& activity) = 0; 179 const std::string& activity) = 0;
160 180
161 // Requests to load an icon of specific scale_factor. 181 // Requests to load an icon of specific scale_factor.
162 virtual bool RequestAppIcon(const std::string& package, 182 virtual bool RequestAppIcon(const std::string& package,
163 const std::string& activity, 183 const std::string& activity,
164 ScaleFactor scale_factor) = 0; 184 ScaleFactor scale_factor) = 0;
165 185
166 protected: 186 protected:
167 ArcBridgeService(); 187 ArcBridgeService();
168 188
169 // Changes the current state and notifies all observers. 189 // Changes the current state and notifies all observers.
170 void SetState(State state); 190 void SetState(State state);
171 191
172 // Changes the current availability and notifies all observers. 192 // Changes the current availability and notifies all observers.
173 void SetAvailable(bool availability); 193 void SetAvailable(bool availability);
174 194
175 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const { 195 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const {
176 return origin_task_runner_; 196 return origin_task_runner_;
177 } 197 }
178 198
179 base::ObserverList<Observer>& observer_list() { return observer_list_; } 199 base::ObserverList<Observer>& observer_list() { return observer_list_; }
200 base::ObserverList<NotificationObserver>& notification_observer_list() {
201 return notification_observer_list_;
202 }
180 203
181 base::ObserverList<AppObserver>& app_observer_list() { 204 base::ObserverList<AppObserver>& app_observer_list() {
182 return app_observer_list_; 205 return app_observer_list_;
183 } 206 }
184 207
185 private: 208 private:
186 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; 209 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_;
187 210
188 base::ObserverList<Observer> observer_list_; 211 base::ObserverList<Observer> observer_list_;
212 base::ObserverList<NotificationObserver> notification_observer_list_;
189 213
190 base::ObserverList<AppObserver> app_observer_list_; 214 base::ObserverList<AppObserver> app_observer_list_;
191 215
192 // If the ARC instance service is available. 216 // If the ARC instance service is available.
193 bool available_; 217 bool available_;
194 218
195 // The current state of the bridge. 219 // The current state of the bridge.
196 ArcBridgeService::State state_; 220 ArcBridgeService::State state_;
197 221
198 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 222 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
199 }; 223 };
200 224
201 } // namespace arc 225 } // namespace arc
202 226
203 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 227 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW
« no previous file with comments | « components/arc/BUILD.gn ('k') | components/arc/arc_bridge_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698