| Index: chrome/app/chrome_crash_reporter_client_win.cc
|
| diff --git a/chrome/app/chrome_crash_reporter_client_win.cc b/chrome/app/chrome_crash_reporter_client_win.cc
|
| index 1250741914a73718add2e1e3440bdd9c08a469eb..a9cdf39b013aa228d11796ea4a4b246697960ee8 100644
|
| --- a/chrome/app/chrome_crash_reporter_client_win.cc
|
| +++ b/chrome/app/chrome_crash_reporter_client_win.cc
|
| @@ -7,30 +7,19 @@
|
| #include <windows.h>
|
|
|
| #include "base/command_line.h"
|
| -#include "base/environment.h"
|
| -#include "base/file_version_info.h"
|
| #include "base/files/file_path.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/path_service.h"
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| -#include "base/win/registry.h"
|
| #include "build/build_config.h"
|
| -#include "chrome/common/chrome_paths.h"
|
| -#include "chrome/common/chrome_paths_internal.h"
|
| #include "chrome/common/chrome_result_codes.h"
|
| #include "chrome/common/crash_keys.h"
|
| #include "chrome/common/env_vars.h"
|
| -#include "chrome/common/metrics_constants_util_win.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"
|
| -#include "chrome/installer/util/util_constants.h"
|
| +#include "chrome/install_static/install_util.h"
|
| #include "components/browser_watcher/crash_reporting_metrics_win.h"
|
| #include "content/public/common/content_switches.h"
|
| -#include "policy/policy_constants.h"
|
| -
|
|
|
| namespace {
|
|
|
| @@ -48,13 +37,12 @@ bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
|
| base::FilePath* crash_dir) {
|
| // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
|
| // location to write breakpad crash dumps can be set.
|
| - std::unique_ptr<base::Environment> env(base::Environment::Create());
|
| - std::string alternate_crash_dump_location;
|
| - if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {
|
| + std::string alternate_crash_dump_location =
|
| + install_static::GetEnvironmentString("BREAKPAD_DUMP_LOCATION");
|
| + if (!alternate_crash_dump_location.empty()) {
|
| *crash_dir = base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location);
|
| return true;
|
| }
|
| -
|
| return false;
|
| }
|
|
|
| @@ -69,39 +57,24 @@ void ChromeCrashReporterClient::GetProductNameAndVersion(
|
| DCHECK(special_build);
|
| DCHECK(channel_name);
|
|
|
| - scoped_ptr<FileVersionInfo> version_info(
|
| - FileVersionInfo::CreateFileVersionInfo(exe_path));
|
| -
|
| - if (version_info.get()) {
|
| - // Get the information from the file.
|
| - *version = version_info->product_version();
|
| - if (!version_info->is_official_build())
|
| - version->append(base::ASCIIToUTF16("-devel"));
|
| -
|
| - *product_name = version_info->product_short_name();
|
| - *special_build = version_info->special_build();
|
| - } else {
|
| - // No version info found. Make up the values.
|
| - *product_name = base::ASCIIToUTF16("Chrome");
|
| - *version = base::ASCIIToUTF16("0.0.0.0-devel");
|
| - }
|
| -
|
| - GoogleUpdateSettings::GetChromeChannelAndModifiers(
|
| - !GetIsPerUserInstall(exe_path), channel_name);
|
| + install_static::GetExecutableVersionDetails(exe_path.value(),
|
| + product_name,
|
| + version,
|
| + special_build,
|
| + channel_name);
|
| }
|
|
|
| bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title,
|
| base::string16* message,
|
| bool* is_rtl_locale) {
|
| - scoped_ptr<base::Environment> env(base::Environment::Create());
|
| - if (!env->HasVar(env_vars::kShowRestart) ||
|
| - !env->HasVar(env_vars::kRestartInfo) ||
|
| - env->HasVar(env_vars::kMetroConnected)) {
|
| + if (!install_static::HasEnvironmentVariable(env_vars::kShowRestart) ||
|
| + !install_static::HasEnvironmentVariable(env_vars::kRestartInfo) ||
|
| + install_static::HasEnvironmentVariable(env_vars::kMetroConnected)) {
|
| return false;
|
| }
|
|
|
| - std::string restart_info;
|
| - env->GetVar(env_vars::kRestartInfo, &restart_info);
|
| + std::string restart_info = install_static::GetEnvironmentString(
|
| + env_vars::kRestartInfo);
|
|
|
| // The CHROME_RESTART var contains the dialog strings separated by '|'.
|
| // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment()
|
| @@ -119,41 +92,39 @@ bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title,
|
| }
|
|
|
| bool ChromeCrashReporterClient::AboutToRestart() {
|
| - scoped_ptr<base::Environment> env(base::Environment::Create());
|
| - if (!env->HasVar(env_vars::kRestartInfo))
|
| + if (!install_static::HasEnvironmentVariable(env_vars::kRestartInfo))
|
| return false;
|
|
|
| - env->SetVar(env_vars::kShowRestart, "1");
|
| + install_static::SetEnvironmentString(env_vars::kShowRestart, "1");
|
| return true;
|
| }
|
|
|
| bool ChromeCrashReporterClient::GetDeferredUploadsSupported(
|
| bool is_per_user_install) {
|
| - Version update_version = GoogleUpdateSettings::GetGoogleUpdateVersion(
|
| - !is_per_user_install);
|
| + Version update_version = install_static::GetGoogleUpdateVersion();
|
| if (!update_version.IsValid() ||
|
| - update_version < base::Version(kMinUpdateVersion))
|
| + update_version < base::Version(kMinUpdateVersion)) {
|
| return false;
|
| -
|
| + }
|
| return true;
|
| }
|
|
|
| bool ChromeCrashReporterClient::GetIsPerUserInstall(
|
| const base::FilePath& exe_path) {
|
| - return InstallUtil::IsPerUserInstall(exe_path);
|
| + return !install_static::IsSystemInstall(exe_path.value().c_str());
|
| }
|
|
|
| bool ChromeCrashReporterClient::GetShouldDumpLargerDumps(
|
| bool is_per_user_install) {
|
| - base::string16 channel_name =
|
| - GoogleUpdateSettings::GetChromeChannel(!is_per_user_install);
|
| -
|
| + base::string16 channel_name;
|
| + install_static::GetChromeChannelName(is_per_user_install,
|
| + &channel_name);
|
| // Capture more detail in crash dumps for Beta, Dev, Canary channels and
|
| // if channel is unknown (e.g. Chromium or developer builds).
|
| - return (channel_name == installer::kChromeChannelBeta ||
|
| - channel_name == installer::kChromeChannelDev ||
|
| - channel_name == GoogleChromeSxSDistribution::ChannelName() ||
|
| - channel_name == installer::kChromeChannelUnknown);
|
| + return (channel_name == install_static::kChromeChannelBeta ||
|
| + channel_name == install_static::kChromeChannelDev ||
|
| + channel_name == install_static::kChromeChannelCanary ||
|
| + channel_name == install_static::kChromeChannelUnknown);
|
| }
|
|
|
| int ChromeCrashReporterClient::GetResultCodeRespawnFailed() {
|
| @@ -162,9 +133,9 @@ int ChromeCrashReporterClient::GetResultCodeRespawnFailed() {
|
|
|
| void ChromeCrashReporterClient::InitBrowserCrashDumpsRegKey() {
|
| #if !defined(NACL_WIN64)
|
| - if (GetCollectStatsConsent()){
|
| + if (GetCollectStatsConsent()) {
|
| crash_reporting_metrics_.reset(new browser_watcher::CrashReportingMetrics(
|
| - chrome::GetBrowserCrashDumpAttemptsRegistryPath()));
|
| + install_static::GetBrowserCrashDumpAttemptsRegistryPath()));
|
| }
|
| #endif
|
| }
|
| @@ -196,29 +167,13 @@ void ChromeCrashReporterClient::RecordCrashDumpAttemptResult(bool is_real_crash,
|
|
|
| bool ChromeCrashReporterClient::ReportingIsEnforcedByPolicy(
|
| bool* breakpad_enabled) {
|
| -// Determine whether configuration management allows loading the crash reporter.
|
| -// Since the configuration management infrastructure is not initialized at this
|
| -// point, we read the corresponding registry key directly. The return status
|
| -// indicates whether policy data was successfully read. If it is true,
|
| -// |breakpad_enabled| contains the value set by policy.
|
| - base::string16 key_name =
|
| - base::UTF8ToUTF16(policy::key::kMetricsReportingEnabled);
|
| - DWORD value = 0;
|
| - base::win::RegKey hklm_policy_key(HKEY_LOCAL_MACHINE,
|
| - policy::kRegistryChromePolicyKey, KEY_READ);
|
| - if (hklm_policy_key.ReadValueDW(key_name.c_str(), &value) == ERROR_SUCCESS) {
|
| - *breakpad_enabled = value != 0;
|
| - return true;
|
| - }
|
| -
|
| - base::win::RegKey hkcu_policy_key(HKEY_CURRENT_USER,
|
| - policy::kRegistryChromePolicyKey, KEY_READ);
|
| - if (hkcu_policy_key.ReadValueDW(key_name.c_str(), &value) == ERROR_SUCCESS) {
|
| - *breakpad_enabled = value != 0;
|
| - return true;
|
| - }
|
| -
|
| - return false;
|
| + // Determine whether configuration management allows loading the crash
|
| + // reporter.
|
| + // Since the configuration management infrastructure is not initialized at
|
| + // this point, we read the corresponding registry key directly. The return
|
| + // status indicates whether policy data was successfully read. If it is true,
|
| + // |breakpad_enabled| contains the value set by policy.
|
| + return install_static::ReportingIsEnforcedByPolicy(breakpad_enabled);
|
| }
|
|
|
|
|
| @@ -226,23 +181,16 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(
|
| base::FilePath* crash_dir) {
|
| // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
|
| // location to write breakpad crash dumps can be set.
|
| - scoped_ptr<base::Environment> env(base::Environment::Create());
|
| - std::string alternate_crash_dump_location;
|
| - if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {
|
| - base::FilePath crash_dumps_dir_path =
|
| - base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location);
|
| -
|
| - // If this environment variable exists, then for the time being,
|
| - // short-circuit how it's handled on Windows. Honoring this
|
| - // variable is required in order to symbolize stack traces in
|
| - // Telemetry based tests: http://crbug.com/561763.
|
| - *crash_dir = crash_dumps_dir_path;
|
| + // If this environment variable exists, then for the time being,
|
| + // short-circuit how it's handled on Windows. Honoring this
|
| + // variable is required in order to symbolize stack traces in
|
| + // Telemetry based tests: http://crbug.com/561763.
|
| + if (GetAlternativeCrashDumpLocation(crash_dir))
|
| return true;
|
| - }
|
|
|
| // TODO(scottmg): Consider supporting --user-data-dir. See
|
| // https://crbug.com/565446.
|
| - return chrome::GetDefaultCrashDumpLocation(crash_dir);
|
| + return install_static::GetDefaultCrashDumpLocation(crash_dir);
|
| }
|
|
|
| size_t ChromeCrashReporterClient::RegisterCrashKeys() {
|
| @@ -250,8 +198,7 @@ size_t ChromeCrashReporterClient::RegisterCrashKeys() {
|
| }
|
|
|
| bool ChromeCrashReporterClient::IsRunningUnattended() {
|
| - scoped_ptr<base::Environment> env(base::Environment::Create());
|
| - return env->HasVar(env_vars::kHeadless);
|
| + return install_static::HasEnvironmentVariable(env_vars::kHeadless);
|
| }
|
|
|
| bool ChromeCrashReporterClient::GetCollectStatsConsent() {
|
| @@ -261,8 +208,7 @@ bool ChromeCrashReporterClient::GetCollectStatsConsent() {
|
| bool is_official_chrome_build = false;
|
| #endif
|
|
|
| - return is_official_chrome_build &&
|
| - GoogleUpdateSettings::GetCollectStatsConsent();
|
| + return is_official_chrome_build && install_static::GetCollectStatsConsent();
|
| }
|
|
|
| bool ChromeCrashReporterClient::EnableBreakpadForProcess(
|
|
|