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 22 matching lines...) Expand all Loading... |
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_client_authenticator.h" | 42 #include "remoting/protocol/negotiating_client_authenticator.h" |
| 43 #include "remoting/protocol/third_party_client_authenticator.h" |
43 | 44 |
44 namespace base { | 45 namespace base { |
45 class DictionaryValue; | 46 class DictionaryValue; |
46 } // namespace base | 47 } // namespace base |
47 | 48 |
48 namespace pp { | 49 namespace pp { |
49 class InputEvent; | 50 class InputEvent; |
50 class Module; | 51 class Module; |
51 } // namespace pp | 52 } // namespace pp |
52 | 53 |
53 namespace remoting { | 54 namespace remoting { |
54 | 55 |
55 class ChromotingClient; | 56 class ChromotingClient; |
56 class ChromotingStats; | 57 class ChromotingStats; |
57 class ClientContext; | 58 class ClientContext; |
58 class FrameConsumerProxy; | 59 class FrameConsumerProxy; |
59 class PepperAudioPlayer; | 60 class PepperAudioPlayer; |
| 61 class PepperTokenFetcher; |
60 class PepperView; | 62 class PepperView; |
61 class PepperXmppProxy; | 63 class PepperXmppProxy; |
62 class RectangleUpdateDecoder; | 64 class RectangleUpdateDecoder; |
63 | 65 |
64 struct ClientConfig; | 66 struct ClientConfig; |
65 | 67 |
66 class ChromotingInstance : | 68 class ChromotingInstance : |
67 public ClientUserInterface, | 69 public ClientUserInterface, |
68 public protocol::ClipboardStub, | 70 public protocol::ClipboardStub, |
69 public protocol::CursorShapeStub, | 71 public protocol::CursorShapeStub, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const char* argv[]) OVERRIDE; | 103 const char* argv[]) OVERRIDE; |
102 virtual void HandleMessage(const pp::Var& message) OVERRIDE; | 104 virtual void HandleMessage(const pp::Var& message) OVERRIDE; |
103 virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE; | 105 virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE; |
104 | 106 |
105 // ClientUserInterface interface. | 107 // ClientUserInterface interface. |
106 virtual void OnConnectionState(protocol::ConnectionToHost::State state, | 108 virtual void OnConnectionState(protocol::ConnectionToHost::State state, |
107 protocol::ErrorCode error) OVERRIDE; | 109 protocol::ErrorCode error) OVERRIDE; |
108 virtual void OnConnectionReady(bool ready) OVERRIDE; | 110 virtual void OnConnectionReady(bool ready) OVERRIDE; |
109 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; | 111 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; |
110 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; | 112 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; |
| 113 virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> |
| 114 GetTokenFetcher(const std::string& host_public_key) OVERRIDE; |
111 | 115 |
112 // protocol::ClipboardStub interface. | 116 // protocol::ClipboardStub interface. |
113 virtual void InjectClipboardEvent( | 117 virtual void InjectClipboardEvent( |
114 const protocol::ClipboardEvent& event) OVERRIDE; | 118 const protocol::ClipboardEvent& event) OVERRIDE; |
115 | 119 |
116 // protocol::CursorShapeStub interface. | 120 // protocol::CursorShapeStub interface. |
117 virtual void SetCursorShape( | 121 virtual void SetCursorShape( |
118 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE; | 122 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE; |
119 | 123 |
120 // Called by PepperView. | 124 // Called by PepperView. |
(...skipping 19 matching lines...) Expand all Loading... |
140 // to it. If this instance is not the currently registered logging instance, | 144 // to it. If this instance is not the currently registered logging instance, |
141 // then the currently registered instance will stay in effect. | 145 // then the currently registered instance will stay in effect. |
142 void UnregisterLoggingInstance(); | 146 void UnregisterLoggingInstance(); |
143 | 147 |
144 // A Log Message Handler that is called after each LOG message has been | 148 // A Log Message Handler that is called after each LOG message has been |
145 // processed. This must be of type LogMessageHandlerFunction defined in | 149 // processed. This must be of type LogMessageHandlerFunction defined in |
146 // base/logging.h. | 150 // base/logging.h. |
147 static bool LogToUI(int severity, const char* file, int line, | 151 static bool LogToUI(int severity, const char* file, int line, |
148 size_t message_start, const std::string& str); | 152 size_t message_start, const std::string& str); |
149 | 153 |
| 154 // Requests the webapp to fetch a third-party token. |
| 155 void FetchThirdPartyToken( |
| 156 const GURL& token_url, |
| 157 const std::string& host_public_key, |
| 158 const std::string& scope, |
| 159 const base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher); |
| 160 |
150 private: | 161 private: |
151 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); | 162 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); |
152 | 163 |
153 // Used as the |FetchSecretCallback| for IT2Me (or Me2Me from old webapps). | 164 // Used as the |FetchSecretCallback| for IT2Me (or Me2Me from old webapps). |
154 // Immediately calls |secret_fetched_callback| with |shared_secret|. | 165 // Immediately calls |secret_fetched_callback| with |shared_secret|. |
155 static void FetchSecretFromString( | 166 static void FetchSecretFromString( |
156 const std::string& shared_secret, | 167 const std::string& shared_secret, |
157 const protocol::SecretFetchedCallback& secret_fetched_callback); | 168 const protocol::SecretFetchedCallback& secret_fetched_callback); |
158 | 169 |
159 // Message handlers for messages that come from JavaScript. Called | 170 // Message handlers for messages that come from JavaScript. Called |
160 // from HandleMessage(). | 171 // from HandleMessage(). |
161 void Connect(const ClientConfig& config); | 172 void Connect(const ClientConfig& config); |
162 void Disconnect(); | 173 void Disconnect(); |
163 void OnIncomingIq(const std::string& iq); | 174 void OnIncomingIq(const std::string& iq); |
164 void ReleaseAllKeys(); | 175 void ReleaseAllKeys(); |
165 void InjectKeyEvent(const protocol::KeyEvent& event); | 176 void InjectKeyEvent(const protocol::KeyEvent& event); |
166 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode); | 177 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode); |
167 void TrapKey(uint32 usb_keycode, bool trap); | 178 void TrapKey(uint32 usb_keycode, bool trap); |
168 void SendClipboardItem(const std::string& mime_type, const std::string& item); | 179 void SendClipboardItem(const std::string& mime_type, const std::string& item); |
169 void NotifyClientResolution(int width, int height, int x_dpi, int y_dpi); | 180 void NotifyClientResolution(int width, int height, int x_dpi, int y_dpi); |
170 void PauseVideo(bool pause); | 181 void PauseVideo(bool pause); |
171 void PauseAudio(bool pause); | 182 void PauseAudio(bool pause); |
172 void OnPinFetched(const std::string& pin); | 183 void OnPinFetched(const std::string& pin); |
| 184 void OnThirdPartyTokenFetched(const std::string& token, |
| 185 const std::string& shared_secret); |
173 | 186 |
174 // Helper method to post messages to the webapp. | 187 // Helper method to post messages to the webapp. |
175 void PostChromotingMessage(const std::string& method, | 188 void PostChromotingMessage(const std::string& method, |
176 scoped_ptr<base::DictionaryValue> data); | 189 scoped_ptr<base::DictionaryValue> data); |
177 | 190 |
178 // Posts trapped keys to the web-app to handle. | 191 // Posts trapped keys to the web-app to handle. |
179 void SendTrappedKey(uint32 usb_keycode, bool pressed); | 192 void SendTrappedKey(uint32 usb_keycode, bool pressed); |
180 | 193 |
181 // Callback for PepperXmppProxy. | 194 // Callback for PepperXmppProxy. |
182 void SendOutgoingIq(const std::string& iq); | 195 void SendOutgoingIq(const std::string& iq); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // XmppProxy is a refcounted interface used to perform thread-switching and | 233 // XmppProxy is a refcounted interface used to perform thread-switching and |
221 // detaching between objects whose lifetimes are controlled by pepper, and | 234 // detaching between objects whose lifetimes are controlled by pepper, and |
222 // jingle_glue objects. This is used when if we start a sandboxed jingle | 235 // jingle_glue objects. This is used when if we start a sandboxed jingle |
223 // connection. | 236 // connection. |
224 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 237 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
225 | 238 |
226 // PIN Fetcher. | 239 // PIN Fetcher. |
227 bool use_async_pin_dialog_; | 240 bool use_async_pin_dialog_; |
228 protocol::SecretFetchedCallback secret_fetched_callback_; | 241 protocol::SecretFetchedCallback secret_fetched_callback_; |
229 | 242 |
| 243 base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher_; |
| 244 |
230 base::WeakPtrFactory<ChromotingInstance> weak_factory_; | 245 base::WeakPtrFactory<ChromotingInstance> weak_factory_; |
231 | 246 |
232 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); | 247 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); |
233 }; | 248 }; |
234 | 249 |
235 } // namespace remoting | 250 } // namespace remoting |
236 | 251 |
237 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 252 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
OLD | NEW |