1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/app/chrome_crash_reporter_client.h"
7 #include <CoreFoundation/CoreFoundation.h>
9 #include "base/apple/scoped_cftyperef.h"
10 #include "base/path_service.h"
11 #include "base/rand_util.h"
12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/common/channel_info.h"
14 #include "chrome/common/chrome_paths.h"
15 #include "components/policy/policy_constants.h"
16 #include "components/version_info/version_info.h"
18 bool ChromeCrashReporterClient::ReportingIsEnforcedByPolicy(
19 bool* breakpad_enabled) {
20 base::apple::ScopedCFTypeRef<CFStringRef> key =
21 base::SysUTF8ToCFStringRef(policy::key::kMetricsReportingEnabled);
23 Boolean metrics_reporting_enabled = CFPreferencesGetAppBooleanValue(key,
24 kCFPreferencesCurrentApplication, &key_valid);
26 CFPreferencesAppValueIsForced(key, kCFPreferencesCurrentApplication)) {
27 *breakpad_enabled = metrics_reporting_enabled;
33 bool ChromeCrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
34 // This mechanism dedicates a process to be crashpad_handler's own
35 // crashpad_handler. In Google Chrome, scale back on this in the more stable
36 // channels. Other builds are of more of a developmental nature, so always
37 // enable the additional crash reporting.
39 switch (chrome::GetChannel()) {
40 case version_info::Channel::STABLE:
44 case version_info::Channel::BETA:
48 case version_info::Channel::DEV:
56 return base::RandDouble() < probability;