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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host.cc

Issue 615543004: Fix remoting NM hosts to verify that incoming messages are dictionaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | remoting/host/native_messaging/pipe_messaging_channel.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/it2me/it2me_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 DCHECK(!quit_closure.is_null()); 80 DCHECK(!quit_closure.is_null());
81 81
82 quit_closure_ = quit_closure; 82 quit_closure_ = quit_closure;
83 83
84 channel_->Start(this); 84 channel_->Start(this);
85 } 85 }
86 86
87 void It2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) { 87 void It2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) {
88 DCHECK(task_runner()->BelongsToCurrentThread()); 88 DCHECK(task_runner()->BelongsToCurrentThread());
89 89
90 if (message->GetType() != base::Value::TYPE_DICTIONARY) {
91 LOG(ERROR) << "Received a message that's not a dictionary.";
92 channel_->SendMessage(nullptr);
93 return;
94 }
95
90 scoped_ptr<base::DictionaryValue> message_dict( 96 scoped_ptr<base::DictionaryValue> message_dict(
91 static_cast<base::DictionaryValue*>(message.release())); 97 static_cast<base::DictionaryValue*>(message.release()));
92 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); 98 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue());
93 99
94 // If the client supplies an ID, it will expect it in the response. This 100 // If the client supplies an ID, it will expect it in the response. This
95 // might be a string or a number, so cope with both. 101 // might be a string or a number, so cope with both.
96 const base::Value* id; 102 const base::Value* id;
97 if (message_dict->Get("id", &id)) 103 if (message_dict->Get("id", &id))
98 response->Set("id", id->DeepCopy()); 104 response->Set("id", id->DeepCopy());
99 105
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 309 }
304 310
305 /* static */ 311 /* static */
306 std::string It2MeNativeMessagingHost::HostStateToString( 312 std::string It2MeNativeMessagingHost::HostStateToString(
307 It2MeHostState host_state) { 313 It2MeHostState host_state) {
308 return ValueToName(kIt2MeHostStates, host_state); 314 return ValueToName(kIt2MeHostStates, host_state);
309 } 315 }
310 316
311 } // namespace remoting 317 } // namespace remoting
312 318
OLDNEW
« no previous file with comments | « no previous file | remoting/host/native_messaging/pipe_messaging_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698