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

Side by Side Diff: remoting/host/security_key/security_key_extension_session.cc

Issue 2856243002: [Chromoting] Add ProcessStatsDispatcher to send process stats to the client
Patch Set: Partially resolve the review comments Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « remoting/base/constants.cc ('k') | remoting/protocol/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "remoting/base/constants.h"
14 #include "remoting/base/logging.h" 15 #include "remoting/base/logging.h"
15 #include "remoting/host/client_session_details.h" 16 #include "remoting/host/client_session_details.h"
16 #include "remoting/host/security_key/security_key_auth_handler.h" 17 #include "remoting/host/security_key/security_key_auth_handler.h"
17 #include "remoting/proto/control.pb.h" 18 #include "remoting/proto/control.pb.h"
18 #include "remoting/protocol/client_stub.h" 19 #include "remoting/protocol/client_stub.h"
19 20
20 namespace { 21 namespace {
21 22
22 // Used as the type attribute of all Security Key protocol::ExtensionMessages.
23 const char kExtensionMessageType[] = "gnubby-auth";
24
25 // SecurityKey extension message data members. 23 // SecurityKey extension message data members.
26 const char kConnectionId[] = "connectionId"; 24 const char kConnectionId[] = "connectionId";
27 const char kControlMessage[] = "control"; 25 const char kControlMessage[] = "control";
28 const char kControlOption[] = "option"; 26 const char kControlOption[] = "option";
29 const char kDataMessage[] = "data"; 27 const char kDataMessage[] = "data";
30 const char kDataPayload[] = "data"; 28 const char kDataPayload[] = "data";
31 const char kErrorMessage[] = "error"; 29 const char kErrorMessage[] = "error";
32 const char kSecurityKeyAuthV1[] = "auth-v1"; 30 const char kSecurityKeyAuthV1[] = "auth-v1";
33 const char kMessageType[] = "type"; 31 const char kMessageType[] = "type";
34 32
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Returns true if the |message| is a Security Key ExtensionMessage. 78 // Returns true if the |message| is a Security Key ExtensionMessage.
81 // This is done so the host does not pass |message| to other HostExtensions. 79 // This is done so the host does not pass |message| to other HostExtensions.
82 // TODO(joedow): Use |client_session_details| to disconnect the session if we 80 // TODO(joedow): Use |client_session_details| to disconnect the session if we
83 // receive an invalid extension message. 81 // receive an invalid extension message.
84 bool SecurityKeyExtensionSession::OnExtensionMessage( 82 bool SecurityKeyExtensionSession::OnExtensionMessage(
85 ClientSessionDetails* client_session_details, 83 ClientSessionDetails* client_session_details,
86 protocol::ClientStub* client_stub, 84 protocol::ClientStub* client_stub,
87 const protocol::ExtensionMessage& message) { 85 const protocol::ExtensionMessage& message) {
88 DCHECK(thread_checker_.CalledOnValidThread()); 86 DCHECK(thread_checker_.CalledOnValidThread());
89 87
90 if (message.type() != kExtensionMessageType) { 88 if (message.type() != kSecurityKeyExtensionMessageType) {
91 return false; 89 return false;
92 } 90 }
93 91
94 std::unique_ptr<base::Value> value = base::JSONReader::Read(message.data()); 92 std::unique_ptr<base::Value> value = base::JSONReader::Read(message.data());
95 base::DictionaryValue* client_message; 93 base::DictionaryValue* client_message;
96 if (!value || !value->GetAsDictionary(&client_message)) { 94 if (!value || !value->GetAsDictionary(&client_message)) {
97 LOG(WARNING) << "Failed to retrieve data from gnubby-auth message."; 95 LOG(WARNING) << "Failed to retrieve data from gnubby-auth message.";
98 return true; 96 return true;
99 } 97 }
100 98
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 std::unique_ptr<base::ListValue> bytes(new base::ListValue()); 186 std::unique_ptr<base::ListValue> bytes(new base::ListValue());
189 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) { 187 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) {
190 bytes->AppendInteger(static_cast<unsigned char>(*i)); 188 bytes->AppendInteger(static_cast<unsigned char>(*i));
191 } 189 }
192 request.Set(kDataPayload, bytes.release()); 190 request.Set(kDataPayload, bytes.release());
193 191
194 std::string request_json; 192 std::string request_json;
195 CHECK(base::JSONWriter::Write(request, &request_json)); 193 CHECK(base::JSONWriter::Write(request, &request_json));
196 194
197 protocol::ExtensionMessage message; 195 protocol::ExtensionMessage message;
198 message.set_type(kExtensionMessageType); 196 message.set_type(kSecurityKeyExtensionMessageType);
199 message.set_data(request_json); 197 message.set_data(request_json);
200 198
201 client_stub_->DeliverHostMessage(message); 199 client_stub_->DeliverHostMessage(message);
202 } 200 }
203 201
204 void SecurityKeyExtensionSession::SetSecurityKeyAuthHandlerForTesting( 202 void SecurityKeyExtensionSession::SetSecurityKeyAuthHandlerForTesting(
205 std::unique_ptr<SecurityKeyAuthHandler> security_key_auth_handler) { 203 std::unique_ptr<SecurityKeyAuthHandler> security_key_auth_handler) {
206 DCHECK(security_key_auth_handler); 204 DCHECK(security_key_auth_handler);
207 205
208 security_key_auth_handler_ = std::move(security_key_auth_handler); 206 security_key_auth_handler_ = std::move(security_key_auth_handler);
209 security_key_auth_handler_->SetSendMessageCallback( 207 security_key_auth_handler_->SetSendMessageCallback(
210 base::Bind(&SecurityKeyExtensionSession::SendMessageToClient, 208 base::Bind(&SecurityKeyExtensionSession::SendMessageToClient,
211 base::Unretained(this))); 209 base::Unretained(this)));
212 } 210 }
213 211
214 } // namespace remoting 212 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/constants.cc ('k') | remoting/protocol/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698