| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A simple command-line app that registers and starts a host. | 5 #include "remoting/host/setup/start_host_main.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 #include "remoting/base/logging.h" | 18 #include "remoting/base/logging.h" |
| 19 #include "remoting/base/url_request_context_getter.h" | 19 #include "remoting/base/url_request_context_getter.h" |
| 20 #include "remoting/host/service_urls.h" | 20 #include "remoting/host/service_urls.h" |
| 21 #include "remoting/host/setup/host_starter.h" | 21 #include "remoting/host/setup/host_starter.h" |
| 22 #include "remoting/host/setup/oauth_helper.h" | 22 #include "remoting/host/setup/oauth_helper.h" |
| 23 #include "remoting/host/setup/pin_validator.h" | 23 #include "remoting/host/setup/pin_validator.h" |
| 24 | 24 |
| 25 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
| 26 #include <termios.h> | 26 #include <termios.h> |
| 27 #include <unistd.h> | 27 #include <unistd.h> |
| 28 #endif // defined(OS_POSIX) | 28 #endif // defined(OS_POSIX) |
| 29 | 29 |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 #include "remoting/host/win/elevation_helpers.h" | 31 #include "remoting/host/win/elevation_helpers.h" |
| 32 #endif // defined(OS_WIN) | 32 #endif // defined(OS_WIN) |
| 33 | 33 |
| 34 using remoting::HostStarter; | 34 namespace remoting { |
| 35 |
| 36 namespace { |
| 35 | 37 |
| 36 // True if the host was started successfully. | 38 // True if the host was started successfully. |
| 37 bool g_started = false; | 39 bool g_started = false; |
| 38 | 40 |
| 39 // The main message loop. | 41 // The main message loop. |
| 40 base::MessageLoop* g_message_loop = nullptr; | 42 base::MessageLoop* g_message_loop = nullptr; |
| 41 | 43 |
| 42 // Lets us hide the PIN that a user types. | 44 // Lets us hide the PIN that a user types. |
| 43 void SetEcho(bool echo) { | 45 void SetEcho(bool echo) { |
| 44 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 break; | 105 break; |
| 104 } | 106 } |
| 105 | 107 |
| 106 g_message_loop->QuitNow(); | 108 g_message_loop->QuitNow(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 std::string GetAuthorizationCodeUri() { | 111 std::string GetAuthorizationCodeUri() { |
| 110 return remoting::GetOauthStartUrl(remoting::GetDefaultOauthRedirectUrl()); | 112 return remoting::GetOauthStartUrl(remoting::GetDefaultOauthRedirectUrl()); |
| 111 } | 113 } |
| 112 | 114 |
| 113 int main(int argc, char** argv) { | 115 } // namespace |
| 116 |
| 117 int StartHostMain(int argc, char** argv) { |
| 114 // google_apis::GetOAuth2ClientID/Secret need a static CommandLine. | 118 // google_apis::GetOAuth2ClientID/Secret need a static CommandLine. |
| 115 base::CommandLine::Init(argc, argv); | 119 base::CommandLine::Init(argc, argv); |
| 116 const base::CommandLine* command_line = | 120 const base::CommandLine* command_line = |
| 117 base::CommandLine::ForCurrentProcess(); | 121 base::CommandLine::ForCurrentProcess(); |
| 118 | 122 |
| 119 // This object instance is required by Chrome code (for example, | 123 // This object instance is required by Chrome code (for example, |
| 120 // FilePath, LazyInstance, MessageLoop). | 124 // FilePath, LazyInstance, MessageLoop). |
| 121 base::AtExitManager exit_manager; | 125 base::AtExitManager exit_manager; |
| 122 | 126 |
| 123 logging::LoggingSettings settings; | 127 logging::LoggingSettings settings; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 230 |
| 227 // Destroy the HostStarter and URLRequestContextGetter before stopping the | 231 // Destroy the HostStarter and URLRequestContextGetter before stopping the |
| 228 // IO thread. | 232 // IO thread. |
| 229 host_starter.reset(); | 233 host_starter.reset(); |
| 230 url_request_context_getter = nullptr; | 234 url_request_context_getter = nullptr; |
| 231 | 235 |
| 232 io_thread.Stop(); | 236 io_thread.Stop(); |
| 233 | 237 |
| 234 return g_started ? 0 : 1; | 238 return g_started ? 0 : 1; |
| 235 } | 239 } |
| 240 |
| 241 } // namespace remoting |
| OLD | NEW |