OLD | NEW |
---|---|
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/setup/native_messaging_host.h" | 5 #include "remoting/host/setup/native_messaging_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 scoped_ptr<base::DictionaryValue> response) { | 234 scoped_ptr<base::DictionaryValue> response) { |
235 daemon_controller_->Stop( | 235 daemon_controller_->Stop( |
236 base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), | 236 base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
237 base::Passed(&response))); | 237 base::Passed(&response))); |
238 return true; | 238 return true; |
239 } | 239 } |
240 | 240 |
241 bool NativeMessagingHost::ProcessGetDaemonState( | 241 bool NativeMessagingHost::ProcessGetDaemonState( |
242 const base::DictionaryValue& message, | 242 const base::DictionaryValue& message, |
243 scoped_ptr<base::DictionaryValue> response) { | 243 scoped_ptr<base::DictionaryValue> response) { |
244 // TODO(lambroslambrou): Send the state as a string instead of an integer, | |
245 // and update the web-app accordingly. | |
246 DaemonController::State state = daemon_controller_->GetState(); | 244 DaemonController::State state = daemon_controller_->GetState(); |
247 response->SetInteger("state", state); | 245 switch (state) { |
246 case DaemonController::STATE_NOT_IMPLEMENTED: | |
Sergey Ulanov
2013/05/30 23:14:52
Take a look at "remoting/protocol/name_value_map.h
Lambros
2013/05/31 01:32:56
Not worth moving, I'm only using value->name direc
| |
247 response->SetString("state", DaemonController::kStateNotImplemented); | |
248 break; | |
249 case DaemonController::STATE_NOT_INSTALLED: | |
250 response->SetString("state", DaemonController::kStateNotInstalled); | |
251 break; | |
252 case DaemonController::STATE_INSTALLING: | |
253 response->SetString("state", DaemonController::kStateInstalling); | |
254 break; | |
255 case DaemonController::STATE_STOPPED: | |
256 response->SetString("state", DaemonController::kStateStopped); | |
257 break; | |
258 case DaemonController::STATE_STARTING: | |
259 response->SetString("state", DaemonController::kStateStarting); | |
260 break; | |
261 case DaemonController::STATE_STARTED: | |
262 response->SetString("state", DaemonController::kStateStarted); | |
263 break; | |
264 case DaemonController::STATE_STOPPING: | |
265 response->SetString("state", DaemonController::kStateStopping); | |
266 break; | |
267 case DaemonController::STATE_UNKNOWN: | |
268 response->SetString("state", DaemonController::kStateUnknown); | |
269 break; | |
270 } | |
248 SendResponse(response.Pass()); | 271 SendResponse(response.Pass()); |
249 return true; | 272 return true; |
250 } | 273 } |
251 | 274 |
252 void NativeMessagingHost::SendResponse( | 275 void NativeMessagingHost::SendResponse( |
253 scoped_ptr<base::DictionaryValue> response) { | 276 scoped_ptr<base::DictionaryValue> response) { |
254 if (!caller_task_runner_->BelongsToCurrentThread()) { | 277 if (!caller_task_runner_->BelongsToCurrentThread()) { |
255 caller_task_runner_->PostTask( | 278 caller_task_runner_->PostTask( |
256 FROM_HERE, base::Bind(&NativeMessagingHost::SendResponse, weak_ptr_, | 279 FROM_HERE, base::Bind(&NativeMessagingHost::SendResponse, weak_ptr_, |
257 base::Passed(&response))); | 280 base::Passed(&response))); |
(...skipping 18 matching lines...) Expand all Loading... | |
276 bool set_by_policy) { | 299 bool set_by_policy) { |
277 response->SetBoolean("supported", supported); | 300 response->SetBoolean("supported", supported); |
278 response->SetBoolean("allowed", allowed); | 301 response->SetBoolean("allowed", allowed); |
279 response->SetBoolean("set_by_policy", set_by_policy); | 302 response->SetBoolean("set_by_policy", set_by_policy); |
280 SendResponse(response.Pass()); | 303 SendResponse(response.Pass()); |
281 } | 304 } |
282 | 305 |
283 void NativeMessagingHost::SendAsyncResult( | 306 void NativeMessagingHost::SendAsyncResult( |
284 scoped_ptr<base::DictionaryValue> response, | 307 scoped_ptr<base::DictionaryValue> response, |
285 DaemonController::AsyncResult result) { | 308 DaemonController::AsyncResult result) { |
286 // TODO(lambroslambrou): Send the result as a string instead of an integer, | 309 switch (result) { |
287 // and update the web-app accordingly. See http://crbug.com/232135. | 310 case DaemonController::RESULT_OK: |
288 response->SetInteger("result", result); | 311 response->SetString("result", DaemonController::kResultOk); |
312 break; | |
313 case DaemonController::RESULT_FAILED: | |
314 response->SetString("result", DaemonController::kResultFailed); | |
315 break; | |
316 case DaemonController::RESULT_CANCELLED: | |
317 response->SetString("result", DaemonController::kResultCancelled); | |
318 break; | |
319 case DaemonController::RESULT_FAILED_DIRECTORY: | |
320 response->SetString("result", DaemonController::kResultFailedDirectory); | |
321 break; | |
322 } | |
289 SendResponse(response.Pass()); | 323 SendResponse(response.Pass()); |
290 } | 324 } |
291 | 325 |
292 } // namespace remoting | 326 } // namespace remoting |
OLD | NEW |