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

Unified Diff: chrome/app/chrome_crash_reporter_client_win.cc

Issue 1913943003: Remove dependencies on chrome\installer from the ChromeCrashReporterClient class on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix DEPs includes Created 4 years, 7 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/DEPS ('k') | chrome/chrome_dll.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d782db4e692904ac4c227ad0371f374b25f8f05a..641c262d27f2dc436fda8bc12567d3ea018637b4 100644
--- a/chrome/app/chrome_crash_reporter_client_win.cc
+++ b/chrome/app/chrome_crash_reporter_client_win.cc
@@ -1,36 +1,28 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+// TODO(ananta/scottmg)
+// Add test coverage for Crashpad.
#include "chrome/app/chrome_crash_reporter_client_win.h"
#include <windows.h>
#include <memory>
+#include <string>
#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/path_service.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/win/registry.h"
+#include "base/version.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 "content/public/common/content_switches.h"
-#include "policy/policy_constants.h"
-
namespace {
@@ -48,13 +40,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 +60,21 @@ void ChromeCrashReporterClient::GetProductNameAndVersion(
DCHECK(special_build);
DCHECK(channel_name);
- std::unique_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) {
- std::unique_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,41 @@ bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title,
}
bool ChromeCrashReporterClient::AboutToRestart() {
- std::unique_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);
+ std::string version_string = install_static::GetGoogleUpdateVersion();
+ Version update_version(version_string);
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,
+ false, // !add_modifier
+ &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,29 +135,13 @@ int ChromeCrashReporterClient::GetResultCodeRespawnFailed() {
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);
}
@@ -192,23 +149,20 @@ 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.
- 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)) {
- 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);
+ base::string16 crash_dump_location;
+ if (!install_static::GetDefaultCrashDumpLocation(&crash_dump_location))
+ return false;
+ *crash_dir = base::FilePath(crash_dump_location);
+ return true;
}
size_t ChromeCrashReporterClient::RegisterCrashKeys() {
@@ -216,19 +170,11 @@ size_t ChromeCrashReporterClient::RegisterCrashKeys() {
}
bool ChromeCrashReporterClient::IsRunningUnattended() {
- std::unique_ptr<base::Environment> env(base::Environment::Create());
- return env->HasVar(env_vars::kHeadless);
+ return install_static::HasEnvironmentVariable(env_vars::kHeadless);
}
bool ChromeCrashReporterClient::GetCollectStatsConsent() {
-#if defined(GOOGLE_CHROME_BUILD)
- bool is_official_chrome_build = true;
-#else
- bool is_official_chrome_build = false;
-#endif
-
- return is_official_chrome_build &&
- GoogleUpdateSettings::GetCollectStatsConsent();
+ return install_static::GetCollectStatsConsent();
}
bool ChromeCrashReporterClient::EnableBreakpadForProcess(
« no previous file with comments | « chrome/app/DEPS ('k') | chrome/chrome_dll.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698