Chromium Code Reviews| 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 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "remoting/client/key_event_mapper.h" | 32 #include "remoting/client/key_event_mapper.h" |
| 33 #include "remoting/client/plugin/mac_key_event_processor.h" | 33 #include "remoting/client/plugin/mac_key_event_processor.h" |
| 34 #include "remoting/client/plugin/pepper_input_handler.h" | 34 #include "remoting/client/plugin/pepper_input_handler.h" |
| 35 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" | 35 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" |
| 36 #include "remoting/proto/event.pb.h" | 36 #include "remoting/proto/event.pb.h" |
| 37 #include "remoting/protocol/clipboard_stub.h" | 37 #include "remoting/protocol/clipboard_stub.h" |
| 38 #include "remoting/protocol/connection_to_host.h" | 38 #include "remoting/protocol/connection_to_host.h" |
| 39 #include "remoting/protocol/cursor_shape_stub.h" | 39 #include "remoting/protocol/cursor_shape_stub.h" |
| 40 #include "remoting/protocol/input_event_tracker.h" | 40 #include "remoting/protocol/input_event_tracker.h" |
| 41 #include "remoting/protocol/mouse_input_filter.h" | 41 #include "remoting/protocol/mouse_input_filter.h" |
| 42 #include "remoting/protocol/negotiating_authenticator.h" | |
| 42 | 43 |
| 43 namespace base { | 44 namespace base { |
| 44 class DictionaryValue; | 45 class DictionaryValue; |
| 45 } // namespace base | 46 } // namespace base |
| 46 | 47 |
| 47 namespace pp { | 48 namespace pp { |
| 48 class InputEvent; | 49 class InputEvent; |
| 49 class Module; | 50 class Module; |
| 50 } // namespace pp | 51 } // namespace pp |
| 51 | 52 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 const protocol::ClipboardEvent& event) OVERRIDE; | 114 const protocol::ClipboardEvent& event) OVERRIDE; |
| 114 | 115 |
| 115 // protocol::CursorShapeStub interface. | 116 // protocol::CursorShapeStub interface. |
| 116 virtual void SetCursorShape( | 117 virtual void SetCursorShape( |
| 117 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE; | 118 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE; |
| 118 | 119 |
| 119 // Called by PepperView. | 120 // Called by PepperView. |
| 120 void SetDesktopSize(const SkISize& size, const SkIPoint& dpi); | 121 void SetDesktopSize(const SkISize& size, const SkIPoint& dpi); |
| 121 void OnFirstFrameReceived(); | 122 void OnFirstFrameReceived(); |
| 122 | 123 |
| 123 // Message handlers for messages that come from JavaScript. Called | |
| 124 // from HandleMessage(). | |
| 125 void Connect(const ClientConfig& config); | |
| 126 void Disconnect(); | |
| 127 void OnIncomingIq(const std::string& iq); | |
| 128 void ReleaseAllKeys(); | |
| 129 void InjectKeyEvent(const protocol::KeyEvent& event); | |
| 130 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode); | |
| 131 void TrapKey(uint32 usb_keycode, bool trap); | |
| 132 void SendClipboardItem(const std::string& mime_type, const std::string& item); | |
| 133 void NotifyClientResolution(int width, int height, int x_dpi, int y_dpi); | |
| 134 void PauseVideo(bool pause); | |
| 135 void PauseAudio(bool pause); | |
| 136 | |
| 137 // Return statistics record by ChromotingClient. | 124 // Return statistics record by ChromotingClient. |
| 138 // If no connection is currently active then NULL will be returned. | 125 // If no connection is currently active then NULL will be returned. |
| 139 ChromotingStats* GetStats(); | 126 ChromotingStats* GetStats(); |
| 140 | 127 |
| 141 // Registers a global log message handler that redirects the log output to | 128 // Registers a global log message handler that redirects the log output to |
| 142 // our plugin instance. | 129 // our plugin instance. |
| 143 // This is called by the plugin's PPP_InitializeModule. | 130 // This is called by the plugin's PPP_InitializeModule. |
| 144 // Note that no logging will be processed unless a ChromotingInstance has been | 131 // Note that no logging will be processed unless a ChromotingInstance has been |
| 145 // registered for logging (see RegisterLoggingInstance). | 132 // registered for logging (see RegisterLoggingInstance). |
| 146 static void RegisterLogMessageHandler(); | 133 static void RegisterLogMessageHandler(); |
| 147 | 134 |
| 148 // Registers this instance so it processes messages sent by the global log | 135 // Registers this instance so it processes messages sent by the global log |
| 149 // message handler. This overwrites any previously registered instance. | 136 // message handler. This overwrites any previously registered instance. |
| 150 void RegisterLoggingInstance(); | 137 void RegisterLoggingInstance(); |
| 151 | 138 |
| 152 // Unregisters this instance so that debug log messages will no longer be sent | 139 // Unregisters this instance so that debug log messages will no longer be sent |
| 153 // to it. If this instance is not the currently registered logging instance, | 140 // to it. If this instance is not the currently registered logging instance, |
| 154 // then the currently registered instance will stay in effect. | 141 // then the currently registered instance will stay in effect. |
| 155 void UnregisterLoggingInstance(); | 142 void UnregisterLoggingInstance(); |
| 156 | 143 |
| 157 // A Log Message Handler that is called after each LOG message has been | 144 // A Log Message Handler that is called after each LOG message has been |
| 158 // processed. This must be of type LogMessageHandlerFunction defined in | 145 // processed. This must be of type LogMessageHandlerFunction defined in |
| 159 // base/logging.h. | 146 // base/logging.h. |
| 160 static bool LogToUI(int severity, const char* file, int line, | 147 static bool LogToUI(int severity, const char* file, int line, |
| 161 size_t message_start, const std::string& str); | 148 size_t message_start, const std::string& str); |
| 162 | 149 |
| 163 private: | 150 private: |
| 164 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); | 151 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); |
| 165 | 152 |
| 153 // Immediately calls |secret_fetched_callback| with |shared_secret| | |
|
Sergey Ulanov
2013/03/20 20:33:40
Explain what this is used for. Also need period at
rmsousa
2013/03/20 20:50:35
Done.
| |
| 154 static void FetchSecretFromString( | |
| 155 const std::string& shared_secret, | |
| 156 const protocol::SecretFetchedCallback& secret_fetched_callback); | |
| 157 | |
| 158 // Message handlers for messages that come from JavaScript. Called | |
| 159 // from HandleMessage(). | |
| 160 void Connect(const ClientConfig& config); | |
| 161 void Disconnect(); | |
| 162 void OnIncomingIq(const std::string& iq); | |
| 163 void ReleaseAllKeys(); | |
| 164 void InjectKeyEvent(const protocol::KeyEvent& event); | |
| 165 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode); | |
| 166 void TrapKey(uint32 usb_keycode, bool trap); | |
| 167 void SendClipboardItem(const std::string& mime_type, const std::string& item); | |
| 168 void NotifyClientResolution(int width, int height, int x_dpi, int y_dpi); | |
| 169 void PauseVideo(bool pause); | |
| 170 void PauseAudio(bool pause); | |
| 171 void OnPinFetched(const std::string& pin); | |
| 172 | |
| 166 // Helper method to post messages to the webapp. | 173 // Helper method to post messages to the webapp. |
| 167 void PostChromotingMessage(const std::string& method, | 174 void PostChromotingMessage(const std::string& method, |
| 168 scoped_ptr<base::DictionaryValue> data); | 175 scoped_ptr<base::DictionaryValue> data); |
| 169 | 176 |
| 170 // Posts trapped keys to the web-app to handle. | 177 // Posts trapped keys to the web-app to handle. |
| 171 void SendTrappedKey(uint32 usb_keycode, bool pressed); | 178 void SendTrappedKey(uint32 usb_keycode, bool pressed); |
| 172 | 179 |
| 173 // Callback for PepperXmppProxy. | 180 // Callback for PepperXmppProxy. |
| 174 void SendOutgoingIq(const std::string& iq); | 181 void SendOutgoingIq(const std::string& iq); |
| 175 | 182 |
| 176 void SendPerfStats(); | 183 void SendPerfStats(); |
| 177 | 184 |
| 178 void ProcessLogToUI(const std::string& message); | 185 void ProcessLogToUI(const std::string& message); |
| 179 | 186 |
| 180 // Returns true if the hosting content has the chrome-extension:// scheme. | 187 // Returns true if the hosting content has the chrome-extension:// scheme. |
| 181 bool IsCallerAppOrExtension(); | 188 bool IsCallerAppOrExtension(); |
| 182 | 189 |
| 183 // Returns true if there is a ConnectionToHost and it is connected. | 190 // Returns true if there is a ConnectionToHost and it is connected. |
| 184 bool IsConnected(); | 191 bool IsConnected(); |
| 185 | 192 |
| 193 // Uses the PIN request dialog in the webapp to obtain the shared secret. | |
| 194 void FetchSecretFromDialog( | |
| 195 const protocol::SecretFetchedCallback& secret_fetched_callback); | |
| 196 | |
| 186 bool initialized_; | 197 bool initialized_; |
| 187 | 198 |
| 188 PepperPluginThreadDelegate plugin_thread_delegate_; | 199 PepperPluginThreadDelegate plugin_thread_delegate_; |
| 189 scoped_refptr<PluginThreadTaskRunner> plugin_task_runner_; | 200 scoped_refptr<PluginThreadTaskRunner> plugin_task_runner_; |
| 190 ClientContext context_; | 201 ClientContext context_; |
| 191 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; | 202 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; |
| 192 scoped_ptr<PepperView> view_; | 203 scoped_ptr<PepperView> view_; |
| 193 pp::View plugin_view_; | 204 pp::View plugin_view_; |
| 194 | 205 |
| 195 scoped_ptr<protocol::ConnectionToHost> host_connection_; | 206 scoped_ptr<protocol::ConnectionToHost> host_connection_; |
| 196 scoped_ptr<ChromotingClient> client_; | 207 scoped_ptr<ChromotingClient> client_; |
| 197 | 208 |
| 198 // Input pipeline components, in reverse order of distance from input source. | 209 // Input pipeline components, in reverse order of distance from input source. |
| 199 protocol::MouseInputFilter mouse_input_filter_; | 210 protocol::MouseInputFilter mouse_input_filter_; |
| 200 protocol::InputEventTracker input_tracker_; | 211 protocol::InputEventTracker input_tracker_; |
| 201 #if defined(OS_MACOSX) | 212 #if defined(OS_MACOSX) |
| 202 MacKeyEventProcessor mac_key_event_processor_; | 213 MacKeyEventProcessor mac_key_event_processor_; |
| 203 #endif | 214 #endif |
| 204 KeyEventMapper key_mapper_; | 215 KeyEventMapper key_mapper_; |
| 205 PepperInputHandler input_handler_; | 216 PepperInputHandler input_handler_; |
| 206 | 217 |
| 207 // XmppProxy is a refcounted interface used to perform thread-switching and | 218 // XmppProxy is a refcounted interface used to perform thread-switching and |
| 208 // detaching between objects whose lifetimes are controlled by pepper, and | 219 // detaching between objects whose lifetimes are controlled by pepper, and |
| 209 // jingle_glue objects. This is used when if we start a sandboxed jingle | 220 // jingle_glue objects. This is used when if we start a sandboxed jingle |
| 210 // connection. | 221 // connection. |
| 211 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 222 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
| 212 | 223 |
| 224 // PIN Fetcher. | |
| 225 bool use_async_pin_dialog_; | |
| 226 protocol::SecretFetchedCallback secret_fetched_callback_; | |
| 227 | |
| 213 base::WeakPtrFactory<ChromotingInstance> weak_factory_; | 228 base::WeakPtrFactory<ChromotingInstance> weak_factory_; |
| 214 | 229 |
| 215 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); | 230 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); |
| 216 }; | 231 }; |
| 217 | 232 |
| 218 } // namespace remoting | 233 } // namespace remoting |
| 219 | 234 |
| 220 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 235 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
| OLD | NEW |