Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1608)

Unified Diff: chrome/app/breakpad_win.cc

Issue 19697015: Move dependency on env_vars.h to breakpad client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/breakpad_mac.mm ('k') | chrome/app/chrome_breakpad_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_win.cc
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index 58ef38158b0c6cede299d6b81bc108cbc8d2f65f..7c26782230512015f8bbf0b627f258aa8b499e74 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -32,7 +32,6 @@
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_result_codes.h"
-#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_chrome_sxs_distribution.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
@@ -489,10 +488,10 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path,
bool controlled_by_policy =
MetricsReportingControlledByPolicy(&crash_reporting_enabled);
const CommandLine& command = *CommandLine::ForCurrentProcess();
- bool use_crash_service = !controlled_by_policy &&
- ((command.HasSwitch(switches::kNoErrorDialogs) ||
- GetEnvironmentVariable(
- ASCIIToWide(env_vars::kHeadless).c_str(), NULL, 0)));
+ bool use_crash_service =
+ !controlled_by_policy &&
+ (command.HasSwitch(switches::kNoErrorDialogs) ||
+ breakpad::GetBreakpadClient()->IsRunningUnattended());
if (use_crash_service)
SetBreakpadDumpPath();
@@ -555,13 +554,9 @@ bool DumpDoneCallback(const wchar_t*, const wchar_t*, void*,
if (HardErrorHandler(ex_info))
return true;
- // We set CHROME_CRASHED env var. If the CHROME_RESTART is present.
- // This signals the child process to show the 'chrome has crashed' dialog.
- scoped_ptr<base::Environment> env(base::Environment::Create());
- if (!env->HasVar(env_vars::kRestartInfo)) {
+ if (!breakpad::GetBreakpadClient()->AboutToRestart())
return true;
- }
- env->SetVar(env_vars::kShowRestart, "1");
+
// Now we just start chrome browser with the same command line.
STARTUPINFOW si = {sizeof(si)};
PROCESS_INFORMATION pi;
@@ -801,11 +796,6 @@ bool WrapMessageBoxWithSEH(const wchar_t* text, const wchar_t* caption,
// spawned and basically just shows the 'chrome has crashed' dialog if
// the CHROME_CRASHED environment variable is present.
bool ShowRestartDialogIfCrashed(bool* exit_now) {
- if (!::GetEnvironmentVariableW(ASCIIToWide(env_vars::kShowRestart).c_str(),
- NULL, 0)) {
- return false;
- }
-
// If we are being launched in metro mode don't try to show the dialog.
if (base::win::IsMetroProcess())
return false;
@@ -814,36 +804,27 @@ bool ShowRestartDialogIfCrashed(bool* exit_now) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
- if (!process_type.empty()) {
+ if (!process_type.empty())
return false;
- }
-
- DWORD len = ::GetEnvironmentVariableW(
- ASCIIToWide(env_vars::kRestartInfo).c_str(), NULL, 0);
- if (!len)
- return true;
- wchar_t* restart_data = new wchar_t[len + 1];
- ::GetEnvironmentVariableW(ASCIIToWide(env_vars::kRestartInfo).c_str(),
- restart_data, len);
- restart_data[len] = 0;
- // The CHROME_RESTART var contains the dialog strings separated by '|'.
- // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment()
- // for details.
- std::vector<std::wstring> dlg_strings;
- base::SplitString(restart_data, L'|', &dlg_strings);
- delete[] restart_data;
- if (dlg_strings.size() < 3)
- return true;
+ base::string16 message;
+ base::string16 title;
+ bool is_rtl_locale;
+ if (!breakpad::GetBreakpadClient()->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 (dlg_strings[2] == ASCIIToWide(env_vars::kRtlLocale))
+ if (is_rtl_locale)
flags |= MB_RIGHT | MB_RTLREADING;
- return WrapMessageBoxWithSEH(dlg_strings[1].c_str(), dlg_strings[0].c_str(),
- flags, exit_now);
+ return WrapMessageBoxWithSEH(base::UTF16ToWide(message).c_str(),
+ base::UTF16ToWide(title).c_str(),
+ flags,
+ exit_now);
}
// Crashes the process after generating a dump for the provided exception. Note
@@ -959,10 +940,10 @@ static void InitPipeNameEnvVar(bool is_per_user_install) {
MetricsReportingControlledByPolicy(&crash_reporting_enabled);
const CommandLine& command = *CommandLine::ForCurrentProcess();
- bool use_crash_service = !controlled_by_policy &&
- ((command.HasSwitch(switches::kNoErrorDialogs) ||
- GetEnvironmentVariable(
- ASCIIToWide(env_vars::kHeadless).c_str(), NULL, 0)));
+ bool use_crash_service =
+ !controlled_by_policy &&
+ (command.HasSwitch(switches::kNoErrorDialogs) ||
+ breakpad::GetBreakpadClient()->IsRunningUnattended());
std::wstring pipe_name;
if (use_crash_service) {
@@ -1110,8 +1091,8 @@ void InitCrashReporter() {
#ifndef _WIN64
std::string headless;
- if (process_type != L"browser" && !GetEnvironmentVariable(
- ASCIIToWide(env_vars::kHeadless).c_str(), NULL, 0)) {
+ if (process_type != L"browser" &&
+ !breakpad::GetBreakpadClient()->IsRunningUnattended()) {
// Initialize the hook TerminateProcess to catch unexpected exits.
InitTerminateProcessHooks();
}
« no previous file with comments | « chrome/app/breakpad_mac.mm ('k') | chrome/app/chrome_breakpad_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698