Index: chrome/app/main_dll_loader_win.cc |
diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc |
index 4f831ff6bb5a9dea72cca67b1024cbeef5f92deb..16b3cb0261aebfc6d8e537cd90f11de9b347601a 100644 |
--- a/chrome/app/main_dll_loader_win.cc |
+++ b/chrome/app/main_dll_loader_win.cc |
@@ -21,6 +21,7 @@ |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/trace_event/trace_event.h" |
+#include "base/win/metro.h" |
#include "base/win/scoped_handle.h" |
#include "base/win/windows_version.h" |
#include "chrome/app/chrome_crash_reporter_client.h" |
@@ -39,8 +40,8 @@ |
#include "chrome/installer/util/install_util.h" |
#include "chrome/installer/util/module_util_win.h" |
#include "chrome/installer/util/util_constants.h" |
-#include "components/crash/content/app/breakpad_win.h" |
#include "components/crash/content/app/crash_reporter_client.h" |
+#include "components/crash/content/app/crashpad.h" |
#include "content/public/app/sandbox_helper_win.h" |
#include "content/public/common/content_switches.h" |
#include "sandbox/win/src/sandbox.h" |
@@ -89,6 +90,57 @@ bool InMetroMode() { |
typedef int (*InitMetro)(); |
+// Returns the directory in which the currently running executable resides. |
+base::FilePath GetExecutableDir() { |
+ base::char16 path[MAX_PATH]; |
+ ::GetModuleFileNameW(nullptr, path, MAX_PATH); |
+ return base::FilePath(path).DirName(); |
+} |
+ |
+bool WrapMessageBoxWithSEH(const wchar_t* text, |
+ const wchar_t* caption, |
+ UINT flags, |
+ bool* exit_now) { |
+ // We wrap the call to MessageBoxW with a SEH handler because it some |
+ // machines with CursorXP, PeaDict or with FontExplorer installed it crashes |
+ // uncontrollably here. Being this a best effort deal we better go away. |
+ __try { |
+ *exit_now = (IDOK != ::MessageBoxW(NULL, text, caption, flags)); |
+ } __except(EXCEPTION_EXECUTE_HANDLER) { |
+ // Its not safe to continue executing, exit silently here. |
+ ::TerminateProcess( |
+ ::GetCurrentProcess(), |
+ g_chrome_crash_client.Pointer()->GetResultCodeRespawnFailed()); |
+ } |
+ |
+ return true; |
+} |
+ |
+// This function is executed by the child process that DumpDoneCallback() |
+// spawned and basically just shows the 'chrome has crashed' dialog if |
+// the CHROME_CRASHED environment variable is present. |
+bool ShowRestartDialogIfCrashed(bool* exit_now) { |
+ // If we are being launched in metro mode don't try to show the dialog. |
+ if (base::win::IsMetroProcess()) |
cpu_(ooo_6.6-7.5)
2015/11/07 01:53:17
mmm .. see line 86
scottmg
2015/11/09 18:29:56
Removed the local one.
|
+ return false; |
+ |
+ base::string16 message; |
+ base::string16 title; |
+ bool is_rtl_locale; |
+ if (!g_chrome_crash_client.Pointer()->ShouldShowRestartDialog( |
+ &title, &message, &is_rtl_locale)) { |
+ return false; |
+ } |
+ |
+ // If the UI layout is right-to-left, we need to pass the appropriate MB_XXX |
+ // flags so that an RTL message box is displayed. |
+ UINT flags = MB_OKCANCEL | MB_ICONWARNING; |
+ if (is_rtl_locale) |
+ flags |= MB_RIGHT | MB_RTLREADING; |
+ |
+ return WrapMessageBoxWithSEH(message.c_str(), title.c_str(), flags, exit_now); |
+} |
+ |
} // namespace |
//============================================================================= |
@@ -158,8 +210,9 @@ int MainDllLoader::Launch(HINSTANCE instance) { |
return chrome_metro_main(); |
} |
+ chrome::RegisterPathProvider(); |
+ |
if (process_type_ == "watcher") { |
- chrome::RegisterPathProvider(); |
base::win::ScopedHandle parent_process; |
base::win::ScopedHandle on_initialized_event; |
@@ -209,14 +262,15 @@ int MainDllLoader::Launch(HINSTANCE instance) { |
crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); |
bool exit_now = true; |
if (process_type_.empty()) { |
- if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) { |
+ if (ShowRestartDialogIfCrashed(&exit_now)) { |
// We restarted because of a previous crash. Ask user if we should |
// Relaunch. Only for the browser process. See crbug.com/132119. |
if (exit_now) |
return content::RESULT_CODE_NORMAL_EXIT; |
} |
} |
- breakpad::InitCrashReporter(process_type_); |
+ |
+ crash_reporter::InitializeCrashpad(process_type_ == "", process_type_); |
dll_ = Load(&version, &file); |
if (!dll_) |
@@ -230,12 +284,6 @@ int MainDllLoader::Launch(HINSTANCE instance) { |
reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); |
int rc = chrome_main(instance, &sandbox_info); |
rc = OnBeforeExit(rc, file); |
- // Sandboxed processes close some system DLL handles after lockdown so ignore |
- // EXCEPTION_INVALID_HANDLE generated on Windows 10 during shutdown of these |
- // processes. |
- // TODO(wfh): Check whether MS have fixed this in Win10 RTM. crbug.com/456193 |
- if (base::win::GetVersion() >= base::win::VERSION_WIN10) |
- breakpad::ConsumeInvalidHandleExceptions(); |
return rc; |
} |