| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/client/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 static base::LazyInstance<base::Lock>::Leaky | 102 static base::LazyInstance<base::Lock>::Leaky |
| 103 g_logging_lock = LAZY_INSTANCE_INITIALIZER; | 103 g_logging_lock = LAZY_INSTANCE_INITIALIZER; |
| 104 | 104 |
| 105 // String sent in the "hello" message to the plugin to describe features. | 105 // String sent in the "hello" message to the plugin to describe features. |
| 106 const char ChromotingInstance::kApiFeatures[] = | 106 const char ChromotingInstance::kApiFeatures[] = |
| 107 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " | 107 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
| 108 "notifyClientDimensions pauseVideo"; | 108 "notifyClientDimensions pauseVideo"; |
| 109 | 109 |
| 110 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 110 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
| 111 ClientConfig* config) { | 111 ClientConfig* config) { |
| 112 if (auth_methods_str == "v1_token") { | 112 std::vector<std::string> auth_methods; |
| 113 config->use_v1_authenticator = true; | 113 base::SplitString(auth_methods_str, ',', &auth_methods); |
| 114 } else { | 114 for (std::vector<std::string>::iterator it = auth_methods.begin(); |
| 115 config->use_v1_authenticator = false; | 115 it != auth_methods.end(); ++it) { |
| 116 | 116 protocol::AuthenticationMethod authentication_method = |
| 117 std::vector<std::string> auth_methods; | 117 protocol::AuthenticationMethod::FromString(*it); |
| 118 base::SplitString(auth_methods_str, ',', &auth_methods); | 118 if (authentication_method.is_valid()) |
| 119 for (std::vector<std::string>::iterator it = auth_methods.begin(); | 119 config->authentication_methods.push_back(authentication_method); |
| 120 it != auth_methods.end(); ++it) { | 120 } |
| 121 protocol::AuthenticationMethod authentication_method = | 121 if (config->authentication_methods.empty()) { |
| 122 protocol::AuthenticationMethod::FromString(*it); | 122 LOG(ERROR) << "No valid authentication methods specified."; |
| 123 if (authentication_method.is_valid()) | 123 return false; |
| 124 config->authentication_methods.push_back(authentication_method); | |
| 125 } | |
| 126 if (config->authentication_methods.empty()) { | |
| 127 LOG(ERROR) << "No valid authentication methods specified."; | |
| 128 return false; | |
| 129 } | |
| 130 } | 124 } |
| 131 | 125 |
| 132 return true; | 126 return true; |
| 133 } | 127 } |
| 134 | 128 |
| 135 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) | 129 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) |
| 136 : pp::Instance(pp_instance), | 130 : pp::Instance(pp_instance), |
| 137 initialized_(false), | 131 initialized_(false), |
| 138 plugin_message_loop_( | 132 plugin_message_loop_( |
| 139 new PluginMessageLoopProxy(&plugin_thread_delegate_)), | 133 new PluginMessageLoopProxy(&plugin_thread_delegate_)), |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 PostChromotingMessage("logDebugMessage", data.Pass()); | 650 PostChromotingMessage("logDebugMessage", data.Pass()); |
| 657 g_logging_to_plugin = false; | 651 g_logging_to_plugin = false; |
| 658 } | 652 } |
| 659 | 653 |
| 660 bool ChromotingInstance::IsConnected() { | 654 bool ChromotingInstance::IsConnected() { |
| 661 return host_connection_.get() && | 655 return host_connection_.get() && |
| 662 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 656 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
| 663 } | 657 } |
| 664 | 658 |
| 665 } // namespace remoting | 659 } // namespace remoting |
| OLD | NEW |