diff options
-rw-r--r-- | chrome/app/breakpad_mac.mm | 41 | ||||
-rw-r--r-- | chrome/browser/browser_child_process_host.cc | 12 |
2 files changed, 40 insertions, 13 deletions
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm index 1d701de..a7d580d 100644 --- a/chrome/app/breakpad_mac.mm +++ b/chrome/app/breakpad_mac.mm @@ -1,9 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. #import "chrome/app/breakpad_mac.h" +#include <CoreFoundation/CoreFoundation.h> #import <Foundation/Foundation.h> #include "base/base_switches.h" @@ -13,11 +14,13 @@ #include "base/file_util.h" #import "base/logging.h" #include "base/mac_util.h" +#include "base/scoped_cftyperef.h" #import "base/scoped_nsautorelease_pool.h" #include "base/sys_string_conversions.h" #import "breakpad/src/client/mac/Framework/Breakpad.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/policy_constants.h" #include "chrome/installer/util/google_update_settings.h" namespace { @@ -42,20 +45,38 @@ void InitCrashReporter() { DCHECK(gBreakpadRef == NULL); base::ScopedNSAutoreleasePool autorelease_pool; - // Check whether the user has consented to stats and crash reporting. The - // browser process can make this determination directly. Helper processes - // may not have access to the disk or to the same data as the browser - // process, so the browser passes the consent preference to them on the + // Check whether crash reporting should be enabled. If enterprise + // configuration management controls crash reporting, it takes precedence. + // Otherwise, check whether the user has consented to stats and crash + // reporting. The browser process can make this determination directly. + // Helper processes may not have access to the disk or to the same data as + // the browser process, so the browser passes the decision to them on the // command line. NSBundle* main_bundle = mac_util::MainAppBundle(); bool is_browser = !mac_util::IsBackgroundOnlyProcess(); + bool enable_breakpad = false; CommandLine* command_line = CommandLine::ForCurrentProcess(); - bool enable_breakpad = - is_browser ? GoogleUpdateSettings::GetCollectStatsConsent() : - command_line->HasSwitch(switches::kEnableCrashReporter); - if (command_line->HasSwitch(switches::kDisableBreakpad)) { - enable_breakpad = false; + if (is_browser) { + // Since the configuration management infrastructure is possibly not + // initialized when this code runs, read the policy preference directly. + scoped_cftyperef<CFStringRef> key( + base::SysUTF8ToCFStringRef(policy::key::kMetricsReportingEnabled)); + Boolean key_valid; + Boolean metrics_reporting_enabled = CFPreferencesGetAppBooleanValue(key, + kCFPreferencesCurrentApplication, &key_valid); + if (key_valid && + CFPreferencesAppValueIsForced(key, kCFPreferencesCurrentApplication)) { + // Controlled by configuration manangement. + enable_breakpad = metrics_reporting_enabled; + } else { + // Controlled by the user. + enable_breakpad = GoogleUpdateSettings::GetCollectStatsConsent() && + !command_line->HasSwitch(switches::kDisableBreakpad); + } + } else { + // This is a helper process, check the command line switch. + enable_breakpad = command_line->HasSwitch(switches::kEnableCrashReporter); } if (!enable_breakpad) { diff --git a/chrome/browser/browser_child_process_host.cc b/chrome/browser/browser_child_process_host.cc index 8dbf668..7f8018b 100644 --- a/chrome/browser/browser_child_process_host.cc +++ b/chrome/browser/browser_child_process_host.cc @@ -14,13 +14,17 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/waitable_event.h" +#include "chrome/app/breakpad_mac.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/browser/pref_service.h" #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" #include "chrome/common/process_watcher.h" #include "chrome/common/result_codes.h" #include "chrome/installer/util/google_update_settings.h" @@ -94,9 +98,11 @@ void BrowserChildProcessHost::SetCrashReporterCommandLine( base::GetLinuxDistro()); } #elif defined(OS_MACOSX) - if (GoogleUpdateSettings::GetCollectStatsConsent()) - command_line->AppendSwitchASCII(switches::kEnableCrashReporter, - google_update::posix_guid); + if (IsCrashReporterEnabled()) { + std::string client_id = + g_browser_process->local_state()->GetString(prefs::kMetricsClientID); + command_line->AppendSwitchASCII(switches::kEnableCrashReporter, client_id); + } #endif // OS_MACOSX } |