OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TODO(ajwong): We need to come up with a better description of the | 5 // TODO(ajwong): We need to come up with a better description of the |
6 // responsibilities for each thread. | 6 // responsibilities for each thread. |
7 | 7 |
8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_rect.h" | 17 #include "ppapi/c/pp_rect.h" |
18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
19 #include "ppapi/cpp/instance.h" | 19 #include "ppapi/cpp/instance.h" |
20 #include "ppapi/cpp/mouse_lock.h" | |
21 #include "ppapi/cpp/point.h" | |
20 #include "ppapi/cpp/var.h" | 22 #include "ppapi/cpp/var.h" |
23 #include "ppapi/utility/completion_callback_factory.h" | |
21 #include "remoting/client/client_context.h" | 24 #include "remoting/client/client_context.h" |
22 #include "remoting/client/client_user_interface.h" | 25 #include "remoting/client/client_user_interface.h" |
23 #include "remoting/client/key_event_mapper.h" | 26 #include "remoting/client/key_event_mapper.h" |
24 #include "remoting/client/plugin/normalizing_input_filter.h" | 27 #include "remoting/client/plugin/normalizing_input_filter.h" |
25 #include "remoting/client/plugin/pepper_input_handler.h" | 28 #include "remoting/client/plugin/pepper_input_handler.h" |
26 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" | 29 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" |
27 #include "remoting/proto/event.pb.h" | 30 #include "remoting/proto/event.pb.h" |
28 #include "remoting/protocol/client_stub.h" | 31 #include "remoting/protocol/client_stub.h" |
29 #include "remoting/protocol/clipboard_stub.h" | 32 #include "remoting/protocol/clipboard_stub.h" |
30 #include "remoting/protocol/connection_to_host.h" | 33 #include "remoting/protocol/connection_to_host.h" |
31 #include "remoting/protocol/cursor_shape_stub.h" | 34 #include "remoting/protocol/cursor_shape_stub.h" |
32 #include "remoting/protocol/input_event_tracker.h" | 35 #include "remoting/protocol/input_event_tracker.h" |
33 #include "remoting/protocol/mouse_input_filter.h" | 36 #include "remoting/protocol/mouse_input_filter.h" |
34 #include "remoting/protocol/negotiating_client_authenticator.h" | 37 #include "remoting/protocol/negotiating_client_authenticator.h" |
35 #include "remoting/protocol/third_party_client_authenticator.h" | 38 #include "remoting/protocol/third_party_client_authenticator.h" |
36 #include "third_party/skia/include/core/SkPoint.h" | 39 #include "third_party/skia/include/core/SkPoint.h" |
37 #include "third_party/skia/include/core/SkRegion.h" | 40 #include "third_party/skia/include/core/SkRegion.h" |
38 #include "third_party/skia/include/core/SkSize.h" | 41 #include "third_party/skia/include/core/SkSize.h" |
39 | 42 |
40 namespace base { | 43 namespace base { |
41 class DictionaryValue; | 44 class DictionaryValue; |
42 } // namespace base | 45 } // namespace base |
43 | 46 |
44 namespace pp { | 47 namespace pp { |
48 class ImageData; | |
45 class InputEvent; | 49 class InputEvent; |
46 class Module; | 50 class Module; |
47 } // namespace pp | 51 } // namespace pp |
48 | 52 |
49 namespace remoting { | 53 namespace remoting { |
50 | 54 |
51 class ChromotingClient; | 55 class ChromotingClient; |
52 class ChromotingStats; | 56 class ChromotingStats; |
53 class ClientContext; | 57 class ClientContext; |
54 class DelegatingSignalStrategy; | 58 class DelegatingSignalStrategy; |
55 class FrameConsumer; | 59 class FrameConsumer; |
56 class FrameConsumerProxy; | 60 class FrameConsumerProxy; |
57 class PepperAudioPlayer; | 61 class PepperAudioPlayer; |
58 class PepperTokenFetcher; | 62 class PepperTokenFetcher; |
59 class PepperView; | 63 class PepperView; |
60 class RectangleUpdateDecoder; | 64 class RectangleUpdateDecoder; |
61 class SignalStrategy; | 65 class SignalStrategy; |
62 | 66 |
63 struct ClientConfig; | 67 struct ClientConfig; |
64 | 68 |
65 class ChromotingInstance : | 69 class ChromotingInstance : |
66 public ClientUserInterface, | 70 public ClientUserInterface, |
67 public protocol::ClipboardStub, | 71 public protocol::ClipboardStub, |
68 public protocol::CursorShapeStub, | 72 public protocol::CursorShapeStub, |
69 public pp::Instance { | 73 public pp::Instance, |
74 public pp::MouseLock { | |
Wez
2013/09/05 21:19:38
Have you considered having PepperInputHandler deri
alexeypa (please no reviews)
2013/09/06 20:00:17
Done. Moved it to PepperInputHandler.
| |
70 public: | 75 public: |
71 // Plugin API version. This should be incremented whenever the API | 76 // Plugin API version. This should be incremented whenever the API |
72 // interface changes. | 77 // interface changes. |
73 static const int kApiVersion = 7; | 78 static const int kApiVersion = 7; |
74 | 79 |
75 // Plugin API features. This allows orthogonal features to be supported | 80 // Plugin API features. This allows orthogonal features to be supported |
76 // without bumping the API version. | 81 // without bumping the API version. |
77 static const char kApiFeatures[]; | 82 static const char kApiFeatures[]; |
78 | 83 |
79 // Capabilities supported by the plugin that should also be supported by the | 84 // Capabilities supported by the plugin that should also be supported by the |
(...skipping 15 matching lines...) Expand all Loading... | |
95 static const int kApiMinScriptableVersion = 5; | 100 static const int kApiMinScriptableVersion = 5; |
96 | 101 |
97 // Helper method to parse authentication_methods parameter. | 102 // Helper method to parse authentication_methods parameter. |
98 static bool ParseAuthMethods(const std::string& auth_methods, | 103 static bool ParseAuthMethods(const std::string& auth_methods, |
99 ClientConfig* config); | 104 ClientConfig* config); |
100 | 105 |
101 explicit ChromotingInstance(PP_Instance instance); | 106 explicit ChromotingInstance(PP_Instance instance); |
102 virtual ~ChromotingInstance(); | 107 virtual ~ChromotingInstance(); |
103 | 108 |
104 // pp::Instance interface. | 109 // pp::Instance interface. |
110 virtual void DidChangeFocus(bool has_focus) OVERRIDE; | |
105 virtual void DidChangeView(const pp::View& view) OVERRIDE; | 111 virtual void DidChangeView(const pp::View& view) OVERRIDE; |
106 virtual bool Init(uint32_t argc, const char* argn[], | 112 virtual bool Init(uint32_t argc, const char* argn[], |
107 const char* argv[]) OVERRIDE; | 113 const char* argv[]) OVERRIDE; |
108 virtual void HandleMessage(const pp::Var& message) OVERRIDE; | 114 virtual void HandleMessage(const pp::Var& message) OVERRIDE; |
109 virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE; | 115 virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE; |
110 | 116 |
117 // pp::MouseLock interface. | |
118 virtual void MouseLockLost() OVERRIDE; | |
119 | |
111 // ClientUserInterface interface. | 120 // ClientUserInterface interface. |
112 virtual void OnConnectionState(protocol::ConnectionToHost::State state, | 121 virtual void OnConnectionState(protocol::ConnectionToHost::State state, |
113 protocol::ErrorCode error) OVERRIDE; | 122 protocol::ErrorCode error) OVERRIDE; |
114 virtual void OnConnectionReady(bool ready) OVERRIDE; | 123 virtual void OnConnectionReady(bool ready) OVERRIDE; |
115 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; | 124 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; |
116 virtual void SetPairingResponse( | 125 virtual void SetPairingResponse( |
117 const protocol::PairingResponse& pairing_response) OVERRIDE; | 126 const protocol::PairingResponse& pairing_response) OVERRIDE; |
118 virtual void DeliverHostMessage( | 127 virtual void DeliverHostMessage( |
119 const protocol::ExtensionMessage& message) OVERRIDE; | 128 const protocol::ExtensionMessage& message) OVERRIDE; |
120 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; | 129 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 void HandleRemapKey(const base::DictionaryValue& data); | 197 void HandleRemapKey(const base::DictionaryValue& data); |
189 void HandleTrapKey(const base::DictionaryValue& data); | 198 void HandleTrapKey(const base::DictionaryValue& data); |
190 void HandleSendClipboardItem(const base::DictionaryValue& data); | 199 void HandleSendClipboardItem(const base::DictionaryValue& data); |
191 void HandleNotifyClientResolution(const base::DictionaryValue& data); | 200 void HandleNotifyClientResolution(const base::DictionaryValue& data); |
192 void HandlePauseVideo(const base::DictionaryValue& data); | 201 void HandlePauseVideo(const base::DictionaryValue& data); |
193 void HandlePauseAudio(const base::DictionaryValue& data); | 202 void HandlePauseAudio(const base::DictionaryValue& data); |
194 void HandleOnPinFetched(const base::DictionaryValue& data); | 203 void HandleOnPinFetched(const base::DictionaryValue& data); |
195 void HandleOnThirdPartyTokenFetched(const base::DictionaryValue& data); | 204 void HandleOnThirdPartyTokenFetched(const base::DictionaryValue& data); |
196 void HandleRequestPairing(const base::DictionaryValue& data); | 205 void HandleRequestPairing(const base::DictionaryValue& data); |
197 void HandleExtensionMessage(const base::DictionaryValue& data); | 206 void HandleExtensionMessage(const base::DictionaryValue& data); |
207 void HandleAllowMouseLockMessage(); | |
198 | 208 |
199 // Helper method called from Connect() to connect with parsed config. | 209 // Helper method called from Connect() to connect with parsed config. |
200 void ConnectWithConfig(const ClientConfig& config, | 210 void ConnectWithConfig(const ClientConfig& config, |
201 const std::string& local_jid); | 211 const std::string& local_jid); |
202 | 212 |
203 // Helper method to post messages to the webapp. | 213 // Helper method to post messages to the webapp. |
204 void PostChromotingMessage(const std::string& method, | 214 void PostChromotingMessage(const std::string& method, |
205 scoped_ptr<base::DictionaryValue> data); | 215 scoped_ptr<base::DictionaryValue> data); |
206 | 216 |
207 // Posts trapped keys to the web-app to handle. | 217 // Posts trapped keys to the web-app to handle. |
(...skipping 11 matching lines...) Expand all Loading... | |
219 | 229 |
220 // Returns true if there is a ConnectionToHost and it is connected. | 230 // Returns true if there is a ConnectionToHost and it is connected. |
221 bool IsConnected(); | 231 bool IsConnected(); |
222 | 232 |
223 // Used as the |FetchSecretCallback| for Me2Me connections. | 233 // Used as the |FetchSecretCallback| for Me2Me connections. |
224 // Uses the PIN request dialog in the webapp to obtain the shared secret. | 234 // Uses the PIN request dialog in the webapp to obtain the shared secret. |
225 void FetchSecretFromDialog( | 235 void FetchSecretFromDialog( |
226 bool pairing_supported, | 236 bool pairing_supported, |
227 const protocol::SecretFetchedCallback& secret_fetched_callback); | 237 const protocol::SecretFetchedCallback& secret_fetched_callback); |
228 | 238 |
239 // Applies |cursor_image_| as the custom pointer or uses the standard arrow | |
240 // pointer if |cursor_image_| is not available. | |
241 void EnableMousePointer(); | |
242 | |
243 // Requests the browser to lock the mouse and hides the cursor. | |
244 void RequestMouseLock(); | |
245 | |
246 // Request the browser and restores the cursor once the lock is gone. | |
Wez
2013/09/05 20:24:45
This wording seems b0rked!
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
247 void CancelMouseLock(); | |
248 | |
249 // Called when the browser locked the mouse. | |
Wez
2013/09/05 20:24:45
nit: Does this take any action? Is this also calle
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
250 void OnMouseLocked(int error); | |
251 | |
229 bool initialized_; | 252 bool initialized_; |
230 | 253 |
231 PepperPluginThreadDelegate plugin_thread_delegate_; | 254 PepperPluginThreadDelegate plugin_thread_delegate_; |
232 scoped_refptr<PluginThreadTaskRunner> plugin_task_runner_; | 255 scoped_refptr<PluginThreadTaskRunner> plugin_task_runner_; |
233 ClientContext context_; | 256 ClientContext context_; |
234 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; | 257 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; |
235 scoped_ptr<PepperView> view_; | 258 scoped_ptr<PepperView> view_; |
236 scoped_ptr<base::WeakPtrFactory<FrameConsumer> > view_weak_factory_; | 259 scoped_ptr<base::WeakPtrFactory<FrameConsumer> > view_weak_factory_; |
237 pp::View plugin_view_; | 260 pp::View plugin_view_; |
238 | 261 |
262 // True if the plugin is focused. | |
Wez
2013/09/05 20:24:45
nit: has focus.
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
263 bool focused_; | |
Wez
2013/09/05 20:24:45
nit: has_focus_;
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
264 | |
265 // Custom cursor image sent by the host. When mouse lock is requested | |
266 // |cursor_image_| is set to NULL. | |
Wez
2013/09/05 20:24:45
Why is this set to NULL when mouse-lock is request
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
267 scoped_ptr<pp::ImageData> cursor_image_; | |
268 | |
269 // Hot spot for |cursor_image_|. | |
270 pp::Point cursor_hotspot_; | |
271 | |
272 enum MouseLockState { | |
273 MouseLockDisabled, | |
Wez
2013/09/05 20:24:45
nit: You've called this state "Disabled", but it's
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
274 MouseLockOff, | |
275 MouseLockPending, | |
Wez
2013/09/05 20:24:45
nit: MouseLockRequested or MouseLockRequestPending
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
276 MouseLockOn, | |
277 MouseLockCancelling | |
278 }; | |
279 | |
280 MouseLockState mouse_lock_state_; | |
281 | |
239 // Contains the most-recently-reported desktop shape, if any. | 282 // Contains the most-recently-reported desktop shape, if any. |
240 scoped_ptr<SkRegion> desktop_shape_; | 283 scoped_ptr<SkRegion> desktop_shape_; |
241 | 284 |
242 scoped_ptr<DelegatingSignalStrategy> signal_strategy_; | 285 scoped_ptr<DelegatingSignalStrategy> signal_strategy_; |
243 | 286 |
244 scoped_ptr<protocol::ConnectionToHost> host_connection_; | 287 scoped_ptr<protocol::ConnectionToHost> host_connection_; |
245 scoped_ptr<ChromotingClient> client_; | 288 scoped_ptr<ChromotingClient> client_; |
246 | 289 |
247 // Input pipeline components, in reverse order of distance from input source. | 290 // Input pipeline components, in reverse order of distance from input source. |
248 protocol::MouseInputFilter mouse_input_filter_; | 291 protocol::MouseInputFilter mouse_input_filter_; |
249 protocol::InputEventTracker input_tracker_; | 292 protocol::InputEventTracker input_tracker_; |
250 KeyEventMapper key_mapper_; | 293 KeyEventMapper key_mapper_; |
251 scoped_ptr<protocol::InputFilter> normalizing_input_filter_; | 294 scoped_ptr<protocol::InputFilter> normalizing_input_filter_; |
252 PepperInputHandler input_handler_; | 295 PepperInputHandler input_handler_; |
253 | 296 |
254 // PIN Fetcher. | 297 // PIN Fetcher. |
255 bool use_async_pin_dialog_; | 298 bool use_async_pin_dialog_; |
256 protocol::SecretFetchedCallback secret_fetched_callback_; | 299 protocol::SecretFetchedCallback secret_fetched_callback_; |
257 | 300 |
258 base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher_; | 301 base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher_; |
259 | 302 |
303 pp::CompletionCallbackFactory<ChromotingInstance> callback_factory_; | |
304 | |
260 // Weak reference to this instance, used for global logging and task posting. | 305 // Weak reference to this instance, used for global logging and task posting. |
261 base::WeakPtrFactory<ChromotingInstance> weak_factory_; | 306 base::WeakPtrFactory<ChromotingInstance> weak_factory_; |
262 | 307 |
263 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); | 308 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); |
264 }; | 309 }; |
265 | 310 |
266 } // namespace remoting | 311 } // namespace remoting |
267 | 312 |
268 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 313 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
OLD | NEW |