| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // codes are obtained "out-of-band", i.e., not through an OAuth redirect). | 46 // codes are obtained "out-of-band", i.e., not through an OAuth redirect). |
| 47 const char* kServiceAccountRedirectUri = "oob"; | 47 const char* kServiceAccountRedirectUri = "oob"; |
| 48 | 48 |
| 49 // Features supported in addition to the base protocol. | 49 // Features supported in addition to the base protocol. |
| 50 const char* kSupportedFeatures[] = { | 50 const char* kSupportedFeatures[] = { |
| 51 "pairingRegistry", | 51 "pairingRegistry", |
| 52 "oauthClient" | 52 "oauthClient" |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Helper to extract the "config" part of a message as a DictionaryValue. | 55 // Helper to extract the "config" part of a message as a DictionaryValue. |
| 56 // Returns NULL on failure, and logs an error message. | 56 // Returns nullptr on failure, and logs an error message. |
| 57 scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage( | 57 scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage( |
| 58 scoped_ptr<base::DictionaryValue> message) { | 58 scoped_ptr<base::DictionaryValue> message) { |
| 59 scoped_ptr<base::DictionaryValue> result; | 59 scoped_ptr<base::DictionaryValue> result; |
| 60 const base::DictionaryValue* config_dict; | 60 const base::DictionaryValue* config_dict; |
| 61 if (message->GetDictionary("config", &config_dict)) { | 61 if (message->GetDictionary("config", &config_dict)) { |
| 62 result.reset(config_dict->DeepCopy()); | 62 result.reset(config_dict->DeepCopy()); |
| 63 } else { | 63 } else { |
| 64 LOG(ERROR) << "'config' dictionary not found"; | 64 LOG(ERROR) << "'config' dictionary not found"; |
| 65 } | 65 } |
| 66 return result.Pass(); | 66 return result.Pass(); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 const std::string& user_email, | 498 const std::string& user_email, |
| 499 const std::string& refresh_token) { | 499 const std::string& refresh_token) { |
| 500 DCHECK(thread_checker_.CalledOnValidThread()); | 500 DCHECK(thread_checker_.CalledOnValidThread()); |
| 501 | 501 |
| 502 response->SetString("userEmail", user_email); | 502 response->SetString("userEmail", user_email); |
| 503 response->SetString("refreshToken", refresh_token); | 503 response->SetString("refreshToken", refresh_token); |
| 504 channel_->SendMessage(response.Pass()); | 504 channel_->SendMessage(response.Pass()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 void Me2MeNativeMessagingHost::OnError() { | 507 void Me2MeNativeMessagingHost::OnError() { |
| 508 // Trigger a host shutdown by sending a NULL message. | 508 // Trigger a host shutdown by sending a nullptr message. |
| 509 channel_->SendMessage(nullptr); | 509 channel_->SendMessage(nullptr); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void Me2MeNativeMessagingHost::Stop() { | 512 void Me2MeNativeMessagingHost::Stop() { |
| 513 DCHECK(thread_checker_.CalledOnValidThread()); | 513 DCHECK(thread_checker_.CalledOnValidThread()); |
| 514 | 514 |
| 515 if (!quit_closure_.is_null()) | 515 if (!quit_closure_.is_null()) |
| 516 base::ResetAndReturn(&quit_closure_).Run(); | 516 base::ResetAndReturn(&quit_closure_).Run(); |
| 517 } | 517 } |
| 518 | 518 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 537 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( | 537 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( |
| 538 scoped_ptr<base::DictionaryValue> message) { | 538 scoped_ptr<base::DictionaryValue> message) { |
| 539 DCHECK(thread_checker_.CalledOnValidThread()); | 539 DCHECK(thread_checker_.CalledOnValidThread()); |
| 540 | 540 |
| 541 EnsureElevatedHostCreated(); | 541 EnsureElevatedHostCreated(); |
| 542 | 542 |
| 543 // elevated_channel_ will be null if user rejects the UAC request. | 543 // elevated_channel_ will be null if user rejects the UAC request. |
| 544 if (elevated_channel_) | 544 if (elevated_channel_) |
| 545 elevated_channel_->SendMessage(message.Pass()); | 545 elevated_channel_->SendMessage(message.Pass()); |
| 546 | 546 |
| 547 return elevated_channel_ != NULL; | 547 return elevated_channel_ != nullptr; |
| 548 } | 548 } |
| 549 | 549 |
| 550 void Me2MeNativeMessagingHost::EnsureElevatedHostCreated() { | 550 void Me2MeNativeMessagingHost::EnsureElevatedHostCreated() { |
| 551 DCHECK(thread_checker_.CalledOnValidThread()); | 551 DCHECK(thread_checker_.CalledOnValidThread()); |
| 552 DCHECK(needs_elevation_); | 552 DCHECK(needs_elevation_); |
| 553 | 553 |
| 554 if (elevated_channel_) | 554 if (elevated_channel_) |
| 555 return; | 555 return; |
| 556 | 556 |
| 557 // presubmit: allow wstring | 557 // presubmit: allow wstring |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 660 |
| 661 if (!ShellExecuteEx(&info)) { | 661 if (!ShellExecuteEx(&info)) { |
| 662 DWORD error = ::GetLastError(); | 662 DWORD error = ::GetLastError(); |
| 663 PLOG(ERROR) << "Unable to launch '" << binary.value() << "'"; | 663 PLOG(ERROR) << "Unable to launch '" << binary.value() << "'"; |
| 664 if (error != ERROR_CANCELLED) { | 664 if (error != ERROR_CANCELLED) { |
| 665 OnError(); | 665 OnError(); |
| 666 } | 666 } |
| 667 return; | 667 return; |
| 668 } | 668 } |
| 669 | 669 |
| 670 if (!::ConnectNamedPipe(delegate_write_handle.Get(), NULL)) { | 670 if (!::ConnectNamedPipe(delegate_write_handle.Get(), nullptr)) { |
| 671 DWORD error = ::GetLastError(); | 671 DWORD error = ::GetLastError(); |
| 672 if (error != ERROR_PIPE_CONNECTED) { | 672 if (error != ERROR_PIPE_CONNECTED) { |
| 673 PLOG(ERROR) << "Unable to connect '" << input_pipe_name << "'"; | 673 PLOG(ERROR) << "Unable to connect '" << input_pipe_name << "'"; |
| 674 OnError(); | 674 OnError(); |
| 675 return; | 675 return; |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 | 678 |
| 679 if (!::ConnectNamedPipe(delegate_read_handle.Get(), NULL)) { | 679 if (!::ConnectNamedPipe(delegate_read_handle.Get(), nullptr)) { |
| 680 DWORD error = ::GetLastError(); | 680 DWORD error = ::GetLastError(); |
| 681 if (error != ERROR_PIPE_CONNECTED) { | 681 if (error != ERROR_PIPE_CONNECTED) { |
| 682 PLOG(ERROR) << "Unable to connect '" << output_pipe_name << "'"; | 682 PLOG(ERROR) << "Unable to connect '" << output_pipe_name << "'"; |
| 683 OnError(); | 683 OnError(); |
| 684 return; | 684 return; |
| 685 } | 685 } |
| 686 } | 686 } |
| 687 | 687 |
| 688 // Set up the native messaging channel to talk to the elevated host. | 688 // Set up the native messaging channel to talk to the elevated host. |
| 689 // Note that input for the elevated channel is output for the elevated host. | 689 // Note that input for the elevated channel is output for the elevated host. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 711 | 711 |
| 712 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( | 712 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( |
| 713 scoped_ptr<base::DictionaryValue> message) { | 713 scoped_ptr<base::DictionaryValue> message) { |
| 714 NOTREACHED(); | 714 NOTREACHED(); |
| 715 return false; | 715 return false; |
| 716 } | 716 } |
| 717 | 717 |
| 718 #endif // !defined(OS_WIN) | 718 #endif // !defined(OS_WIN) |
| 719 | 719 |
| 720 } // namespace remoting | 720 } // namespace remoting |
| OLD | NEW |