Index: remoting/client/plugin/chromoting_instance.cc |
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc |
index 92476103c15fed2b5052592e854cc5c9822c2a37..004317e77390cdbaf8d2af3e3d29ed4d20d3d978 100644 |
--- a/remoting/client/plugin/chromoting_instance.cc |
+++ b/remoting/client/plugin/chromoting_instance.cc |
@@ -34,6 +34,7 @@ |
#include "remoting/client/frame_consumer_proxy.h" |
#include "remoting/client/plugin/pepper_audio_player.h" |
#include "remoting/client/plugin/pepper_input_handler.h" |
+#include "remoting/client/plugin/pepper_pin_fetcher.h" |
#include "remoting/client/plugin/pepper_port_allocator.h" |
#include "remoting/client/plugin/pepper_view.h" |
#include "remoting/client/plugin/pepper_xmpp_proxy.h" |
@@ -134,7 +135,8 @@ logging::LogMessageHandlerFunction g_logging_old_handler = NULL; |
// String sent in the "hello" message to the plugin to describe features. |
const char ChromotingInstance::kApiFeatures[] = |
"highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
- "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio"; |
+ "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " |
+ "onPinFetched useAsyncPinDialog"; |
Sergey Ulanov
2013/03/17 21:29:21
Don't need two separate features
rmsousa
2013/03/18 21:07:26
Done.
|
bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
ClientConfig* config) { |
@@ -171,6 +173,7 @@ ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) |
key_mapper_(&input_tracker_), |
#endif |
input_handler_(&key_mapper_), |
+ use_async_pin_dialog_(false), |
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); |
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); |
@@ -277,7 +280,6 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) { |
LOG(ERROR) << "Invalid connect() data."; |
return; |
} |
- |
Connect(config); |
} else if (method == "disconnect") { |
Disconnect(); |
@@ -373,6 +375,15 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) { |
return; |
} |
PauseAudio(pause); |
+ } else if (method == "useAsyncPinDialog") { |
+ use_async_pin_dialog_ = true; |
+ } else if (method == "onPinFetched") { |
+ std::string pin; |
+ if (!data->GetString("pin", &pin)) { |
+ LOG(ERROR) << "Invalid onPinFetched."; |
+ return; |
+ } |
+ OnPinFetched(pin); |
} |
} |
@@ -424,6 +435,20 @@ void ChromotingInstance::OnConnectionReady(bool ready) { |
PostChromotingMessage("onConnectionReady", data.Pass()); |
} |
+scoped_ptr<protocol::PinFetcher> ChromotingInstance::CreatePinFetcher() { |
+ return scoped_ptr<protocol::PinFetcher>(new PepperPinFetcher(AsWeakPtr())); |
+} |
+ |
+void ChromotingInstance::FetchPin(base::WeakPtr<PepperPinFetcher> pin_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 pin fetcher already registered. |
+ DCHECK(!pin_fetcher_); |
+ pin_fetcher_ = pin_fetcher; |
+ scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
+ PostChromotingMessage("fetchPin", data.Pass()); |
+} |
+ |
protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() { |
// TODO(sergeyu): Move clipboard handling to a separate class. |
// crbug.com/138108 |
@@ -436,6 +461,15 @@ protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { |
return this; |
} |
+protocol::PinFetcherFactory* ChromotingInstance::GetPinFetcherFactory() { |
+ // TODO(rmsousa): Move pin fetcher code to a separate class. |
Sergey Ulanov
2013/03/17 21:29:21
Isn't it already in a separate class?
rmsousa
2013/03/18 21:07:26
Done.
|
+ if (use_async_pin_dialog_) { |
+ return this; |
+ } else { |
+ return NULL; |
+ } |
+} |
+ |
void ChromotingInstance::InjectClipboardEvent( |
const protocol::ClipboardEvent& event) { |
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
@@ -650,6 +684,16 @@ void ChromotingInstance::PauseAudio(bool pause) { |
host_connection_->host_stub()->ControlAudio(audio_control); |
} |
+void ChromotingInstance::OnPinFetched(const std::string& shared_secret) { |
+ if (pin_fetcher_) { |
+ pin_fetcher_->OnPinFetched(shared_secret); |
+ pin_fetcher_.reset(); |
+ } else { |
+ VLOG(1) << |
+ "Ignored OnPinFetched received without a pending fetch."; |
+ } |
+} |
+ |
ChromotingStats* ChromotingInstance::GetStats() { |
if (!client_.get()) |
return NULL; |