| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/app/breakpad_mac.h" | 5 #import "chrome/app/breakpad_mac.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
| 12 #import "base/basictypes.h" | 12 #import "base/basictypes.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/crash_logging.h" | 14 #include "base/debug/crash_logging.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #import "base/logging.h" | 17 #import "base/logging.h" |
| 18 #include "base/mac/bundle_locations.h" | 18 #include "base/mac/bundle_locations.h" |
| 19 #include "base/mac/mac_util.h" | 19 #include "base/mac/mac_util.h" |
| 20 #include "base/mac/scoped_cftyperef.h" | 20 #include "base/mac/scoped_cftyperef.h" |
| 21 #import "base/mac/scoped_nsautorelease_pool.h" | 21 #import "base/mac/scoped_nsautorelease_pool.h" |
| 22 #include "base/strings/sys_string_conversions.h" | 22 #include "base/strings/sys_string_conversions.h" |
| 23 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
| 24 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 25 #import "breakpad/src/client/mac/Framework/Breakpad.h" | 25 #import "breakpad/src/client/mac/Framework/Breakpad.h" |
| 26 #include "chrome/common/child_process_logging.h" | 26 #include "chrome/common/child_process_logging.h" |
| 27 #include "chrome/common/env_vars.h" | |
| 28 #include "chrome/installer/util/google_update_settings.h" | 27 #include "chrome/installer/util/google_update_settings.h" |
| 29 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 30 #include "components/breakpad/breakpad_client.h" | 29 #include "components/breakpad/breakpad_client.h" |
| 31 #include "components/nacl/common/nacl_switches.h" | 30 #include "components/nacl/common/nacl_switches.h" |
| 32 #include "native_client/src/trusted/service_runtime/osx/crash_filter.h" | 31 #include "native_client/src/trusted/service_runtime/osx/crash_filter.h" |
| 33 #include "policy/policy_constants.h" | 32 #include "policy/policy_constants.h" |
| 34 | 33 |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 BreakpadRef gBreakpadRef = NULL; | 36 BreakpadRef gBreakpadRef = NULL; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 kCFPreferencesCurrentApplication, &key_valid); | 185 kCFPreferencesCurrentApplication, &key_valid); |
| 187 if (key_valid && | 186 if (key_valid && |
| 188 CFPreferencesAppValueIsForced(key, kCFPreferencesCurrentApplication)) { | 187 CFPreferencesAppValueIsForced(key, kCFPreferencesCurrentApplication)) { |
| 189 // Controlled by configuration manangement. | 188 // Controlled by configuration manangement. |
| 190 enable_breakpad = metrics_reporting_enabled; | 189 enable_breakpad = metrics_reporting_enabled; |
| 191 } else { | 190 } else { |
| 192 // Controlled by the user. The crash reporter may be enabled by | 191 // Controlled by the user. The crash reporter may be enabled by |
| 193 // preference or through an environment variable, but the kDisableBreakpad | 192 // preference or through an environment variable, but the kDisableBreakpad |
| 194 // switch overrides both. | 193 // switch overrides both. |
| 195 enable_breakpad = GoogleUpdateSettings::GetCollectStatsConsent() || | 194 enable_breakpad = GoogleUpdateSettings::GetCollectStatsConsent() || |
| 196 getenv(env_vars::kHeadless) != NULL; | 195 breakpad::GetBreakpadClient()->IsRunningUnattended(); |
| 197 enable_breakpad &= !command_line->HasSwitch(switches::kDisableBreakpad); | 196 enable_breakpad &= !command_line->HasSwitch(switches::kDisableBreakpad); |
| 198 } | 197 } |
| 199 } else { | 198 } else { |
| 200 // This is a helper process, check the command line switch. | 199 // This is a helper process, check the command line switch. |
| 201 enable_breakpad = command_line->HasSwitch(switches::kEnableCrashReporter); | 200 enable_breakpad = command_line->HasSwitch(switches::kEnableCrashReporter); |
| 202 } | 201 } |
| 203 | 202 |
| 204 if (!enable_breakpad) { | 203 if (!enable_breakpad) { |
| 205 VLOG_IF(1, is_browser) << "Breakpad disabled"; | 204 VLOG_IF(1, is_browser) << "Breakpad disabled"; |
| 206 return; | 205 return; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 293 |
| 295 #if !defined(DISABLE_NACL) | 294 #if !defined(DISABLE_NACL) |
| 296 if (process_type_switch == switches::kNaClLoaderProcess) { | 295 if (process_type_switch == switches::kNaClLoaderProcess) { |
| 297 BreakpadSetFilterCallback(gBreakpadRef, NaClBreakpadCrashFilter, NULL); | 296 BreakpadSetFilterCallback(gBreakpadRef, NaClBreakpadCrashFilter, NULL); |
| 298 } | 297 } |
| 299 #endif | 298 #endif |
| 300 | 299 |
| 301 // Store process type in crash dump. | 300 // Store process type in crash dump. |
| 302 SetCrashKeyValue(@"ptype", process_type); | 301 SetCrashKeyValue(@"ptype", process_type); |
| 303 } | 302 } |
| OLD | NEW |