1// Copyright (c) 2011 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 <windows.h>
6#include <DbgHelp.h>
7#include <string>
8
9#include "chrome_frame/chrome_launcher.h"
10#include "chrome_frame/crash_server_init.h"
11#include "chrome_frame/update_launcher.h"
12
13int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) {
14  google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad(
15      InitializeCrashReporting(NORMAL));
16
17  const wchar_t* cmd_line = ::GetCommandLine();
18  std::wstring update_command(
19      update_launcher::GetUpdateCommandFromArguments(cmd_line));
20
21  UINT exit_code = ERROR_FILE_NOT_FOUND;
22
23  if (!update_command.empty())
24    exit_code = update_launcher::LaunchUpdateCommand(update_command);
25  else if (chrome_launcher::SanitizeAndLaunchChrome(cmd_line))
26    exit_code = ERROR_SUCCESS;
27
28  return exit_code;
29}
30