| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } // namespace protocol | 30 } // namespace protocol |
| 31 | 31 |
| 32 // ClientUserInterface that indirectly makes and receives JNI calls. | 32 // ClientUserInterface that indirectly makes and receives JNI calls. |
| 33 class ChromotingJniInstance | 33 class ChromotingJniInstance |
| 34 : public ClientUserInterface, | 34 : public ClientUserInterface, |
| 35 public protocol::ClipboardStub, | 35 public protocol::ClipboardStub, |
| 36 public protocol::CursorShapeStub, | 36 public protocol::CursorShapeStub, |
| 37 public base::RefCountedThreadSafe<ChromotingJniInstance> { | 37 public base::RefCountedThreadSafe<ChromotingJniInstance> { |
| 38 public: | 38 public: |
| 39 // Initiates a connection with the specified host. Call from the UI thread. | 39 // Initiates a connection with the specified host. Call from the UI thread. |
| 40 // The instance does not take ownership of |jni_runtime|. | 40 // The instance does not take ownership of |jni_runtime|. To connect with an |
| 41 // unpaired host, pass in |pairing_id| and |pairing_secret| as empty strings. |
| 41 ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, | 42 ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, |
| 42 const char* username, | 43 const char* username, |
| 43 const char* auth_token, | 44 const char* auth_token, |
| 44 const char* host_jid, | 45 const char* host_jid, |
| 45 const char* host_id, | 46 const char* host_id, |
| 46 const char* host_pubkey); | 47 const char* host_pubkey, |
| 48 const char* pairing_id, |
| 49 const char* pairing_secret); |
| 47 | 50 |
| 48 // Terminates the current connection (if it hasn't already failed) and cleans | 51 // Terminates the current connection (if it hasn't already failed) and cleans |
| 49 // up. Must be called before destruction. | 52 // up. Must be called before destruction. |
| 50 void Cleanup(); | 53 void Cleanup(); |
| 51 | 54 |
| 52 // Provides the user's PIN and resumes the host authentication attempt. Call | 55 // Provides the user's PIN and resumes the host authentication attempt. Call |
| 53 // on the UI thread once the user has finished entering this PIN into the UI, | 56 // on the UI thread once the user has finished entering this PIN into the UI, |
| 54 // but only after the UI has been asked to provide a PIN (via FetchSecret()). | 57 // but only after the UI has been asked to provide a PIN (via FetchSecret()). |
| 55 void ProvideSecret(const std::string& pin); | 58 void ProvideSecret(const std::string& pin, bool create_pair); |
| 56 | 59 |
| 57 // Schedules a redraw on the display thread. May be called from any thread. | 60 // Schedules a redraw on the display thread. May be called from any thread. |
| 58 void RedrawDesktop(); | 61 void RedrawDesktop(); |
| 59 | 62 |
| 60 // Moves the host's cursor to the specified coordinates, optionally with some | 63 // Moves the host's cursor to the specified coordinates, optionally with some |
| 61 // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made. | 64 // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made. |
| 62 void PerformMouseAction(int x, | 65 void PerformMouseAction(int x, |
| 63 int y, | 66 int y, |
| 64 protocol::MouseEvent_MouseButton button, | 67 protocol::MouseEvent_MouseButton button, |
| 65 bool button_down); | 68 bool button_down); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 127 |
| 125 // These strings describe the current connection, and are not reused. They | 128 // These strings describe the current connection, and are not reused. They |
| 126 // are initialized in ConnectionToHost(), but thereafter are only to be used | 129 // are initialized in ConnectionToHost(), but thereafter are only to be used |
| 127 // on the network thread. (This is safe because ConnectionToHost()'s finishes | 130 // on the network thread. (This is safe because ConnectionToHost()'s finishes |
| 128 // using them on the UI thread before they are ever touched from network.) | 131 // using them on the UI thread before they are ever touched from network.) |
| 129 std::string username_; | 132 std::string username_; |
| 130 std::string auth_token_; | 133 std::string auth_token_; |
| 131 std::string host_jid_; | 134 std::string host_jid_; |
| 132 std::string host_id_; | 135 std::string host_id_; |
| 133 std::string host_pubkey_; | 136 std::string host_pubkey_; |
| 137 std::string pairing_id_; |
| 138 std::string pairing_secret_; |
| 139 |
| 140 // Indicates whether to establish a new pairing with this host. This is |
| 141 // modified in ProvideSecret(), but thereafter to be used only from the |
| 142 // network thread. (This is safe because ProvideSecret() is invoked at most |
| 143 // once per run, and always before any reference to this flag.) |
| 144 bool create_pairing_; |
| 134 | 145 |
| 135 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; | 146 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; |
| 136 | 147 |
| 137 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); | 148 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); |
| 138 }; | 149 }; |
| 139 | 150 |
| 140 } // namespace remoting | 151 } // namespace remoting |
| 141 | 152 |
| 142 #endif | 153 #endif |
| OLD | NEW |