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 3// found in the LICENSE file. 4 5#include <atlbase.h> 6#include <atlwin.h> 7#include <ole2.h> 8 9#include "base/at_exit.h" 10#include "base/command_line.h" 11#include "base/run_loop.h" 12#include "base/threading/thread.h" 13#include "remoting/base/url_request_context.h" 14#include "remoting/host/setup/win/host_configurer_window.h" 15 16class HostConfigurerModule 17 : public ATL::CAtlExeModuleT<HostConfigurerModule> { 18}; 19 20HostConfigurerModule _AtlModule; 21 22// An app that runs a HostConfigurerWindow. 23int WINAPI WinMain(HINSTANCE instance_handle, HINSTANCE prev_instance_handle, 24 LPSTR cmd_line, int cmd) 25{ 26 // google_apis::GetOAuth2ClientID/Secret need the next line. 27 // On Windows, CommandLine::Init ignores its arguments, and parses 28 // GetCommandLineW directly, so we can pass it dummy arguments. 29 CommandLine::Init(0, NULL); 30 31 // Register and initialize common controls. 32 INITCOMMONCONTROLSEX info; 33 info.dwSize = sizeof(info); 34 info.dwICC = ICC_STANDARD_CLASSES; 35 InitCommonControlsEx(&info); 36 37 // This object instance is required by Chrome code (for example, 38 // FilePath, LazyInstance, MessageLoop). 39 base::AtExitManager exit_manager; 40 41 // Provide message loops and threads for the URLRequestContextGetter. 42 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); 43 base::Thread io_thread("IO thread"); 44 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); 45 io_thread.StartWithOptions(io_thread_options); 46 47 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_( 48 new remoting::URLRequestContextGetter( 49 message_loop.message_loop_proxy(), io_thread.message_loop_proxy())); 50 51 OleInitialize(NULL); 52 53 // Run a HostConfigurerWindow. 54 remoting::HostConfigurerWindow host_configurer_window( 55 url_request_context_getter_, message_loop.message_loop_proxy(), 56 message_loop.QuitClosure()); 57 host_configurer_window.Create(NULL); 58 59 base::RunLoop run_loop; 60 run_loop.Run(); 61 62 io_thread.Stop(); 63 64 OleUninitialize(); 65} 66