| Index: remoting/client/jni/jni_pairing_secret_fetcher.cc
|
| diff --git a/remoting/client/jni/jni_pairing_secret_fetcher.cc b/remoting/client/jni/jni_pairing_secret_fetcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3dc5a4e8e80bcf4d98d050008231b6b9a087348c
|
| --- /dev/null
|
| +++ b/remoting/client/jni/jni_pairing_secret_fetcher.cc
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <remoting/client/jni/jni_pairing_secret_fetcher.h>
|
| +#include "base/bind.h"
|
| +#include "base/location.h"
|
| +#include "remoting/client/jni/chromoting_jni_runtime.h"
|
| +#include "remoting/client/jni/jni_client.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +JniPairingSecretFetcher::JniPairingSecretFetcher(ChromotingJniRuntime* runtime,
|
| + base::WeakPtr<JniClient> client,
|
| + const std::string& host_id) :
|
| + jni_runtime_(runtime),
|
| + jni_client_(client),
|
| + host_id_(host_id),
|
| + weak_factory_(this) {}
|
| +
|
| +JniPairingSecretFetcher::~JniPairingSecretFetcher() {
|
| + DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
|
| +}
|
| +
|
| +void JniPairingSecretFetcher::FetchSecret(
|
| + bool pairable,
|
| + const protocol::SecretFetchedCallback& callback) {
|
| + DCHECK (jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
|
| +
|
| + if (!jni_client_) {
|
| + return;
|
| + }
|
| +
|
| + // Delete pairing credentials if they exist.
|
| + jni_client_->CommitPairingCredentials(host_id_, "", "");
|
| +
|
| + callback_ = callback;
|
| + jni_client_->DisplayAuthenticationPrompt(pairable);
|
| +}
|
| +
|
| +void JniPairingSecretFetcher::ProvideSecret(const std::string& pin) {
|
| + DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
|
| + DCHECK(!callback_.is_null());
|
| +
|
| + jni_runtime_->network_task_runner()->PostTask(FROM_HERE,
|
| + base::Bind(callback_, pin));
|
| +}
|
| +
|
| +base::WeakPtr<JniPairingSecretFetcher> JniPairingSecretFetcher::GetWeakPtr() {
|
| + return weak_factory_.GetWeakPtr();
|
| +}
|
| +
|
| +} // namespace remoting
|
|
|