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 a6036e831bf71c1cef8812dbfebeb278bad78391..39dcf25b5a61734503c36dcb635adf98e8ad5dea 100644 |
--- a/chrome/app/main_dll_loader_win.cc |
+++ b/chrome/app/main_dll_loader_win.cc |
@@ -22,7 +22,6 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "base/threading/platform_thread.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" |
@@ -42,8 +41,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 "components/startup_metric_utils/browser/pre_read_field_trial_utils_win.h" |
#include "content/public/app/sandbox_helper_win.h" |
#include "content/public/common/content_switches.h" |
@@ -54,6 +53,9 @@ |
typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); |
+ |
+base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client = |
+ LAZY_INSTANCE_INITIALIZER; |
// Loads |module| after setting the CWD to |module|'s directory. Returns a |
// reference to the loaded module on success, or null on error. |
@@ -98,6 +100,11 @@ |
GoogleUpdateSettings::UpdateDidRunState(false, system_level); |
} |
+bool InMetroMode() { |
+ return (wcsstr( |
+ ::GetCommandLineW(), L" -ServerName:DefaultBrowserServer") != nullptr); |
+} |
+ |
typedef int (*InitMetro)(); |
} // namespace |
@@ -105,7 +112,7 @@ |
//============================================================================= |
MainDllLoader::MainDllLoader() |
- : dll_(nullptr), metro_mode_(base::win::IsMetroProcess()) { |
+ : dll_(nullptr), metro_mode_(InMetroMode()) { |
} |
MainDllLoader::~MainDllLoader() { |
@@ -217,6 +224,18 @@ |
sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
content::InitializeSandboxInfo(&sandbox_info); |
+ crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); |
+ bool exit_now = true; |
+ if (process_type_.empty()) { |
+ if (breakpad::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_); |
+ |
dll_ = Load(&version, &file); |
if (!dll_) |
return chrome::RESULT_CODE_MISSING_DATA; |
@@ -229,6 +248,12 @@ |
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; |
} |
@@ -270,13 +295,7 @@ |
RecordDidRun(dll_path); |
// Launch the watcher process if stats collection consent has been granted. |
-#if defined(GOOGLE_CHROME_BUILD) |
- const bool stats_collection_consent = |
- GoogleUpdateSettings::GetCollectStatsConsent(); |
-#else |
- const bool stats_collection_consent = false; |
-#endif |
- if (stats_collection_consent) { |
+ if (g_chrome_crash_client.Get().GetCollectStatsConsent()) { |
base::FilePath exe_path; |
if (PathService::Get(base::FILE_EXE, &exe_path)) { |
chrome_watcher_client_.reset(new ChromeWatcherClient( |