| 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_main.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host_main.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <cstdint> |
| 8 | 8 #include <memory> |
| 9 #include <string> |
| 9 #include <utility> | 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 14 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
| 15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
| 21 #include "remoting/base/breakpad.h" | 22 #include "remoting/base/breakpad.h" |
| 22 #include "remoting/base/url_request_context_getter.h" | 23 #include "remoting/base/url_request_context_getter.h" |
| 23 #include "remoting/host/host_exit_codes.h" | 24 #include "remoting/host/host_exit_codes.h" |
| 24 #include "remoting/host/logging.h" | 25 #include "remoting/host/logging.h" |
| 25 #include "remoting/host/native_messaging/pipe_messaging_channel.h" | 26 #include "remoting/host/native_messaging/pipe_messaging_channel.h" |
| 26 #include "remoting/host/pairing_registry_delegate.h" | 27 #include "remoting/host/pairing_registry_delegate.h" |
| 27 #include "remoting/host/setup/gaia_oauth_client.h" | 28 #include "remoting/host/setup/gaia_oauth_client.h" |
| 28 #include "remoting/host/setup/me2me_native_messaging_host.h" | 29 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 30 #include "remoting/host/switches.h" |
| 29 #include "remoting/host/usage_stats_consent.h" | 31 #include "remoting/host/usage_stats_consent.h" |
| 30 | 32 |
| 31 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
| 32 #include "base/mac/scoped_nsautorelease_pool.h" | 34 #include "base/mac/scoped_nsautorelease_pool.h" |
| 33 #endif // defined(OS_MACOSX) | 35 #endif // defined(OS_MACOSX) |
| 34 | 36 |
| 35 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 36 #include "base/win/registry.h" | 38 #include "base/win/registry.h" |
| 37 #include "remoting/host/pairing_registry_delegate_win.h" | 39 #include "remoting/host/pairing_registry_delegate_win.h" |
| 38 #include "remoting/host/win/elevation_helpers.h" | 40 #include "remoting/host/win/elevation_helpers.h" |
| 39 #endif // defined(OS_WIN) | 41 #endif // defined(OS_WIN) |
| 40 | 42 |
| 41 #if defined(OS_LINUX) | 43 #if defined(OS_LINUX) |
| 42 #include <glib-object.h> | 44 #include <glib-object.h> |
| 43 #endif // defined(OS_LINUX) | 45 #endif // defined(OS_LINUX) |
| 44 | 46 |
| 45 using remoting::protocol::PairingRegistry; | 47 using remoting::protocol::PairingRegistry; |
| 46 | 48 |
| 47 namespace { | |
| 48 | |
| 49 const char kParentWindowSwitchName[] = "parent-window"; | |
| 50 | |
| 51 } // namespace | |
| 52 | |
| 53 namespace remoting { | 49 namespace remoting { |
| 54 | 50 |
| 55 int StartMe2MeNativeMessagingHost() { | 51 int StartMe2MeNativeMessagingHost() { |
| 56 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
| 57 // Needed so we don't leak objects when threads are created. | 53 // Needed so we don't leak objects when threads are created. |
| 58 base::mac::ScopedNSAutoreleasePool pool; | 54 base::mac::ScopedNSAutoreleasePool pool; |
| 59 #endif // defined(OS_MACOSX) | 55 #endif // defined(OS_MACOSX) |
| 60 | 56 |
| 61 #if defined(OS_LINUX) | 57 #if defined(OS_LINUX) |
| 62 // g_type_init will be deprecated in 2.36. 2.35 is the development | 58 // g_type_init will be deprecated in 2.36. 2.35 is the development |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 106 } |
| 111 } | 107 } |
| 112 | 108 |
| 113 base::File read_file; | 109 base::File read_file; |
| 114 base::File write_file; | 110 base::File write_file; |
| 115 bool needs_elevation = false; | 111 bool needs_elevation = false; |
| 116 | 112 |
| 117 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
| 118 needs_elevation = !IsProcessElevated(); | 114 needs_elevation = !IsProcessElevated(); |
| 119 | 115 |
| 120 if (command_line->HasSwitch(kElevatingSwitchName)) { | 116 if (command_line->HasSwitch(kElevateSwitchName)) { |
| 121 DCHECK(!needs_elevation); | 117 DCHECK(!needs_elevation); |
| 122 | 118 |
| 123 // The "elevate" switch is always accompanied by the "input" and "output" | 119 // The "elevate" switch is always accompanied by the "input" and "output" |
| 124 // switches whose values name named pipes that should be used in place of | 120 // switches whose values name named pipes that should be used in place of |
| 125 // stdin and stdout. | 121 // stdin and stdout. |
| 126 DCHECK(command_line->HasSwitch(kInputSwitchName)); | 122 DCHECK(command_line->HasSwitch(kInputSwitchName)); |
| 127 DCHECK(command_line->HasSwitch(kOutputSwitchName)); | 123 DCHECK(command_line->HasSwitch(kOutputSwitchName)); |
| 128 | 124 |
| 129 // presubmit: allow wstring | 125 // presubmit: allow wstring |
| 130 std::wstring input_pipe_name = | 126 std::wstring input_pipe_name = |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // This object instance is required by Chrome code (such as MessageLoop). | 250 // This object instance is required by Chrome code (such as MessageLoop). |
| 255 base::AtExitManager exit_manager; | 251 base::AtExitManager exit_manager; |
| 256 | 252 |
| 257 base::CommandLine::Init(argc, argv); | 253 base::CommandLine::Init(argc, argv); |
| 258 remoting::InitHostLogging(); | 254 remoting::InitHostLogging(); |
| 259 | 255 |
| 260 return StartMe2MeNativeMessagingHost(); | 256 return StartMe2MeNativeMessagingHost(); |
| 261 } | 257 } |
| 262 | 258 |
| 263 } // namespace remoting | 259 } // namespace remoting |
| OLD | NEW |