summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 07:58:19 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 07:58:19 +0000
commit1b084b5e0489af11d34e24286712668a5e61edfd (patch)
tree4473665981fd335fc0adde36f898ce4623aa1dcf
parent91e9253e23325eaee915ab6fcd8ecae718b9108b (diff)
downloadchromium_src-1b084b5e0489af11d34e24286712668a5e61edfd.zip
chromium_src-1b084b5e0489af11d34e24286712668a5e61edfd.tar.gz
chromium_src-1b084b5e0489af11d34e24286712668a5e61edfd.tar.bz2
[linux] Hook up crash reporter initialization with configuration management.
BUG=49662 TEST=Enable/Disable metrics reporting through policy and check whether the crash reporter respects that. Review URL: http://codereview.chromium.org/3084008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54716 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_linux.cc5
-rw-r--r--chrome/browser/browser_child_process_host.cc20
-rw-r--r--chrome/browser/browser_main.cc32
3 files changed, 29 insertions, 28 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index c3a4652..22f69f9 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -739,11 +739,8 @@ void InitCrashReporter() {
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
const std::string process_type =
parsed_command_line.GetSwitchValueASCII(switches::kProcessType);
- const bool unattended = (getenv(env_vars::kHeadless) != NULL);
if (process_type.empty()) {
- if (!(unattended || GoogleUpdateSettings::GetCollectStatsConsent()))
- return;
- EnableCrashDumping(unattended);
+ EnableCrashDumping(getenv(env_vars::kHeadless) != NULL);
} else if (process_type == switches::kRendererProcess ||
process_type == switches::kPluginProcess ||
process_type == switches::kZygoteProcess) {
diff --git a/chrome/browser/browser_child_process_host.cc b/chrome/browser/browser_child_process_host.cc
index 7f8018b..be7a037 100644
--- a/chrome/browser/browser_child_process_host.cc
+++ b/chrome/browser/browser_child_process_host.cc
@@ -21,7 +21,6 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/env_vars.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/plugin_messages.h"
#include "chrome/common/pref_names.h"
@@ -33,16 +32,6 @@
#include "base/linux_util.h"
#endif // OS_LINUX
-#if defined(OS_POSIX)
-// This is defined in chrome/browser/google_update_settings_posix.cc. It's the
-// static string containing the user's unique GUID. We send this in the crash
-// report.
-namespace google_update {
-extern std::string posix_guid;
-} // namespace google_update
-#endif // OS_POSIX
-
-
namespace {
typedef std::list<BrowserChildProcessHost*> ChildProcessList;
@@ -90,12 +79,11 @@ BrowserChildProcessHost::~BrowserChildProcessHost() {
void BrowserChildProcessHost::SetCrashReporterCommandLine(
CommandLine* command_line) {
#if defined(USE_LINUX_BREAKPAD)
- const bool unattended = (getenv(env_vars::kHeadless) != NULL);
- if (unattended || GoogleUpdateSettings::GetCollectStatsConsent()) {
+ if (IsCrashReporterEnabled()) {
+ std::string client_id =
+ g_browser_process->local_state()->GetString(prefs::kMetricsClientID);
command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
- google_update::posix_guid +
- "," +
- base::GetLinuxDistro());
+ client_id + "," + base::GetLinuxDistro());
}
#elif defined(OS_MACOSX)
if (IsCrashReporterEnabled()) {
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 81e78a7..dd9e817 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -62,6 +62,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/env_vars.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/main_function_params.h"
@@ -801,14 +802,6 @@ int BrowserMain(const MainFunctionParams& parameters) {
// tabs.
g_browser_process->tab_closeable_state_watcher();
-#if defined(USE_LINUX_BREAKPAD)
- // Needs to be called after we have chrome::DIR_USER_DATA and
- // g_browser_process.
- g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
- new GetLinuxDistroTask());
- InitCrashReporter();
-#endif
-
// The broker service initialization needs to run early because it will
// initialize the sandbox broker, which requires the process to swap its
// window station. During this time all the UI will be broken. This has to
@@ -818,6 +811,29 @@ int BrowserMain(const MainFunctionParams& parameters) {
PrefService* local_state = InitializeLocalState(parsed_command_line,
is_first_run);
+#if defined(USE_LINUX_BREAKPAD)
+ // Needs to be called after we have chrome::DIR_USER_DATA and
+ // g_browser_process.
+ g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
+ new GetLinuxDistroTask());
+
+ // Check whether we should initialize the crash reporter. It may be disabled
+ // through configuration policy or user preference. The kHeadless environment
+ // variable overrides the decision, but only if the crash service is under
+ // control of the user.
+ const PrefService::Preference* metrics_reporting_enabled =
+ local_state->FindPreference(prefs::kMetricsReportingEnabled);
+ CHECK(metrics_reporting_enabled);
+ bool breakpad_enabled =
+ local_state->GetBoolean(prefs::kMetricsReportingEnabled);
+ if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) {
+ breakpad_enabled = (getenv(env_vars::kHeadless) != NULL) ||
+ parsed_command_line.HasSwitch(switches::kEnableCrashReporter);
+ }
+ if (breakpad_enabled)
+ InitCrashReporter();
+#endif
+
InitializeToolkit(); // Must happen before we try to display any UI.
// If we're running tests (ui_task is non-null), then the ResourceBundle