| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #import "base/basictypes.h" | 10 #import "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #import "base/logging.h" | 12 #import "base/logging.h" |
| 13 #import "base/scoped_nsautorelease_pool.h" | 13 #import "base/scoped_nsautorelease_pool.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #import "breakpad/src/client/mac/Framework/Breakpad.h" | 15 #import "breakpad/src/client/mac/Framework/Breakpad.h" |
| 16 #include "chrome/installer/util/google_update_settings.h" |
| 16 | 17 |
| 17 #if !defined(GOOGLE_CHROME_BUILD) | 18 #if !defined(GOOGLE_CHROME_BUILD) |
| 18 // If we aren't compiling as a branded build, then add dummy versions of the | 19 // If we aren't compiling as a branded build, then add dummy versions of the |
| 19 // Breakpad functions so we don't have to link against Breakpad. | 20 // Breakpad functions so we don't have to link against Breakpad. |
| 20 | 21 |
| 21 BreakpadRef BreakpadCreate(NSDictionary *parameters) { | 22 BreakpadRef BreakpadCreate(NSDictionary *parameters) { |
| 22 NOTREACHED(); | 23 NOTREACHED(); |
| 23 return NULL; | 24 return NULL; |
| 24 } | 25 } |
| 25 | 26 |
| 26 void BreakpadRelease(BreakpadRef ref) { | 27 void BreakpadRelease(BreakpadRef ref) { |
| 27 NOTREACHED(); | 28 NOTREACHED(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { | 31 void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { |
| 31 NOTREACHED(); | 32 NOTREACHED(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { | 35 void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { |
| 35 NOTREACHED(); | 36 NOTREACHED(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 #endif // !defined(GOOGLE_CHROME_BUILD) | 39 #endif // !defined(GOOGLE_CHROME_BUILD) |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 BreakpadRef gBreakpadRef = NULL; | 43 BreakpadRef gBreakpadRef = NULL; |
| 43 | 44 |
| 44 // Did the user optin for reporting stats. | |
| 45 bool IsStatsReportingAllowed() { | |
| 46 NOTIMPLEMENTED(); | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 } // namespace | 45 } // namespace |
| 51 | 46 |
| 52 bool IsCrashReporterEnabled() { | 47 bool IsCrashReporterEnabled() { |
| 53 return gBreakpadRef == NULL; | 48 return gBreakpadRef == NULL; |
| 54 } | 49 } |
| 55 | 50 |
| 56 void DestructCrashReporter() { | 51 void DestructCrashReporter() { |
| 57 if (gBreakpadRef) { | 52 if (gBreakpadRef) { |
| 58 BreakpadRelease(gBreakpadRef); | 53 BreakpadRelease(gBreakpadRef); |
| 59 gBreakpadRef = NULL; | 54 gBreakpadRef = NULL; |
| 60 } | 55 } |
| 61 } | 56 } |
| 62 | 57 |
| 63 // Only called for a branded build of Chrome.app. | 58 // Only called for a branded build of Chrome.app. |
| 64 void InitCrashReporter() { | 59 void InitCrashReporter() { |
| 65 DCHECK(gBreakpadRef == NULL); | 60 DCHECK(gBreakpadRef == NULL); |
| 66 base::ScopedNSAutoreleasePool autorelease_pool; | 61 base::ScopedNSAutoreleasePool autorelease_pool; |
| 67 | 62 |
| 68 // Check for Send stats preference. If preference is not specifically turned | 63 // Check for Send stats preference. If preference is not specifically turned |
| 69 // on then disable crash reporting. | 64 // on then disable crash reporting. |
| 70 if (!IsStatsReportingAllowed()) { | 65 if (!GoogleUpdateSettings::GetCollectStatsConsent()) { |
| 71 LOG(WARNING) << "Breakpad disabled"; | 66 LOG(WARNING) << "Breakpad disabled"; |
| 72 return; | 67 return; |
| 73 } | 68 } |
| 74 | 69 |
| 75 NSBundle* main_bundle = [NSBundle mainBundle]; | 70 NSBundle* main_bundle = [NSBundle mainBundle]; |
| 76 NSString* resource_path = [main_bundle resourcePath]; | 71 NSString* resource_path = [main_bundle resourcePath]; |
| 77 | 72 |
| 78 NSDictionary* info_dictionary = [main_bundle infoDictionary]; | 73 NSDictionary* info_dictionary = [main_bundle infoDictionary]; |
| 79 NSMutableDictionary *breakpad_config = [info_dictionary | 74 NSMutableDictionary *breakpad_config = [info_dictionary |
| 80 mutableCopy]; | 75 mutableCopy]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 BreakpadSetKeyValue(gBreakpadRef, key, value); | 138 BreakpadSetKeyValue(gBreakpadRef, key, value); |
| 144 } | 139 } |
| 145 | 140 |
| 146 void ClearCrashKeyValue(NSString* key) { | 141 void ClearCrashKeyValue(NSString* key) { |
| 147 if (gBreakpadRef == NULL) { | 142 if (gBreakpadRef == NULL) { |
| 148 return; | 143 return; |
| 149 } | 144 } |
| 150 | 145 |
| 151 BreakpadRemoveKeyValue(gBreakpadRef, key); | 146 BreakpadRemoveKeyValue(gBreakpadRef, key); |
| 152 } | 147 } |
| OLD | NEW |