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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...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 when the Android clipboard content is changed. This is | |
117 // typically fired when a user initiates a "Copy" action. | |
118 virtual void OnSetClipboardContent(const std::string& text) {} | |
119 | |
120 // Called when the Android clipboard decides to update its content. | |
121 // This is triggered when a "Paste" action is fired or an app | |
122 // or a service tries to retrieve the Android clipboard content. | |
elijahtaylor1
2015/12/15 01:17:05
nit: alignment
cnwan
2015/12/21 11:18:00
Done.
| |
123 virtual void OnGetClipboardContent() {} | |
124 | |
125 protected: | |
126 virtual ~ClipboardObserver() {} | |
127 }; | |
128 | |
113 virtual ~ArcBridgeService(); | 129 virtual ~ArcBridgeService(); |
114 | 130 |
115 // Gets the global instance of the ARC Bridge Service. This can only be | 131 // Gets the global instance of the ARC Bridge Service. This can only be |
116 // called on the thread that this class was created on. | 132 // called on the thread that this class was created on. |
117 static ArcBridgeService* Get(); | 133 static ArcBridgeService* Get(); |
118 | 134 |
119 // Return true if ARC has been enabled through a commandline | 135 // Return true if ARC has been enabled through a commandline |
120 // switch. | 136 // switch. |
121 static bool GetEnabled(const base::CommandLine* command_line); | 137 static bool GetEnabled(const base::CommandLine* command_line); |
122 | 138 |
(...skipping 16 matching lines...) Expand all Loading... | |
139 void AddObserver(Observer* observer); | 155 void AddObserver(Observer* observer); |
140 void RemoveObserver(Observer* observer); | 156 void RemoveObserver(Observer* observer); |
141 void AddNotificationObserver(NotificationObserver* observer); | 157 void AddNotificationObserver(NotificationObserver* observer); |
142 void RemoveNotificationObserver(NotificationObserver* observer); | 158 void RemoveNotificationObserver(NotificationObserver* observer); |
143 | 159 |
144 // Adds or removes ARC app observers. This can only be called on the thread | 160 // Adds or removes ARC app observers. This can only be called on the thread |
145 // that this class was created on. | 161 // that this class was created on. |
146 void AddAppObserver(AppObserver* observer); | 162 void AddAppObserver(AppObserver* observer); |
147 void RemoveAppObserver(AppObserver* observer); | 163 void RemoveAppObserver(AppObserver* observer); |
148 | 164 |
165 // Adds or removes ARC clipboard observers. This can only be called on the | |
166 // thread that this class was created on. | |
167 void AddClipboardObserver(ClipboardObserver* observer); | |
168 void RemoveClipboardObserver(ClipboardObserver* observer); | |
169 | |
149 // Gets the current state of the bridge service. | 170 // Gets the current state of the bridge service. |
150 State state() const { return state_; } | 171 State state() const { return state_; } |
151 | 172 |
152 // Gets if ARC is available in this system. | 173 // Gets if ARC is available in this system. |
153 bool available() const { return available_; } | 174 bool available() const { return available_; } |
154 | 175 |
155 // Requests registration of an input device on the ARC instance. | 176 // Requests registration of an input device on the ARC instance. |
156 // TODO(denniskempin): Make this interface more typesafe. | 177 // TODO(denniskempin): Make this interface more typesafe. |
157 // |name| should be the displayable name of the emulated device (e.g. "Chrome | 178 // |name| should be the displayable name of the emulated device (e.g. "Chrome |
158 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") | 179 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") |
(...skipping 12 matching lines...) Expand all Loading... | |
171 | 192 |
172 // Requests to launch an app. | 193 // Requests to launch an app. |
173 virtual bool LaunchApp(const std::string& package, | 194 virtual bool LaunchApp(const std::string& package, |
174 const std::string& activity) = 0; | 195 const std::string& activity) = 0; |
175 | 196 |
176 // Requests to load an icon of specific scale_factor. | 197 // Requests to load an icon of specific scale_factor. |
177 virtual bool RequestAppIcon(const std::string& package, | 198 virtual bool RequestAppIcon(const std::string& package, |
178 const std::string& activity, | 199 const std::string& activity, |
179 ScaleFactor scale_factor) = 0; | 200 ScaleFactor scale_factor) = 0; |
180 | 201 |
202 // Sends the Chrome clipboard content to Android. | |
203 virtual bool SendClipboardContentToAndroid(const std::string& text) = 0; | |
204 | |
181 protected: | 205 protected: |
182 ArcBridgeService(); | 206 ArcBridgeService(); |
183 | 207 |
184 // Changes the current state and notifies all observers. | 208 // Changes the current state and notifies all observers. |
185 void SetState(State state); | 209 void SetState(State state); |
186 | 210 |
187 // Changes the current availability and notifies all observers. | 211 // Changes the current availability and notifies all observers. |
188 void SetAvailable(bool availability); | 212 void SetAvailable(bool availability); |
189 | 213 |
190 base::ObserverList<Observer>& observer_list() { return observer_list_; } | 214 base::ObserverList<Observer>& observer_list() { return observer_list_; } |
215 | |
191 base::ObserverList<NotificationObserver>& notification_observer_list() { | 216 base::ObserverList<NotificationObserver>& notification_observer_list() { |
192 return notification_observer_list_; | 217 return notification_observer_list_; |
193 } | 218 } |
194 | 219 |
220 base::ObserverList<ClipboardObserver>& clipboard_observer_list() { | |
221 return clipboard_observer_list_; | |
222 } | |
223 | |
195 base::ObserverList<AppObserver>& app_observer_list() { | 224 base::ObserverList<AppObserver>& app_observer_list() { |
196 return app_observer_list_; | 225 return app_observer_list_; |
197 } | 226 } |
198 | 227 |
199 bool CalledOnValidThread(); | 228 bool CalledOnValidThread(); |
200 | 229 |
201 private: | 230 private: |
202 friend class ArcBridgeTest; | 231 friend class ArcBridgeTest; |
203 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 232 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
204 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 233 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
205 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 234 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
206 | 235 |
207 base::ObserverList<Observer> observer_list_; | 236 base::ObserverList<Observer> observer_list_; |
208 base::ObserverList<NotificationObserver> notification_observer_list_; | 237 base::ObserverList<NotificationObserver> notification_observer_list_; |
209 | 238 base::ObserverList<ClipboardObserver> clipboard_observer_list_; |
210 base::ObserverList<AppObserver> app_observer_list_; | 239 base::ObserverList<AppObserver> app_observer_list_; |
211 | 240 |
212 base::ThreadChecker thread_checker_; | 241 base::ThreadChecker thread_checker_; |
213 | 242 |
214 // If the ARC instance service is available. | 243 // If the ARC instance service is available. |
215 bool available_; | 244 bool available_; |
216 | 245 |
217 // The current state of the bridge. | 246 // The current state of the bridge. |
218 ArcBridgeService::State state_; | 247 ArcBridgeService::State state_; |
219 | 248 |
220 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 249 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
221 }; | 250 }; |
222 | 251 |
223 } // namespace arc | 252 } // namespace arc |
224 | 253 |
225 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 254 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
OLD | NEW |