OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/host/security_key/security_key_extension_session.h" | 5 #include "remoting/host/security_key/security_key_extension_session.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
12 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
13 #include "base/values.h" | 16 #include "base/values.h" |
14 #include "remoting/base/logging.h" | 17 #include "remoting/base/logging.h" |
15 #include "remoting/host/client_session_details.h" | 18 #include "remoting/host/client_session_details.h" |
16 #include "remoting/host/security_key/security_key_auth_handler.h" | 19 #include "remoting/host/security_key/security_key_auth_handler.h" |
17 #include "remoting/proto/control.pb.h" | 20 #include "remoting/proto/control.pb.h" |
18 #include "remoting/protocol/client_stub.h" | 21 #include "remoting/protocol/client_stub.h" |
19 | 22 |
20 namespace { | 23 namespace { |
21 | 24 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void SecurityKeyExtensionSession::SendMessageToClient( | 183 void SecurityKeyExtensionSession::SendMessageToClient( |
181 int connection_id, | 184 int connection_id, |
182 const std::string& data) const { | 185 const std::string& data) const { |
183 DCHECK(thread_checker_.CalledOnValidThread()); | 186 DCHECK(thread_checker_.CalledOnValidThread()); |
184 DCHECK(client_stub_); | 187 DCHECK(client_stub_); |
185 | 188 |
186 base::DictionaryValue request; | 189 base::DictionaryValue request; |
187 request.SetString(kMessageType, kDataMessage); | 190 request.SetString(kMessageType, kDataMessage); |
188 request.SetInteger(kConnectionId, connection_id); | 191 request.SetInteger(kConnectionId, connection_id); |
189 | 192 |
190 std::unique_ptr<base::ListValue> bytes(new base::ListValue()); | 193 auto bytes = base::MakeUnique<base::ListValue>(); |
191 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) { | 194 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) { |
192 bytes->AppendInteger(static_cast<unsigned char>(*i)); | 195 bytes->AppendInteger(static_cast<unsigned char>(*i)); |
193 } | 196 } |
194 request.Set(kDataPayload, bytes.release()); | 197 request.Set(kDataPayload, std::move(bytes)); |
195 | 198 |
196 std::string request_json; | 199 std::string request_json; |
197 CHECK(base::JSONWriter::Write(request, &request_json)); | 200 CHECK(base::JSONWriter::Write(request, &request_json)); |
198 | 201 |
199 protocol::ExtensionMessage message; | 202 protocol::ExtensionMessage message; |
200 message.set_type(kExtensionMessageType); | 203 message.set_type(kExtensionMessageType); |
201 message.set_data(request_json); | 204 message.set_data(request_json); |
202 | 205 |
203 client_stub_->DeliverHostMessage(message); | 206 client_stub_->DeliverHostMessage(message); |
204 } | 207 } |
205 | 208 |
206 void SecurityKeyExtensionSession::SetSecurityKeyAuthHandlerForTesting( | 209 void SecurityKeyExtensionSession::SetSecurityKeyAuthHandlerForTesting( |
207 std::unique_ptr<SecurityKeyAuthHandler> security_key_auth_handler) { | 210 std::unique_ptr<SecurityKeyAuthHandler> security_key_auth_handler) { |
208 DCHECK(security_key_auth_handler); | 211 DCHECK(security_key_auth_handler); |
209 | 212 |
210 security_key_auth_handler_ = std::move(security_key_auth_handler); | 213 security_key_auth_handler_ = std::move(security_key_auth_handler); |
211 security_key_auth_handler_->SetSendMessageCallback( | 214 security_key_auth_handler_->SetSendMessageCallback( |
212 base::Bind(&SecurityKeyExtensionSession::SendMessageToClient, | 215 base::Bind(&SecurityKeyExtensionSession::SendMessageToClient, |
213 base::Unretained(this))); | 216 base::Unretained(this))); |
214 } | 217 } |
215 | 218 |
216 } // namespace remoting | 219 } // namespace remoting |
OLD | NEW |