| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
| 22 #include "remoting/base/auto_thread_task_runner.h" |
| 22 #include "remoting/base/breakpad.h" | 23 #include "remoting/base/breakpad.h" |
| 23 #include "remoting/base/url_request_context_getter.h" | 24 #include "remoting/base/url_request_context_getter.h" |
| 25 #include "remoting/host/chromoting_host_context.h" |
| 24 #include "remoting/host/host_exit_codes.h" | 26 #include "remoting/host/host_exit_codes.h" |
| 25 #include "remoting/host/logging.h" | 27 #include "remoting/host/logging.h" |
| 28 #include "remoting/host/native_messaging/native_messaging_pipe.h" |
| 26 #include "remoting/host/native_messaging/pipe_messaging_channel.h" | 29 #include "remoting/host/native_messaging/pipe_messaging_channel.h" |
| 27 #include "remoting/host/pairing_registry_delegate.h" | 30 #include "remoting/host/pairing_registry_delegate.h" |
| 28 #include "remoting/host/setup/gaia_oauth_client.h" | 31 #include "remoting/host/setup/gaia_oauth_client.h" |
| 29 #include "remoting/host/setup/me2me_native_messaging_host.h" | 32 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 30 #include "remoting/host/switches.h" | 33 #include "remoting/host/switches.h" |
| 31 #include "remoting/host/usage_stats_consent.h" | 34 #include "remoting/host/usage_stats_consent.h" |
| 32 | 35 |
| 33 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 34 #include "base/mac/scoped_nsautorelease_pool.h" | 37 #include "base/mac/scoped_nsautorelease_pool.h" |
| 35 #endif // defined(OS_MACOSX) | 38 #endif // defined(OS_MACOSX) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take())) | 226 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take())) |
| 224 return kInitializationFailed; | 227 return kInitializationFailed; |
| 225 | 228 |
| 226 pairing_registry = | 229 pairing_registry = |
| 227 new PairingRegistry(io_thread.task_runner(), std::move(delegate)); | 230 new PairingRegistry(io_thread.task_runner(), std::move(delegate)); |
| 228 #else // defined(OS_WIN) | 231 #else // defined(OS_WIN) |
| 229 pairing_registry = | 232 pairing_registry = |
| 230 CreatePairingRegistry(io_thread.task_runner()); | 233 CreatePairingRegistry(io_thread.task_runner()); |
| 231 #endif // !defined(OS_WIN) | 234 #endif // !defined(OS_WIN) |
| 232 | 235 |
| 236 std::unique_ptr<NativeMessagingPipe> native_messaging_pipe( |
| 237 new NativeMessagingPipe()); |
| 238 |
| 233 // Set up the native messaging channel. | 239 // Set up the native messaging channel. |
| 234 std::unique_ptr<extensions::NativeMessagingChannel> channel( | 240 std::unique_ptr<extensions::NativeMessagingChannel> channel( |
| 235 new PipeMessagingChannel(std::move(read_file), std::move(write_file))); | 241 new PipeMessagingChannel(std::move(read_file), std::move(write_file))); |
| 236 | 242 |
| 243 std::unique_ptr<ChromotingHostContext> context = |
| 244 ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner( |
| 245 message_loop.task_runner(), run_loop.QuitClosure())); |
| 246 |
| 237 // Create the native messaging host. | 247 // Create the native messaging host. |
| 238 std::unique_ptr<Me2MeNativeMessagingHost> host(new Me2MeNativeMessagingHost( | 248 std::unique_ptr<extensions::NativeMessageHost> host( |
| 239 needs_elevation, static_cast<intptr_t>(native_view_handle), | 249 new Me2MeNativeMessagingHost(needs_elevation, |
| 240 std::move(channel), daemon_controller, pairing_registry, | 250 static_cast<intptr_t>(native_view_handle), |
| 241 std::move(oauth_client))); | 251 std::move(context), daemon_controller, |
| 242 host->Start(run_loop.QuitClosure()); | 252 pairing_registry, std::move(oauth_client))); |
| 253 |
| 254 host->Start(native_messaging_pipe.get()); |
| 255 |
| 256 native_messaging_pipe->Start(std::move(host), std::move(channel)); |
| 243 | 257 |
| 244 // Run the loop until channel is alive. | 258 // Run the loop until channel is alive. |
| 245 run_loop.Run(); | 259 run_loop.Run(); |
| 246 return kSuccessExitCode; | 260 return kSuccessExitCode; |
| 247 } | 261 } |
| 248 | 262 |
| 249 int Me2MeNativeMessagingHostMain(int argc, char** argv) { | 263 int Me2MeNativeMessagingHostMain(int argc, char** argv) { |
| 250 // This object instance is required by Chrome code (such as MessageLoop). | 264 // This object instance is required by Chrome code (such as MessageLoop). |
| 251 base::AtExitManager exit_manager; | 265 base::AtExitManager exit_manager; |
| 252 | 266 |
| 253 base::CommandLine::Init(argc, argv); | 267 base::CommandLine::Init(argc, argv); |
| 254 remoting::InitHostLogging(); | 268 remoting::InitHostLogging(); |
| 255 | 269 |
| 256 return StartMe2MeNativeMessagingHost(); | 270 return StartMe2MeNativeMessagingHost(); |
| 257 } | 271 } |
| 258 | 272 |
| 259 } // namespace remoting | 273 } // namespace remoting |
| OLD | NEW |