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/me2me_native_messaging_host.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host.h" |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 response->SetString("privateKey", key_pair->ToString()); | 273 response->SetString("privateKey", key_pair->ToString()); |
274 response->SetString("publicKey", key_pair->GetPublicKey()); | 274 response->SetString("publicKey", key_pair->GetPublicKey()); |
275 channel_->SendMessage(response.Pass()); | 275 channel_->SendMessage(response.Pass()); |
276 } | 276 } |
277 | 277 |
278 void Me2MeNativeMessagingHost::ProcessUpdateDaemonConfig( | 278 void Me2MeNativeMessagingHost::ProcessUpdateDaemonConfig( |
279 scoped_ptr<base::DictionaryValue> message, | 279 scoped_ptr<base::DictionaryValue> message, |
280 scoped_ptr<base::DictionaryValue> response) { | 280 scoped_ptr<base::DictionaryValue> response) { |
281 DCHECK(thread_checker_.CalledOnValidThread()); | 281 DCHECK(thread_checker_.CalledOnValidThread()); |
282 | 282 |
| 283 if (needs_elevation_) { |
| 284 if (!DelegateToElevatedHost(message.Pass())) |
| 285 SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); |
| 286 return; |
| 287 } |
| 288 |
283 scoped_ptr<base::DictionaryValue> config_dict = | 289 scoped_ptr<base::DictionaryValue> config_dict = |
284 ConfigDictionaryFromMessage(message.Pass()); | 290 ConfigDictionaryFromMessage(message.Pass()); |
285 if (!config_dict) { | 291 if (!config_dict) { |
286 OnError(); | 292 OnError(); |
287 return; | 293 return; |
288 } | 294 } |
289 | 295 |
290 daemon_controller_->UpdateConfig( | 296 daemon_controller_->UpdateConfig( |
291 config_dict.Pass(), | 297 config_dict.Pass(), |
292 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, | 298 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 daemon_controller_->GetUsageStatsConsent( | 332 daemon_controller_->GetUsageStatsConsent( |
327 base::Bind(&Me2MeNativeMessagingHost::SendUsageStatsConsentResponse, | 333 base::Bind(&Me2MeNativeMessagingHost::SendUsageStatsConsentResponse, |
328 weak_ptr_, base::Passed(&response))); | 334 weak_ptr_, base::Passed(&response))); |
329 } | 335 } |
330 | 336 |
331 void Me2MeNativeMessagingHost::ProcessStartDaemon( | 337 void Me2MeNativeMessagingHost::ProcessStartDaemon( |
332 scoped_ptr<base::DictionaryValue> message, | 338 scoped_ptr<base::DictionaryValue> message, |
333 scoped_ptr<base::DictionaryValue> response) { | 339 scoped_ptr<base::DictionaryValue> response) { |
334 DCHECK(thread_checker_.CalledOnValidThread()); | 340 DCHECK(thread_checker_.CalledOnValidThread()); |
335 | 341 |
| 342 if (needs_elevation_) { |
| 343 if (!DelegateToElevatedHost(message.Pass())) |
| 344 SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); |
| 345 return; |
| 346 } |
| 347 |
336 bool consent; | 348 bool consent; |
337 if (!message->GetBoolean("consent", &consent)) { | 349 if (!message->GetBoolean("consent", &consent)) { |
338 LOG(ERROR) << "'consent' not found."; | 350 LOG(ERROR) << "'consent' not found."; |
339 OnError(); | 351 OnError(); |
340 return; | 352 return; |
341 } | 353 } |
342 | 354 |
343 scoped_ptr<base::DictionaryValue> config_dict = | 355 scoped_ptr<base::DictionaryValue> config_dict = |
344 ConfigDictionaryFromMessage(message.Pass()); | 356 ConfigDictionaryFromMessage(message.Pass()); |
345 if (!config_dict) { | 357 if (!config_dict) { |
346 OnError(); | 358 OnError(); |
347 return; | 359 return; |
348 } | 360 } |
349 | 361 |
350 daemon_controller_->SetConfigAndStart( | 362 daemon_controller_->SetConfigAndStart( |
351 config_dict.Pass(), consent, | 363 config_dict.Pass(), consent, |
352 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, | 364 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, |
353 base::Passed(&response))); | 365 base::Passed(&response))); |
354 } | 366 } |
355 | 367 |
356 void Me2MeNativeMessagingHost::ProcessStopDaemon( | 368 void Me2MeNativeMessagingHost::ProcessStopDaemon( |
357 scoped_ptr<base::DictionaryValue> message, | 369 scoped_ptr<base::DictionaryValue> message, |
358 scoped_ptr<base::DictionaryValue> response) { | 370 scoped_ptr<base::DictionaryValue> response) { |
359 DCHECK(thread_checker_.CalledOnValidThread()); | 371 DCHECK(thread_checker_.CalledOnValidThread()); |
360 | 372 |
| 373 if (needs_elevation_) { |
| 374 if (!DelegateToElevatedHost(message.Pass())) |
| 375 SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); |
| 376 return; |
| 377 } |
| 378 |
361 daemon_controller_->Stop( | 379 daemon_controller_->Stop( |
362 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, | 380 base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, |
363 base::Passed(&response))); | 381 base::Passed(&response))); |
364 } | 382 } |
365 | 383 |
366 void Me2MeNativeMessagingHost::ProcessGetDaemonState( | 384 void Me2MeNativeMessagingHost::ProcessGetDaemonState( |
367 scoped_ptr<base::DictionaryValue> message, | 385 scoped_ptr<base::DictionaryValue> message, |
368 scoped_ptr<base::DictionaryValue> response) { | 386 scoped_ptr<base::DictionaryValue> response) { |
369 DCHECK(thread_checker_.CalledOnValidThread()); | 387 DCHECK(thread_checker_.CalledOnValidThread()); |
370 | 388 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 731 |
714 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( | 732 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( |
715 scoped_ptr<base::DictionaryValue> message) { | 733 scoped_ptr<base::DictionaryValue> message) { |
716 NOTREACHED(); | 734 NOTREACHED(); |
717 return false; | 735 return false; |
718 } | 736 } |
719 | 737 |
720 #endif // !defined(OS_WIN) | 738 #endif // !defined(OS_WIN) |
721 | 739 |
722 } // namespace remoting | 740 } // namespace remoting |
OLD | NEW |