summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 09:59:40 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 09:59:40 +0000
commite8628000dfefa9d64ce3d26d0ab2b0851af68718 (patch)
treeccd8406e390872aa12c921a82198cd41c96ce3ae /chrome
parent9420283b16b82f3765e2c32a6f5035fe65c267f5 (diff)
downloadchromium_src-e8628000dfefa9d64ce3d26d0ab2b0851af68718.zip
chromium_src-e8628000dfefa9d64ce3d26d0ab2b0851af68718.tar.gz
chromium_src-e8628000dfefa9d64ce3d26d0ab2b0851af68718.tar.bz2
Don't initialize the crash reporter on windows if disabled by configuration management.
BUG=49662 TEST=No crash reports get submitted if policy doesn't allow it. Review URL: http://codereview.chromium.org/3033030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54525 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad_win.cc49
-rw-r--r--chrome/browser/configuration_policy_provider.cc31
-rw-r--r--chrome/browser/configuration_policy_provider_win.cc22
-rw-r--r--chrome/browser/configuration_policy_provider_win_unittest.cc13
-rw-r--r--chrome/common/policy_constants.cc37
-rw-r--r--chrome/common/policy_constants.h41
-rw-r--r--chrome/common_constants.gypi2
7 files changed, 150 insertions, 45 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index 06ace8e..efb5b3e 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -17,12 +17,14 @@
#include "base/file_version_info.h"
#include "base/registry.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/win_util.h"
#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/result_codes.h"
+#include "chrome/common/policy_constants.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"
@@ -385,6 +387,29 @@ bool ShowRestartDialogIfCrashed(bool* exit_now) {
flags, exit_now);
}
+// 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, |result|
+// contains the value set by policy.
+static bool MetricsReportingControlledByPolicy(bool* result) {
+ std::wstring key_name = UTF8ToWide(policy::key::kMetricsReportingEnabled);
+ DWORD value;
+ RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey);
+ if (hkcu_policy_key.ReadValueDW(key_name.c_str(), &value)) {
+ *result = value != 0;
+ return true;
+ }
+
+ RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey);
+ if (hklm_policy_key.ReadValueDW(key_name.c_str(), &value)) {
+ *result = value != 0;
+ return true;
+ }
+
+ return false;
+}
+
static DWORD __stdcall InitCrashReporterThread(void* param) {
scoped_ptr<CrashReporterInfo> info(
reinterpret_cast<CrashReporterInfo*>(param));
@@ -400,9 +425,16 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
callback = &DumpDoneCallback;
}
+ // Check whether configuration management controls crash reporting.
+ bool crash_reporting_enabled = true;
+ bool controlled_by_policy =
+ MetricsReportingControlledByPolicy(&crash_reporting_enabled);
+
const CommandLine& command = *CommandLine::ForCurrentProcess();
- bool use_crash_service = command.HasSwitch(switches::kNoErrorDialogs) ||
- GetEnvironmentVariable(ASCIIToWide(env_vars::kHeadless).c_str(), NULL, 0);
+ bool use_crash_service = !controlled_by_policy &&
+ ((command.HasSwitch(switches::kNoErrorDialogs) ||
+ GetEnvironmentVariable(
+ ASCIIToWide(env_vars::kHeadless).c_str(), NULL, 0)));
bool is_per_user_install =
InstallUtil::IsPerUserInstall(info->dll_path.c_str());
@@ -412,10 +444,15 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
pipe_name = kChromePipeName;
} else {
// We want to use the Google Update crash reporting. We need to check if the
- // user allows it first.
- if (!GoogleUpdateSettings::GetCollectStatsConsent()) {
- // The user did not allow Google Update to send crashes, we need to use
- // our default crash handler instead, but only for the browser process.
+ // user allows it first (in case the administrator didn't already decide
+ // via policy).
+ if (!controlled_by_policy)
+ crash_reporting_enabled = GoogleUpdateSettings::GetCollectStatsConsent();
+
+ if (!crash_reporting_enabled) {
+ // Configuration managed or the user did not allow Google Update to send
+ // crashes, we need to use our default crash handler instead, but only
+ // for the browser process.
if (callback)
InitDefaultCrashCallback();
return 0;
diff --git a/chrome/browser/configuration_policy_provider.cc b/chrome/browser/configuration_policy_provider.cc
index cb6e210..31930a0 100644
--- a/chrome/browser/configuration_policy_provider.cc
+++ b/chrome/browser/configuration_policy_provider.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/configuration_policy_provider.h"
#include "base/values.h"
+#include "chrome/common/policy_constants.h"
namespace {
@@ -19,35 +20,35 @@ struct InternalPolicyValueMapEntry {
const InternalPolicyValueMapEntry kPolicyValueMap[] = {
{ ConfigurationPolicyStore::kPolicyHomePage,
- Value::TYPE_STRING, "HomepageLocation" },
+ Value::TYPE_STRING, policy::key::kHomepageLocation },
{ ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage,
- Value::TYPE_BOOLEAN, "HomepageIsNewTabPage" },
+ Value::TYPE_BOOLEAN, policy::key::kHomepageIsNewTabPage },
{ ConfigurationPolicyStore::kPolicyProxyServerMode,
- Value::TYPE_INTEGER, "ProxyServerMode" },
+ Value::TYPE_INTEGER, policy::key::kProxyServerMode },
{ ConfigurationPolicyStore::kPolicyProxyServer,
- Value::TYPE_STRING, "ProxyServer" },
+ Value::TYPE_STRING, policy::key::kProxyServer },
{ ConfigurationPolicyStore::kPolicyProxyPacUrl,
- Value::TYPE_STRING, "ProxyPacUrl" },
+ Value::TYPE_STRING, policy::key::kProxyPacUrl },
{ ConfigurationPolicyStore::kPolicyProxyBypassList,
- Value::TYPE_STRING, "ProxyBypassList" },
+ Value::TYPE_STRING, policy::key::kProxyBypassList },
{ ConfigurationPolicyStore::kPolicyAlternateErrorPagesEnabled,
- Value::TYPE_BOOLEAN, "AlternateErrorPagesEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kAlternateErrorPagesEnabled },
{ ConfigurationPolicyStore::kPolicySearchSuggestEnabled,
- Value::TYPE_BOOLEAN, "SearchSuggestEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kSearchSuggestEnabled },
{ ConfigurationPolicyStore::kPolicyDnsPrefetchingEnabled,
- Value::TYPE_BOOLEAN, "DnsPrefetchingEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kDnsPrefetchingEnabled },
{ ConfigurationPolicyStore::kPolicySafeBrowsingEnabled,
- Value::TYPE_BOOLEAN, "SafeBrowsingEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kSafeBrowsingEnabled },
{ ConfigurationPolicyStore::kPolicyMetricsReportingEnabled,
- Value::TYPE_BOOLEAN, "MetricsReportingEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kMetricsReportingEnabled },
{ ConfigurationPolicyStore::kPolicyPasswordManagerEnabled,
- Value::TYPE_BOOLEAN, "PasswordManagerEnabled" },
+ Value::TYPE_BOOLEAN, policy::key::kPasswordManagerEnabled },
{ ConfigurationPolicyStore::kPolicyDisabledPlugins,
- Value::TYPE_STRING, "DisabledPluginsList" },
+ Value::TYPE_STRING, policy::key::kDisabledPluginsList },
{ ConfigurationPolicyStore::kPolicyApplicationLocale,
- Value::TYPE_STRING, "ApplicationLocaleValue" },
+ Value::TYPE_STRING, policy::key::kApplicationLocaleValue },
{ ConfigurationPolicyStore::kPolicySyncDisabled,
- Value::TYPE_BOOLEAN, "SyncDisabled" },
+ Value::TYPE_BOOLEAN, policy::key::kSyncDisabled },
};
} // namespace
diff --git a/chrome/browser/configuration_policy_provider_win.cc b/chrome/browser/configuration_policy_provider_win.cc
index d39adeef..a52c123 100644
--- a/chrome/browser/configuration_policy_provider_win.cc
+++ b/chrome/browser/configuration_policy_provider_win.cc
@@ -13,14 +13,7 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-
-#if defined(GOOGLE_CHROME_BUILD)
-const wchar_t ConfigurationPolicyProviderWin::kPolicyRegistrySubKey[] =
- L"SOFTWARE\\Policies\\Google\\Chrome";
-#else
-const wchar_t ConfigurationPolicyProviderWin::kPolicyRegistrySubKey[] =
- L"SOFTWARE\\Policies\\Chromium";
-#endif
+#include "chrome/common/policy_constants.h"
ConfigurationPolicyProviderWin::ConfigurationPolicyProviderWin() {
}
@@ -30,7 +23,7 @@ bool ConfigurationPolicyProviderWin::GetRegistryPolicyString(
DWORD value_size = 0;
DWORD key_type = 0;
scoped_array<uint8> buffer;
- RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, kPolicyRegistrySubKey);
+ RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey);
if (hkcu_policy_key.ReadValue(value_name, 0, &value_size, &key_type)) {
if (key_type != REG_SZ)
return false;
@@ -42,7 +35,7 @@ bool ConfigurationPolicyProviderWin::GetRegistryPolicyString(
memset(buffer.get(), 0, value_size + 2);
hkcu_policy_key.ReadValue(value_name, buffer.get(), &value_size);
} else {
- RegKey hklm_policy_key(HKEY_CURRENT_USER, kPolicyRegistrySubKey);
+ RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey);
if (hklm_policy_key.ReadValue(value_name, 0, &value_size, &key_type)) {
if (key_type != REG_SZ)
return false;
@@ -65,13 +58,13 @@ bool ConfigurationPolicyProviderWin::GetRegistryPolicyString(
bool ConfigurationPolicyProviderWin::GetRegistryPolicyBoolean(
const wchar_t* value_name, bool* result) {
DWORD value;
- RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, kPolicyRegistrySubKey);
+ RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey);
if (hkcu_policy_key.ReadValueDW(value_name, &value)) {
*result = value != 0;
return true;
}
- RegKey hklm_policy_key(HKEY_CURRENT_USER, kPolicyRegistrySubKey);
+ RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey);
if (hklm_policy_key.ReadValueDW(value_name, &value)) {
*result = value != 0;
return true;
@@ -82,13 +75,13 @@ bool ConfigurationPolicyProviderWin::GetRegistryPolicyBoolean(
bool ConfigurationPolicyProviderWin::GetRegistryPolicyInteger(
const wchar_t* value_name, uint32* result) {
DWORD value;
- RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, kPolicyRegistrySubKey);
+ RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey);
if (hkcu_policy_key.ReadValueDW(value_name, &value)) {
*result = value;
return true;
}
- RegKey hklm_policy_key(HKEY_CURRENT_USER, kPolicyRegistrySubKey);
+ RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey);
if (hklm_policy_key.ReadValueDW(value_name, &value)) {
*result = value;
return true;
@@ -134,4 +127,3 @@ bool ConfigurationPolicyProviderWin::Provide(
return true;
}
-
diff --git a/chrome/browser/configuration_policy_provider_win_unittest.cc b/chrome/browser/configuration_policy_provider_win_unittest.cc
index 6197780..4d39ff6 100644
--- a/chrome/browser/configuration_policy_provider_win_unittest.cc
+++ b/chrome/browser/configuration_policy_provider_win_unittest.cc
@@ -14,6 +14,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/configuration_policy_provider_win.h"
#include "chrome/browser/mock_configuration_policy_store.h"
+#include "chrome/common/policy_constants.h"
#include "chrome/common/pref_names.h"
namespace {
@@ -64,9 +65,7 @@ std::wstring NameForPolicy(ConfigurationPolicyStore::PolicyType policy) {
void TestConfigurationPolicyProviderWin::SetHomepageRegistryValue(
HKEY hive,
const wchar_t* value) {
- RegKey key(hive,
- ConfigurationPolicyProviderWin::kPolicyRegistrySubKey,
- KEY_ALL_ACCESS);
+ RegKey key(hive, policy::kRegistrySubKey, KEY_ALL_ACCESS);
EXPECT_TRUE(key.WriteValue(
NameForPolicy(ConfigurationPolicyStore::kPolicyHomePage).c_str(),
value));
@@ -74,9 +73,7 @@ void TestConfigurationPolicyProviderWin::SetHomepageRegistryValue(
void TestConfigurationPolicyProviderWin::SetHomepageRegistryValueWrongType(
HKEY hive) {
- RegKey key(hive,
- ConfigurationPolicyProviderWin::kPolicyRegistrySubKey,
- KEY_ALL_ACCESS);
+ RegKey key(hive, policy::kRegistrySubKey, KEY_ALL_ACCESS);
EXPECT_TRUE(key.WriteValue(
NameForPolicy(ConfigurationPolicyStore::kPolicyHomePage).c_str(),
5));
@@ -86,8 +83,7 @@ void TestConfigurationPolicyProviderWin::SetBooleanPolicy(
ConfigurationPolicyStore::PolicyType type,
HKEY hive,
bool value) {
- RegKey key(hive, ConfigurationPolicyProviderWin::kPolicyRegistrySubKey,
- KEY_ALL_ACCESS);
+ RegKey key(hive, policy::kRegistrySubKey, KEY_ALL_ACCESS);
EXPECT_TRUE(key.WriteValue(NameForPolicy(type).c_str(), value));
}
@@ -312,4 +308,3 @@ TEST_F(ConfigurationPolicyProviderWinTest,
TestPolicyPasswordManagerEnabled) {
TestBooleanPolicy(ConfigurationPolicyStore::kPolicyPasswordManagerEnabled);
}
-
diff --git a/chrome/common/policy_constants.cc b/chrome/common/policy_constants.cc
new file mode 100644
index 0000000..7c0b5b4
--- /dev/null
+++ b/chrome/common/policy_constants.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/common/policy_constants.h"
+
+namespace policy {
+
+#if defined(OS_WIN)
+#if defined(GOOGLE_CHROME_BUILD)
+const wchar_t kRegistrySubKey[] = L"SOFTWARE\\Policies\\Google\\Chrome";
+#else
+const wchar_t kRegistrySubKey[] = L"SOFTWARE\\Policies\\Chromium";
+#endif
+#endif
+
+namespace key {
+
+const char kHomepageLocation[] = "HomepageLocation";
+const char kHomepageIsNewTabPage[] = "HomepageIsNewTabPage";
+const char kProxyServerMode[] = "ProxyServerMode";
+const char kProxyServer[] = "ProxyServer";
+const char kProxyPacUrl[] = "ProxyPacUrl";
+const char kProxyBypassList[] = "ProxyBypassList";
+const char kAlternateErrorPagesEnabled[] = "AlternateErrorPagesEnabled";
+const char kSearchSuggestEnabled[] = "SearchSuggestEnabled";
+const char kDnsPrefetchingEnabled[] = "DnsPrefetchingEnabled";
+const char kSafeBrowsingEnabled[] = "SafeBrowsingEnabled";
+const char kMetricsReportingEnabled[] = "MetricsReportingEnabled";
+const char kPasswordManagerEnabled[] = "PasswordManagerEnabled";
+const char kDisabledPluginsList[] = "DisabledPluginsList";
+const char kApplicationLocaleValue[] = "ApplicationLocaleValue";
+const char kSyncDisabled[] = "SyncDisabled";
+
+} // namespace key
+
+} // namespace policy
diff --git a/chrome/common/policy_constants.h b/chrome/common/policy_constants.h
new file mode 100644
index 0000000..37107db
--- /dev/null
+++ b/chrome/common/policy_constants.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_COMMON_POLICY_CONSTANTS_H_
+#define CHROME_COMMON_POLICY_CONSTANTS_H_
+#pragma once
+
+#include "build/build_config.h"
+
+namespace policy {
+
+#if defined(OS_WIN)
+// The windows registry path we read the policy configuration from.
+extern const wchar_t kRegistrySubKey[];
+#endif
+
+// Key names for the policy settings.
+namespace key {
+
+extern const char kHomepageLocation[];
+extern const char kHomepageIsNewTabPage[];
+extern const char kProxyServerMode[];
+extern const char kProxyServer[];
+extern const char kProxyPacUrl[];
+extern const char kProxyBypassList[];
+extern const char kAlternateErrorPagesEnabled[];
+extern const char kSearchSuggestEnabled[];
+extern const char kDnsPrefetchingEnabled[];
+extern const char kSafeBrowsingEnabled[];
+extern const char kMetricsReportingEnabled[];
+extern const char kPasswordManagerEnabled[];
+extern const char kDisabledPluginsList[];
+extern const char kApplicationLocaleValue[];
+extern const char kSyncDisabled[];
+
+} // namespace key
+
+} // namespace policy
+
+#endif // CHROME_COMMON_POLICY_CONSTANTS_H_
diff --git a/chrome/common_constants.gypi b/chrome/common_constants.gypi
index 47b4d58..07eee8c 100644
--- a/chrome/common_constants.gypi
+++ b/chrome/common_constants.gypi
@@ -26,6 +26,8 @@
'common/json_value_serializer.h',
'common/net/gaia/gaia_constants.cc',
'common/net/gaia/gaia_constants.h',
+ 'common/policy_constants.cc',
+ 'common/policy_constants.h',
'common/pref_names.cc',
'common/pref_names.h',
],