Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: remoting/client/plugin/chromoting_instance.cc

Issue 12475020: Client plugin changes to support third party authentication. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reviewer comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..05a3996098148a02b0dc946b8b1cb0b0b600996a 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,7 +722,6 @@ 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);
@@ -698,6 +731,17 @@ void ChromotingInstance::OnPinFetched(const std::string& pin) {
}
}
+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 {
+ VLOG(1) << "Ignored OnThirdPartyTokenFetched without a pending fetch.";
Sergey Ulanov 2013/04/05 18:34:57 might be better to use LOG(WARNING) here.
rmsousa 2013/04/06 01:11:03 Done. Changed the pin fetcher one as well.
+ }
+}
+
ChromotingStats* ChromotingInstance::GetStats() {
if (!client_.get())
return NULL;

Powered by Google App Engine
This is Rietveld 408576698