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

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

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests. Created 5 years, 4 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
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } else if (type == "disconnect") { 108 } else if (type == "disconnect") {
109 ProcessDisconnect(*message_dict, response.Pass()); 109 ProcessDisconnect(*message_dict, response.Pass());
110 } else { 110 } else {
111 SendErrorAndExit(response.Pass(), "Unsupported request type: " + type); 111 SendErrorAndExit(response.Pass(), "Unsupported request type: " + type);
112 } 112 }
113 } 113 }
114 114
115 void It2MeNativeMessagingHost::Start(Client* client) { 115 void It2MeNativeMessagingHost::Start(Client* client) {
116 DCHECK(task_runner()->BelongsToCurrentThread()); 116 DCHECK(task_runner()->BelongsToCurrentThread());
117 client_ = client; 117 client_ = client;
118 #if !defined(OS_CHROMEOS)
119 log_message_handler_.reset(
120 new LogMessageHandler(
121 base::Bind(&It2MeNativeMessagingHost::SendMessageToClient,
122 base::Unretained(this))));
123 #endif // !defined(OS_CHROMEOS)
118 } 124 }
119 125
120 void It2MeNativeMessagingHost::SendMessageToClient( 126 void It2MeNativeMessagingHost::SendMessageToClient(
121 scoped_ptr<base::DictionaryValue> message) const { 127 scoped_ptr<base::Value> message) const {
122 DCHECK(task_runner()->BelongsToCurrentThread()); 128 DCHECK(task_runner()->BelongsToCurrentThread());
123 std::string message_json; 129 std::string message_json;
124 base::JSONWriter::Write(*message, &message_json); 130 base::JSONWriter::Write(*message, &message_json);
125 client_->PostMessageFromNativeHost(message_json); 131 client_->PostMessageFromNativeHost(message_json);
126 } 132 }
127 133
128 void It2MeNativeMessagingHost::ProcessHello( 134 void It2MeNativeMessagingHost::ProcessHello(
129 const base::DictionaryValue& message, 135 const base::DictionaryValue& message,
130 scoped_ptr<base::DictionaryValue> response) const { 136 scoped_ptr<base::DictionaryValue> response) const {
131 DCHECK(task_runner()->BelongsToCurrentThread()); 137 DCHECK(task_runner()->BelongsToCurrentThread());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return host_context_->ui_task_runner(); 325 return host_context_->ui_task_runner();
320 } 326 }
321 327
322 /* static */ 328 /* static */
323 std::string It2MeNativeMessagingHost::HostStateToString( 329 std::string It2MeNativeMessagingHost::HostStateToString(
324 It2MeHostState host_state) { 330 It2MeHostState host_state) {
325 return ValueToName(kIt2MeHostStates, host_state); 331 return ValueToName(kIt2MeHostStates, host_state);
326 } 332 }
327 333
328 } // namespace remoting 334 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698