#include "remoting/host/host_main.h"
#include <string>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/i18n/icu_util.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "remoting/base/breakpad.h"
#include "remoting/base/logging.h"
#include "remoting/host/base/host_exit_codes.h"
#include "remoting/host/base/switches.h"
#include "remoting/host/evaluate_capability.h"
#include "remoting/host/resources.h"
#include "remoting/host/setup/me2me_native_messaging_host.h"
#include "remoting/host/usage_stats_consent.h"
#if BUILDFLAG(IS_APPLE)
#include "base/apple/scoped_nsautorelease_pool.h"
#endif
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <commctrl.h>
#include <shellapi.h>
#endif
namespace remoting {
int HostProcessMain();
#if BUILDFLAG(IS_WIN)
int DaemonProcessMain();
int DesktopProcessMain();
int FileChooserMain();
int RdpDesktopSessionMain();
int UrlForwarderConfiguratorMain();
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
int XSessionChooserMain();
#endif
namespace {
MainRoutineFn;
const char kUsageMessage[] = …;
void Usage(const base::FilePath& program_name) { … }
#if BUILDFLAG(IS_WIN)
int RunElevated() {
const base::CommandLine::SwitchMap& switches =
base::CommandLine::ForCurrentProcess()->GetSwitches();
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
for (base::CommandLine::SwitchMap::const_iterator i = switches.begin();
i != switches.end(); ++i) {
if (i->first != kElevateSwitchName) {
command_line.AppendSwitchNative(i->first, i->second);
}
}
for (base::CommandLine::StringVector::const_iterator i = args.begin();
i != args.end(); ++i) {
command_line.AppendArgNative(*i);
}
base::FilePath binary =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
kElevateSwitchName);
base::CommandLine::StringType parameters =
command_line.GetCommandLineString();
SHELLEXECUTEINFO info;
memset(&info, 0, sizeof(info));
info.cbSize = sizeof(info);
info.lpVerb = L"runas";
info.lpFile = binary.value().c_str();
info.lpParameters = parameters.c_str();
info.nShow = SW_SHOWNORMAL;
if (!ShellExecuteEx(&info)) {
DWORD exit_code = GetLastError();
PLOG(ERROR) << "Unable to launch '" << binary.value() << "'";
return exit_code;
}
return kSuccessExitCode;
}
#endif
MainRoutineFn SelectMainRoutine(const std::string& process_type) { … }
}
int HostMain(int argc, char** argv) { … }
}