OLD | NEW |
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" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Called whenever ARC sends app icon data for specific scale factor. | 103 // Called whenever ARC sends app icon data for specific scale factor. |
104 virtual void OnAppIcon(const std::string& package, | 104 virtual void OnAppIcon(const std::string& package, |
105 const std::string& activity, | 105 const std::string& activity, |
106 ScaleFactor scale_factor, | 106 ScaleFactor scale_factor, |
107 const std::vector<uint8_t>& icon_png_data) {} | 107 const std::vector<uint8_t>& icon_png_data) {} |
108 | 108 |
109 protected: | 109 protected: |
110 virtual ~AppObserver() {} | 110 virtual ~AppObserver() {} |
111 }; | 111 }; |
112 | 112 |
| 113 // Notifies ARC Clipboard related events. |
| 114 class ClipboardObserver { |
| 115 public: |
| 116 // Called whenever the Android clipboard content is changed. This is |
| 117 // typically fired when a user initiates a "Copy" action. |
| 118 virtual void OnSetClipboardContent(const ClipboardData& data) {} |
| 119 |
| 120 // Called whenever the Android clipboard decides to update its content. |
| 121 // This is typical triggered when a "Paste" action is fired or an app |
| 122 // or service tries to retrieve the android clipboard content. |
| 123 virtual void OnGetClipboardContent() {} |
| 124 |
| 125 protected: |
| 126 virtual ~ClipboardObserver() {} |
| 127 }; |
| 128 |
113 virtual ~ArcBridgeService(); | 129 virtual ~ArcBridgeService(); |
114 | 130 |
115 // Creates instance of |ArcBridgeService| for normal use. | 131 // Creates instance of |ArcBridgeService| for normal use. |
116 static scoped_ptr<ArcBridgeService> Create( | 132 static scoped_ptr<ArcBridgeService> Create( |
117 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | 133 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
118 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); | 134 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); |
119 | 135 |
120 // Gets the global instance of the ARC Bridge Service. This can only be | 136 // Gets the global instance of the ARC Bridge Service. This can only be |
121 // called on the thread that this class was created on. | 137 // called on the thread that this class was created on. |
122 static ArcBridgeService* Get(); | 138 static ArcBridgeService* Get(); |
(...skipping 21 matching lines...) Expand all Loading... |
144 void AddObserver(Observer* observer); | 160 void AddObserver(Observer* observer); |
145 void RemoveObserver(Observer* observer); | 161 void RemoveObserver(Observer* observer); |
146 void AddNotificationObserver(NotificationObserver* observer); | 162 void AddNotificationObserver(NotificationObserver* observer); |
147 void RemoveNotificationObserver(NotificationObserver* observer); | 163 void RemoveNotificationObserver(NotificationObserver* observer); |
148 | 164 |
149 // Adds or removes ARC app observers. This can only be called on the thread | 165 // Adds or removes ARC app observers. This can only be called on the thread |
150 // that this class was created on. | 166 // that this class was created on. |
151 void AddAppObserver(AppObserver* observer); | 167 void AddAppObserver(AppObserver* observer); |
152 void RemoveAppObserver(AppObserver* observer); | 168 void RemoveAppObserver(AppObserver* observer); |
153 | 169 |
| 170 // Adds or removes ARC clipboard observers. This can only be called on the |
| 171 // thread that this class was created on. |
| 172 void AddClipboardObserver(ClipboardObserver* observer); |
| 173 void RemoveClipboardObserver(ClipboardObserver* observer); |
| 174 |
154 // Gets the current state of the bridge service. | 175 // Gets the current state of the bridge service. |
155 State state() const { return state_; } | 176 State state() const { return state_; } |
156 | 177 |
157 // Gets if ARC is available in this system. | 178 // Gets if ARC is available in this system. |
158 bool available() const { return available_; } | 179 bool available() const { return available_; } |
159 | 180 |
160 // Requests registration of an input device on the ARC instance. | 181 // Requests registration of an input device on the ARC instance. |
161 // TODO(denniskempin): Make this interface more typesafe. | 182 // TODO(denniskempin): Make this interface more typesafe. |
162 // |name| should be the displayable name of the emulated device (e.g. "Chrome | 183 // |name| should be the displayable name of the emulated device (e.g. "Chrome |
163 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") | 184 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") |
(...skipping 12 matching lines...) Expand all Loading... |
176 | 197 |
177 // Requests to launch an app. | 198 // Requests to launch an app. |
178 virtual bool LaunchApp(const std::string& package, | 199 virtual bool LaunchApp(const std::string& package, |
179 const std::string& activity) = 0; | 200 const std::string& activity) = 0; |
180 | 201 |
181 // Requests to load an icon of specific scale_factor. | 202 // Requests to load an icon of specific scale_factor. |
182 virtual bool RequestAppIcon(const std::string& package, | 203 virtual bool RequestAppIcon(const std::string& package, |
183 const std::string& activity, | 204 const std::string& activity, |
184 ScaleFactor scale_factor) = 0; | 205 ScaleFactor scale_factor) = 0; |
185 | 206 |
| 207 // Sends the Chrome clipboard content to Android side. |
| 208 virtual bool SendClipboardContentToAndroid(const ClipboardData data) = 0; |
| 209 |
186 protected: | 210 protected: |
187 ArcBridgeService(); | 211 ArcBridgeService(); |
188 | 212 |
189 // Changes the current state and notifies all observers. | 213 // Changes the current state and notifies all observers. |
190 void SetState(State state); | 214 void SetState(State state); |
191 | 215 |
192 // Changes the current availability and notifies all observers. | 216 // Changes the current availability and notifies all observers. |
193 void SetAvailable(bool availability); | 217 void SetAvailable(bool availability); |
194 | 218 |
195 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const { | 219 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const { |
196 return origin_task_runner_; | 220 return origin_task_runner_; |
197 } | 221 } |
198 | 222 |
199 base::ObserverList<Observer>& observer_list() { return observer_list_; } | 223 base::ObserverList<Observer>& observer_list() { return observer_list_; } |
| 224 |
200 base::ObserverList<NotificationObserver>& notification_observer_list() { | 225 base::ObserverList<NotificationObserver>& notification_observer_list() { |
201 return notification_observer_list_; | 226 return notification_observer_list_; |
202 } | 227 } |
203 | 228 |
| 229 base::ObserverList<ClipboardObserver>& clipboard_observer_list() { |
| 230 return clipboard_observer_list_; |
| 231 } |
| 232 |
204 base::ObserverList<AppObserver>& app_observer_list() { | 233 base::ObserverList<AppObserver>& app_observer_list() { |
205 return app_observer_list_; | 234 return app_observer_list_; |
206 } | 235 } |
207 | 236 |
208 private: | 237 private: |
209 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; | 238 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
210 | 239 |
211 base::ObserverList<Observer> observer_list_; | 240 base::ObserverList<Observer> observer_list_; |
212 base::ObserverList<NotificationObserver> notification_observer_list_; | 241 base::ObserverList<NotificationObserver> notification_observer_list_; |
213 | 242 |
214 base::ObserverList<AppObserver> app_observer_list_; | 243 base::ObserverList<AppObserver> app_observer_list_; |
215 | 244 |
| 245 base::ObserverList<ClipboardObserver> clipboard_observer_list_; |
| 246 |
216 // If the ARC instance service is available. | 247 // If the ARC instance service is available. |
217 bool available_; | 248 bool available_; |
218 | 249 |
219 // The current state of the bridge. | 250 // The current state of the bridge. |
220 ArcBridgeService::State state_; | 251 ArcBridgeService::State state_; |
221 | 252 |
222 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 253 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
223 }; | 254 }; |
224 | 255 |
225 } // namespace arc | 256 } // namespace arc |
226 | 257 |
227 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 258 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
OLD | NEW |