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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 static base::LazyInstance<base::Lock>::Leaky | 103 static base::LazyInstance<base::Lock>::Leaky |
104 g_logging_lock = LAZY_INSTANCE_INITIALIZER; | 104 g_logging_lock = LAZY_INSTANCE_INITIALIZER; |
105 | 105 |
106 // String sent in the "hello" message to the plugin to describe features. | 106 // String sent in the "hello" message to the plugin to describe features. |
107 const char ChromotingInstance::kApiFeatures[] = | 107 const char ChromotingInstance::kApiFeatures[] = |
108 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " | 108 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
109 "notifyClientDimensions pauseVideo"; | 109 "notifyClientDimensions pauseVideo"; |
110 | 110 |
111 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 111 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
112 ClientConfig* config) { | 112 ClientConfig* config) { |
113 if (auth_methods_str == "v1_token") { | 113 std::vector<std::string> auth_methods; |
114 config->use_v1_authenticator = true; | 114 base::SplitString(auth_methods_str, ',', &auth_methods); |
115 } else { | 115 for (std::vector<std::string>::iterator it = auth_methods.begin(); |
116 config->use_v1_authenticator = false; | 116 it != auth_methods.end(); ++it) { |
117 | 117 protocol::AuthenticationMethod authentication_method = |
118 std::vector<std::string> auth_methods; | 118 protocol::AuthenticationMethod::FromString(*it); |
119 base::SplitString(auth_methods_str, ',', &auth_methods); | 119 if (authentication_method.is_valid()) |
120 for (std::vector<std::string>::iterator it = auth_methods.begin(); | 120 config->authentication_methods.push_back(authentication_method); |
121 it != auth_methods.end(); ++it) { | 121 } |
122 protocol::AuthenticationMethod authentication_method = | 122 if (config->authentication_methods.empty()) { |
123 protocol::AuthenticationMethod::FromString(*it); | 123 LOG(ERROR) << "No valid authentication methods specified."; |
124 if (authentication_method.is_valid()) | 124 return false; |
125 config->authentication_methods.push_back(authentication_method); | |
126 } | |
127 if (config->authentication_methods.empty()) { | |
128 LOG(ERROR) << "No valid authentication methods specified."; | |
129 return false; | |
130 } | |
131 } | 125 } |
132 | 126 |
133 return true; | 127 return true; |
134 } | 128 } |
135 | 129 |
136 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) | 130 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) |
137 : pp::InstancePrivate(pp_instance), | 131 : pp::InstancePrivate(pp_instance), |
138 initialized_(false), | 132 initialized_(false), |
139 plugin_message_loop_( | 133 plugin_message_loop_( |
140 new PluginMessageLoopProxy(&plugin_thread_delegate_)), | 134 new PluginMessageLoopProxy(&plugin_thread_delegate_)), |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 } | 686 } |
693 g_logging_to_plugin = false; | 687 g_logging_to_plugin = false; |
694 } | 688 } |
695 | 689 |
696 bool ChromotingInstance::IsConnected() { | 690 bool ChromotingInstance::IsConnected() { |
697 return host_connection_.get() && | 691 return host_connection_.get() && |
698 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 692 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
699 } | 693 } |
700 | 694 |
701 } // namespace remoting | 695 } // namespace remoting |
OLD | NEW |