| 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" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/stringize_macros.h" | 14 #include "base/strings/stringize_macros.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "google_apis/gaia/gaia_oauth_client.h" | 19 #include "google_apis/gaia/gaia_oauth_client.h" |
| 20 #include "google_apis/google_api_keys.h" | 20 #include "google_apis/google_api_keys.h" |
| 21 #include "ipc/ipc_channel.h" | 21 #include "ipc/ipc_channel.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 #include "remoting/base/rsa_key_pair.h" | 23 #include "remoting/base/rsa_key_pair.h" |
| 24 #include "remoting/host/native_messaging/pipe_messaging_channel.h" |
| 24 #include "remoting/host/pin_hash.h" | 25 #include "remoting/host/pin_hash.h" |
| 25 #include "remoting/host/setup/oauth_client.h" | 26 #include "remoting/host/setup/oauth_client.h" |
| 26 #include "remoting/protocol/pairing_registry.h" | 27 #include "remoting/protocol/pairing_registry.h" |
| 27 | 28 |
| 28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 29 #include <shellapi.h> | 30 #include <shellapi.h> |
| 30 #include "base/win/win_util.h" | 31 #include "base/win/win_util.h" |
| 31 #include "remoting/host/win/security_descriptor.h" | 32 #include "remoting/host/win/security_descriptor.h" |
| 32 #endif // defined(OS_WIN) | 33 #endif // defined(OS_WIN) |
| 33 | 34 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return result.Pass(); | 66 return result.Pass(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace | 69 } // namespace |
| 69 | 70 |
| 70 namespace remoting { | 71 namespace remoting { |
| 71 | 72 |
| 72 Me2MeNativeMessagingHost::Me2MeNativeMessagingHost( | 73 Me2MeNativeMessagingHost::Me2MeNativeMessagingHost( |
| 73 bool needs_elevation, | 74 bool needs_elevation, |
| 74 intptr_t parent_window_handle, | 75 intptr_t parent_window_handle, |
| 75 scoped_ptr<NativeMessagingChannel> channel, | 76 scoped_ptr<extensions::NativeMessagingChannel> channel, |
| 76 scoped_refptr<DaemonController> daemon_controller, | 77 scoped_refptr<DaemonController> daemon_controller, |
| 77 scoped_refptr<protocol::PairingRegistry> pairing_registry, | 78 scoped_refptr<protocol::PairingRegistry> pairing_registry, |
| 78 scoped_ptr<OAuthClient> oauth_client) | 79 scoped_ptr<OAuthClient> oauth_client) |
| 79 : needs_elevation_(needs_elevation), | 80 : needs_elevation_(needs_elevation), |
| 80 parent_window_handle_(parent_window_handle), | 81 parent_window_handle_(parent_window_handle), |
| 81 channel_(channel.Pass()), | 82 channel_(channel.Pass()), |
| 82 daemon_controller_(daemon_controller), | 83 daemon_controller_(daemon_controller), |
| 83 pairing_registry_(pairing_registry), | 84 pairing_registry_(pairing_registry), |
| 84 oauth_client_(oauth_client.Pass()), | 85 oauth_client_(oauth_client.Pass()), |
| 85 weak_factory_(this) { | 86 weak_factory_(this) { |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 if (!::ConnectNamedPipe(delegate_read_handle.Get(), NULL)) { | 652 if (!::ConnectNamedPipe(delegate_read_handle.Get(), NULL)) { |
| 652 DWORD error = ::GetLastError(); | 653 DWORD error = ::GetLastError(); |
| 653 if (error != ERROR_PIPE_CONNECTED) { | 654 if (error != ERROR_PIPE_CONNECTED) { |
| 654 PLOG(ERROR) << "Unable to connect '" << output_pipe_name << "'"; | 655 PLOG(ERROR) << "Unable to connect '" << output_pipe_name << "'"; |
| 655 OnError(); | 656 OnError(); |
| 656 return; | 657 return; |
| 657 } | 658 } |
| 658 } | 659 } |
| 659 | 660 |
| 660 // Set up the native messaging channel to talk to the elevated host. | 661 // Set up the native messaging channel to talk to the elevated host. |
| 661 // Note that input for the elevate channel is output forthe elevated host. | 662 // Note that input for the elevate channel is output for the elevated host. |
| 662 elevated_channel_.reset(new NativeMessagingChannel( | 663 scoped_ptr<PipeMessagingChannel> channel = new PipeMessagingChannel( |
| 663 base::File(delegate_read_handle.Take()), | 664 base::File(delegate_read_handle.Take()), |
| 664 base::File(delegate_write_handle.Take()))); | 665 base::File(delegate_write_handle.Take())); |
| 666 elevated_channel_.reset(channel.PassAs<extensions::NativeMessagingChannel>()); |
| 665 | 667 |
| 666 elevated_channel_->Start( | 668 elevated_channel_->Start( |
| 667 base::Bind(&Me2MeNativeMessagingHost::ProcessDelegateResponse, weak_ptr_), | 669 base::Bind(&Me2MeNativeMessagingHost::ProcessDelegateResponse, weak_ptr_), |
| 668 base::Bind(&Me2MeNativeMessagingHost::Stop, weak_ptr_)); | 670 base::Bind(&Me2MeNativeMessagingHost::Stop, weak_ptr_)); |
| 669 | 671 |
| 670 elevated_host_timer_.Start( | 672 elevated_host_timer_.Start( |
| 671 FROM_HERE, base::TimeDelta::FromSeconds(kElevatedHostTimeoutSeconds), | 673 FROM_HERE, base::TimeDelta::FromSeconds(kElevatedHostTimeoutSeconds), |
| 672 this, &Me2MeNativeMessagingHost::DisconnectElevatedHost); | 674 this, &Me2MeNativeMessagingHost::DisconnectElevatedHost); |
| 673 } | 675 } |
| 674 | 676 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 691 | 693 |
| 692 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( | 694 bool Me2MeNativeMessagingHost::DelegateToElevatedHost( |
| 693 scoped_ptr<base::DictionaryValue> message) { | 695 scoped_ptr<base::DictionaryValue> message) { |
| 694 NOTREACHED(); | 696 NOTREACHED(); |
| 695 return false; | 697 return false; |
| 696 } | 698 } |
| 697 | 699 |
| 698 #endif // !defined(OS_WIN) | 700 #endif // !defined(OS_WIN) |
| 699 | 701 |
| 700 } // namespace remoting | 702 } // namespace remoting |
| OLD | NEW |