summaryrefslogtreecommitdiffstats
path: root/remoting/client/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/client/plugin')
-rw-r--r--remoting/client/plugin/chromoting_instance.cc19
-rw-r--r--remoting/client/plugin/chromoting_instance.h6
-rw-r--r--remoting/client/plugin/pepper_token_fetcher.cc40
-rw-r--r--remoting/client/plugin/pepper_token_fetcher.h44
4 files changed, 14 insertions, 95 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index f7083b6..2790229 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -47,9 +47,9 @@
#include "remoting/client/plugin/pepper_audio_player.h"
#include "remoting/client/plugin/pepper_input_handler.h"
#include "remoting/client/plugin/pepper_port_allocator.h"
-#include "remoting/client/plugin/pepper_token_fetcher.h"
#include "remoting/client/plugin/pepper_view.h"
#include "remoting/client/software_video_renderer.h"
+#include "remoting/client/token_fetcher_proxy.h"
#include "remoting/protocol/connection_to_host.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/libjingle_transport_factory.h"
@@ -452,12 +452,12 @@ void ChromotingInstance::FetchThirdPartyToken(
const GURL& token_url,
const std::string& host_public_key,
const std::string& scope,
- base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher) {
+ base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) {
// Once the Session object calls this function, it won't continue the
// authentication until the callback is called (or connection is canceled).
// So, it's impossible to reach this with a callback already registered.
- DCHECK(!pepper_token_fetcher_.get());
- pepper_token_fetcher_ = pepper_token_fetcher;
+ DCHECK(!token_fetcher_proxy_.get());
+ token_fetcher_proxy_ = token_fetcher_proxy;
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
data->SetString("tokenUrl", token_url.spec());
data->SetString("hostPublicKey", host_public_key);
@@ -537,7 +537,10 @@ protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() {
scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) {
return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
- new PepperTokenFetcher(weak_factory_.GetWeakPtr(), host_public_key));
+ new TokenFetcherProxy(
+ base::Bind(&ChromotingInstance::FetchThirdPartyToken,
+ weak_factory_.GetWeakPtr()),
+ host_public_key));
}
void ChromotingInstance::InjectClipboardEvent(
@@ -940,9 +943,9 @@ void ChromotingInstance::HandleOnThirdPartyTokenFetched(
LOG(ERROR) << "Invalid onThirdPartyTokenFetched data.";
return;
}
- if (pepper_token_fetcher_.get()) {
- pepper_token_fetcher_->OnTokenFetched(token, shared_secret);
- pepper_token_fetcher_.reset();
+ if (token_fetcher_proxy_.get()) {
+ token_fetcher_proxy_->OnTokenFetched(token, shared_secret);
+ token_fetcher_proxy_.reset();
} else {
LOG(WARNING) << "Ignored OnThirdPartyTokenFetched without a pending fetch.";
}
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index 121f1ad..3f6b0c6 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -61,7 +61,7 @@ class DelegatingSignalStrategy;
class FrameConsumer;
class FrameConsumerProxy;
class PepperAudioPlayer;
-class PepperTokenFetcher;
+class TokenFetcherProxy;
class PepperView;
class RectangleUpdateDecoder;
class SignalStrategy;
@@ -178,7 +178,7 @@ class ChromotingInstance :
const GURL& token_url,
const std::string& host_public_key,
const std::string& scope,
- const base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher);
+ const base::WeakPtr<TokenFetcherProxy> pepper_token_fetcher);
private:
FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup);
@@ -294,7 +294,7 @@ class ChromotingInstance :
// webapp for decoding.
bool use_media_source_rendering_;
- base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher_;
+ base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy_;
// Weak reference to this instance, used for global logging and task posting.
base::WeakPtrFactory<ChromotingInstance> weak_factory_;
diff --git a/remoting/client/plugin/pepper_token_fetcher.cc b/remoting/client/plugin/pepper_token_fetcher.cc
deleted file mode 100644
index 7a7aca9..0000000
--- a/remoting/client/plugin/pepper_token_fetcher.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2013 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/plugin/pepper_token_fetcher.h"
-
-#include "remoting/client/plugin/chromoting_instance.h"
-
-namespace remoting {
-
-PepperTokenFetcher::PepperTokenFetcher(base::WeakPtr<ChromotingInstance> plugin,
- const std::string& host_public_key)
- : plugin_(plugin),
- host_public_key_(host_public_key),
- weak_factory_(this) {
-}
-
-PepperTokenFetcher::~PepperTokenFetcher() {
-}
-
-void PepperTokenFetcher::FetchThirdPartyToken(
- const GURL& token_url,
- const std::string& scope,
- const TokenFetchedCallback& token_fetched_callback) {
- if (plugin_.get()) {
- token_fetched_callback_ = token_fetched_callback;
- plugin_->FetchThirdPartyToken(token_url, host_public_key_, scope,
- weak_factory_.GetWeakPtr());
- }
-}
-
-void PepperTokenFetcher::OnTokenFetched(
- const std::string& token, const std::string& shared_secret) {
- if (!token_fetched_callback_.is_null()) {
- token_fetched_callback_.Run(token, shared_secret);
- token_fetched_callback_.Reset();
- }
-}
-
-} // namespace remoting
diff --git a/remoting/client/plugin/pepper_token_fetcher.h b/remoting/client/plugin/pepper_token_fetcher.h
deleted file mode 100644
index b914f51..0000000
--- a/remoting/client/plugin/pepper_token_fetcher.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2013 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.
-
-#ifndef REMOTING_CLIENT_PLUGIN_PEPPER_TOKEN_FETCHER_H_
-#define REMOTING_CLIENT_PLUGIN_PEPPER_TOKEN_FETCHER_H_
-
-#include "base/callback.h"
-#include "base/memory/weak_ptr.h"
-#include "remoting/protocol/third_party_client_authenticator.h"
-
-namespace remoting {
-
-class ChromotingInstance;
-
-class PepperTokenFetcher
- : public protocol::ThirdPartyClientAuthenticator::TokenFetcher {
- public:
- PepperTokenFetcher(base::WeakPtr<ChromotingInstance> plugin,
- const std::string& host_public_key);
- virtual ~PepperTokenFetcher();
-
- // protocol::TokenClientAuthenticator::TokenFetcher interface.
- virtual void FetchThirdPartyToken(
- const GURL& token_url,
- const std::string& scope,
- const TokenFetchedCallback& token_fetched_callback) OVERRIDE;
-
- // Called by ChromotingInstance when the webapp finishes fetching the token.
- void OnTokenFetched(const std::string& token,
- const std::string& shared_secret);
-
- private:
- base::WeakPtr<ChromotingInstance> plugin_;
- std::string host_public_key_;
- TokenFetchedCallback token_fetched_callback_;
- base::WeakPtrFactory<PepperTokenFetcher> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperTokenFetcher);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_CLIENT_PLUGIN_PEPPER_TOKEN_FETCHER_H_