OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | 5 #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | 6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "remoting/client/chromoting_client.h" | 14 #include "remoting/client/chromoting_client.h" |
15 #include "remoting/client/client_config.h" | 15 #include "remoting/client/client_config.h" |
16 #include "remoting/client/client_context.h" | 16 #include "remoting/client/client_context.h" |
17 #include "remoting/client/client_user_interface.h" | 17 #include "remoting/client/client_user_interface.h" |
18 #include "remoting/client/frame_consumer_proxy.h" | 18 #include "remoting/client/frame_consumer_proxy.h" |
19 #include "remoting/client/jni/jni_frame_consumer.h" | 19 #include "remoting/client/jni/jni_frame_consumer.h" |
20 #include "remoting/client/token_fetcher_proxy.h" | |
21 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 20 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
22 #include "remoting/protocol/clipboard_stub.h" | 21 #include "remoting/protocol/clipboard_stub.h" |
23 #include "remoting/protocol/connection_to_host.h" | 22 #include "remoting/protocol/connection_to_host.h" |
24 #include "remoting/protocol/cursor_shape_stub.h" | 23 #include "remoting/protocol/cursor_shape_stub.h" |
25 | 24 |
26 namespace remoting { | 25 namespace remoting { |
27 | 26 |
28 namespace protocol { | 27 namespace protocol { |
29 class ClipboardEvent; | 28 class ClipboardEvent; |
30 class CursorShapeInfo; | 29 class CursorShapeInfo; |
31 } // namespace protocol | 30 } // namespace protocol |
32 | 31 |
33 namespace client { | 32 namespace client { |
34 class LogToServer; | 33 class LogToServer; |
35 } | 34 } |
36 | 35 |
37 class VideoRenderer; | 36 class VideoRenderer; |
| 37 class TokenFetcherProxy; |
38 | 38 |
39 // ClientUserInterface that indirectly makes and receives JNI calls. | 39 // ClientUserInterface that indirectly makes and receives JNI calls. |
40 class ChromotingJniInstance | 40 class ChromotingJniInstance |
41 : public ClientUserInterface, | 41 : public ClientUserInterface, |
42 public protocol::ClipboardStub, | 42 public protocol::ClipboardStub, |
43 public protocol::CursorShapeStub, | 43 public protocol::CursorShapeStub, |
44 public base::RefCountedThreadSafe<ChromotingJniInstance> { | 44 public base::RefCountedThreadSafe<ChromotingJniInstance> { |
45 public: | 45 public: |
46 // Initiates a connection with the specified host. Call from the UI thread. | 46 // Initiates a connection with the specified host. Call from the UI thread. |
47 // The instance does not take ownership of |jni_runtime|. To connect with an | 47 // The instance does not take ownership of |jni_runtime|. To connect with an |
(...skipping 11 matching lines...) Expand all Loading... |
59 // up. Must be called before destruction. | 59 // up. Must be called before destruction. |
60 void Cleanup(); | 60 void Cleanup(); |
61 | 61 |
62 // Requests the android app to fetch a third-party token. | 62 // Requests the android app to fetch a third-party token. |
63 void FetchThirdPartyToken( | 63 void FetchThirdPartyToken( |
64 const GURL& token_url, | 64 const GURL& token_url, |
65 const std::string& client_id, | 65 const std::string& client_id, |
66 const std::string& scope, | 66 const std::string& scope, |
67 const base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy); | 67 const base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy); |
68 | 68 |
| 69 // Called by the android app when the token is fetched. |
| 70 void HandleOnThirdPartyTokenFetched(const std::string& token, |
| 71 const std::string& shared_secret); |
| 72 |
69 // Provides the user's PIN and resumes the host authentication attempt. Call | 73 // Provides the user's PIN and resumes the host authentication attempt. Call |
70 // on the UI thread once the user has finished entering this PIN into the UI, | 74 // on the UI thread once the user has finished entering this PIN into the UI, |
71 // but only after the UI has been asked to provide a PIN (via FetchSecret()). | 75 // but only after the UI has been asked to provide a PIN (via FetchSecret()). |
72 void ProvideSecret(const std::string& pin, bool create_pair, | 76 void ProvideSecret(const std::string& pin, bool create_pair, |
73 const std::string& device_name); | 77 const std::string& device_name); |
74 | 78 |
75 // Schedules a redraw on the display thread. May be called from any thread. | 79 // Schedules a redraw on the display thread. May be called from any thread. |
76 void RedrawDesktop(); | 80 void RedrawDesktop(); |
77 | 81 |
78 // Moves the host's cursor to the specified coordinates, optionally with some | 82 // Moves the host's cursor to the specified coordinates, optionally with some |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 158 |
155 // This group of variables is to be used on the network thread. | 159 // This group of variables is to be used on the network thread. |
156 ClientConfig client_config_; | 160 ClientConfig client_config_; |
157 scoped_ptr<ClientContext> client_context_; | 161 scoped_ptr<ClientContext> client_context_; |
158 scoped_ptr<VideoRenderer> video_renderer_; | 162 scoped_ptr<VideoRenderer> video_renderer_; |
159 scoped_ptr<protocol::ConnectionToHost> connection_; | 163 scoped_ptr<protocol::ConnectionToHost> connection_; |
160 scoped_ptr<ChromotingClient> client_; | 164 scoped_ptr<ChromotingClient> client_; |
161 XmppSignalStrategy::XmppServerConfig xmpp_config_; | 165 XmppSignalStrategy::XmppServerConfig xmpp_config_; |
162 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ | 166 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ |
163 scoped_ptr<client::LogToServer> log_to_server_; | 167 scoped_ptr<client::LogToServer> log_to_server_; |
| 168 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy_; |
164 | 169 |
165 // Pass this the user's PIN once we have it. To be assigned and accessed on | 170 // Pass this the user's PIN once we have it. To be assigned and accessed on |
166 // the UI thread, but must be posted to the network thread to call it. | 171 // the UI thread, but must be posted to the network thread to call it. |
167 protocol::SecretFetchedCallback pin_callback_; | 172 protocol::SecretFetchedCallback pin_callback_; |
168 | 173 |
169 // Indicates whether to establish a new pairing with this host. This is | 174 // Indicates whether to establish a new pairing with this host. This is |
170 // modified in ProvideSecret(), but thereafter to be used only from the | 175 // modified in ProvideSecret(), but thereafter to be used only from the |
171 // network thread. (This is safe because ProvideSecret() is invoked at most | 176 // network thread. (This is safe because ProvideSecret() is invoked at most |
172 // once per run, and always before any reference to this flag.) | 177 // once per run, and always before any reference to this flag.) |
173 bool create_pairing_; | 178 bool create_pairing_; |
174 | 179 |
175 // The device name to appear in the paired-clients list. Accessed on the | 180 // The device name to appear in the paired-clients list. Accessed on the |
176 // network thread. | 181 // network thread. |
177 std::string device_name_; | 182 std::string device_name_; |
178 | 183 |
179 // If this is true, performance statistics will be periodically written to | 184 // If this is true, performance statistics will be periodically written to |
180 // the Android log. Used on the network thread. | 185 // the Android log. Used on the network thread. |
181 bool stats_logging_enabled_; | 186 bool stats_logging_enabled_; |
182 | 187 |
183 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; | 188 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; |
184 | 189 |
| 190 base::WeakPtrFactory<ChromotingJniInstance> weak_factory_; |
| 191 |
185 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); | 192 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); |
186 }; | 193 }; |
187 | 194 |
188 } // namespace remoting | 195 } // namespace remoting |
189 | 196 |
190 #endif | 197 #endif |
OLD | NEW |