| Index: remoting/client/plugin/chromoting_instance.cc
|
| diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
|
| index 1514466c803f59e613883b6326b878a25f4daacf..fef612e7b4765abe44f876a8ae67bd6ecc25ee3b 100644
|
| --- a/remoting/client/plugin/chromoting_instance.cc
|
| +++ b/remoting/client/plugin/chromoting_instance.cc
|
| @@ -19,6 +19,7 @@
|
| #include "base/synchronization/waitable_event.h"
|
| #include "base/threading/thread.h"
|
| #include "base/values.h"
|
| +#include "googleurl/src/gurl.h"
|
| #include "jingle/glue/thread_wrapper.h"
|
| #include "media/base/media.h"
|
| #include "net/socket/ssl_server_socket.h"
|
| @@ -35,6 +36,7 @@
|
| #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/plugin/pepper_xmpp_proxy.h"
|
| #include "remoting/client/rectangle_update_decoder.h"
|
| @@ -135,7 +137,7 @@ logging::LogMessageHandlerFunction g_logging_old_handler = NULL;
|
| const char ChromotingInstance::kApiFeatures[] =
|
| "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey "
|
| "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio "
|
| - "asyncPin";
|
| + "asyncPin thirdPartyAuth";
|
|
|
| bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str,
|
| ClientConfig* config) {
|
| @@ -395,6 +397,15 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
|
| return;
|
| }
|
| OnPinFetched(pin);
|
| + } else if (method == "onThirdPartyTokenFetched") {
|
| + std::string token;
|
| + std::string shared_secret;
|
| + if (!data->GetString("token", &token) ||
|
| + !data->GetString("sharedSecret", &shared_secret)) {
|
| + LOG(ERROR) << "Invalid onThirdPartyTokenFetched data.";
|
| + return;
|
| + }
|
| + OnThirdPartyTokenFetched(token, shared_secret);
|
| }
|
| }
|
|
|
| @@ -440,6 +451,23 @@ void ChromotingInstance::OnConnectionState(
|
| PostChromotingMessage("onConnectionStatus", data.Pass());
|
| }
|
|
|
| +void ChromotingInstance::FetchThirdPartyToken(
|
| + const GURL& token_url,
|
| + const std::string& host_public_key,
|
| + const std::string& scope,
|
| + base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher) {
|
| + // 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_);
|
| + pepper_token_fetcher_ = pepper_token_fetcher;
|
| + scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
|
| + data->SetString("tokenUrl", token_url.spec());
|
| + data->SetString("hostPublicKey", host_public_key);
|
| + data->SetString("scope", scope);
|
| + PostChromotingMessage("fetchThirdPartyToken", data.Pass());
|
| +}
|
| +
|
| void ChromotingInstance::OnConnectionReady(bool ready) {
|
| scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
|
| data->SetBoolean("ready", ready);
|
| @@ -475,6 +503,12 @@ protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() {
|
| return this;
|
| }
|
|
|
| +scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
|
| +ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) {
|
| + return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
|
| + new PepperTokenFetcher(this->AsWeakPtr(), host_public_key));
|
| +}
|
| +
|
| void ChromotingInstance::InjectClipboardEvent(
|
| const protocol::ClipboardEvent& event) {
|
| scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
|
| @@ -688,13 +722,23 @@ void ChromotingInstance::PauseAudio(bool pause) {
|
| audio_control.set_enable(!pause);
|
| host_connection_->host_stub()->ControlAudio(audio_control);
|
| }
|
| -
|
| void ChromotingInstance::OnPinFetched(const std::string& pin) {
|
| if (!secret_fetched_callback_.is_null()) {
|
| secret_fetched_callback_.Run(pin);
|
| secret_fetched_callback_.Reset();
|
| } else {
|
| - VLOG(1) << "Ignored OnPinFetched received without a pending fetch.";
|
| + LOG(WARNING) << "Ignored OnPinFetched received without a pending fetch.";
|
| + }
|
| +}
|
| +
|
| +void ChromotingInstance::OnThirdPartyTokenFetched(
|
| + const std::string& token,
|
| + const std::string& shared_secret) {
|
| + if (pepper_token_fetcher_) {
|
| + pepper_token_fetcher_->OnTokenFetched(token, shared_secret);
|
| + pepper_token_fetcher_.reset();
|
| + } else {
|
| + LOG(WARNING) << "Ignored OnThirdPartyTokenFetched without a pending fetch.";
|
| }
|
| }
|
|
|
|
|