Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_JNI_JNI_SECRET_FETCHER_H_ | |
| 6 #define REMOTING_CLIENT_JNI_JNI_SECRET_FETCHER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "remoting/protocol/client_authentication_config.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 | |
| 14 class ChromotingJniRuntime; | |
| 15 class JniClient; | |
| 16 | |
| 17 // This class fetches the secret on the UI thread. It must be deleted on UI. | |
|
Lambros
2016/05/28 00:43:06
pairing secret
Yuwei
2016/06/01 21:30:11
Done.
| |
| 18 class JniSecretFetcher { | |
| 19 public: | |
| 20 JniSecretFetcher(ChromotingJniRuntime* runtime, | |
| 21 base::WeakPtr<JniClient> client, | |
| 22 const std::string& host_id); | |
| 23 virtual ~JniSecretFetcher(); | |
| 24 | |
| 25 // Called on UI thread. Notifies the user interface that the user needs to | |
| 26 // enter a PIN. The current authentication attempt is put on hold until | |
| 27 // |callback| is invoked. |callback| will be run on the network thread. | |
| 28 void FetchSecret(bool pairable, | |
| 29 const protocol::SecretFetchedCallback& callback); | |
| 30 | |
| 31 // Provides the user's PIN and resumes the host authentication attempt. Call | |
| 32 // on the UI thread once the user has finished entering this PIN into the UI, | |
| 33 // but only after the UI has been asked to provide a PIN (via FetchSecret()). | |
| 34 void ProvideSecret(const std::string& pin); | |
| 35 | |
| 36 // Get weak pointer to be used on the UI thread. | |
| 37 base::WeakPtr<JniSecretFetcher> GetWeakPtr(); | |
| 38 | |
| 39 private: | |
| 40 ChromotingJniRuntime* jni_runtime_; | |
| 41 base::WeakPtr<JniClient> jni_client_; | |
| 42 | |
| 43 std::string host_id_; | |
| 44 | |
| 45 // Pass this the user's PIN once we have it. To be assigned and accessed on | |
| 46 // the UI thread, but must be posted to the network thread to call it. | |
| 47 protocol::SecretFetchedCallback callback_; | |
| 48 | |
| 49 base::WeakPtrFactory<JniSecretFetcher> weak_factory_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(JniSecretFetcher); | |
| 52 }; | |
| 53 | |
| 54 } // namespace remoting | |
| 55 | |
| 56 #endif // REMOTING_CLIENT_JNI_JNI_SECRET_FETCHER_H_ | |
| OLD | NEW |