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" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 // Only called for a branded build of Chrome.app. | 38 // Only called for a branded build of Chrome.app. |
39 void InitCrashReporter() { | 39 void InitCrashReporter() { |
40 DCHECK(gBreakpadRef == NULL); | 40 DCHECK(gBreakpadRef == NULL); |
41 base::ScopedNSAutoreleasePool autorelease_pool; | 41 base::ScopedNSAutoreleasePool autorelease_pool; |
42 | 42 |
43 // Check for Send stats preference. If preference is not specifically turned | 43 // Check for Send stats preference. If preference is not specifically turned |
44 // on then disable crash reporting. | 44 // on then disable crash reporting. |
45 if (!GoogleUpdateSettings::GetCollectStatsConsent()) { | 45 bool user_consented = GoogleUpdateSettings::GetCollectStatsConsent(); |
46 if (!user_consented) { | |
46 LOG(WARNING) << "Breakpad disabled"; | 47 LOG(WARNING) << "Breakpad disabled"; |
47 return; | 48 return; |
48 } | 49 } |
49 | 50 |
50 NSBundle* main_bundle = [NSBundle mainBundle]; | 51 NSBundle* main_bundle = [NSBundle mainBundle]; |
51 NSString* resource_path = [main_bundle resourcePath]; | 52 NSString* resource_path = [main_bundle resourcePath]; |
52 | 53 |
53 NSDictionary* info_dictionary = [main_bundle infoDictionary]; | 54 NSDictionary* info_dictionary = [main_bundle infoDictionary]; |
54 NSMutableDictionary *breakpad_config = [info_dictionary | 55 NSMutableDictionary *breakpad_config = [info_dictionary |
55 mutableCopy]; | 56 mutableCopy]; |
56 | 57 |
57 // Tell Breakpad where inspector & crash_reporter are. | 58 // Tell Breakpad where inspector & crash_reporter are. |
58 NSString *inspector_location = [resource_path | 59 NSString *inspector_location = [resource_path |
59 stringByAppendingPathComponent:@"crash_inspector"]; | 60 stringByAppendingPathComponent:@"crash_inspector"]; |
60 NSString *reporter_bundle_location = [resource_path | 61 NSString *reporter_bundle_location = [resource_path |
61 stringByAppendingPathComponent:@"crash_report_sender.app"]; | 62 stringByAppendingPathComponent:@"crash_report_sender.app"]; |
62 NSString *reporter_location = [[NSBundle | 63 NSString *reporter_location = [[NSBundle |
63 bundleWithPath:reporter_bundle_location] | 64 bundleWithPath:reporter_bundle_location] |
64 executablePath]; | 65 executablePath]; |
65 | 66 |
66 [breakpad_config setObject:inspector_location | 67 [breakpad_config setObject:inspector_location |
67 forKey:@BREAKPAD_INSPECTOR_LOCATION]; | 68 forKey:@BREAKPAD_INSPECTOR_LOCATION]; |
68 [breakpad_config setObject:reporter_location | 69 [breakpad_config setObject:reporter_location |
69 forKey:@BREAKPAD_REPORTER_EXE_LOCATION]; | 70 forKey:@BREAKPAD_REPORTER_EXE_LOCATION]; |
70 | 71 |
72 // Pass crash to Crash Reporter if we're a foreground application [the | |
73 // browser process]. This is so the user gets notification when Chrome | |
74 // crashes and also since we get "restart ui" for free. | |
75 BOOL is_background_app = [[info_dictionary objectForKey:@"LSUIElement"] | |
76 isEqualToString:@"1"]; | |
77 if (!is_background_app) { | |
78 [breakpad_config setObject:@"NO" forKey:@BREAKPAD_SEND_AND_EXIT]; | |
John Grabowski
2009/08/12 22:38:25
Are you sure this is @"NO" and not [NSNumber numbe
| |
79 } | |
80 | |
71 // Init breakpad | 81 // Init breakpad |
72 BreakpadRef breakpad = NULL; | 82 BreakpadRef breakpad = NULL; |
73 breakpad = BreakpadCreate(breakpad_config); | 83 breakpad = BreakpadCreate(breakpad_config); |
74 if (!breakpad) { | 84 if (!breakpad) { |
75 LOG(ERROR) << "Breakpad init failed."; | 85 LOG(ERROR) << "Breakpad init failed."; |
76 return; | 86 return; |
77 } | 87 } |
78 | 88 |
79 // This needs to be set before calling SetCrashKeyValue(). | 89 // This needs to be set before calling SetCrashKeyValue(). |
80 gBreakpadRef = breakpad; | 90 gBreakpadRef = breakpad; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 void ClearCrashKeyValue(NSString* key) { | 135 void ClearCrashKeyValue(NSString* key) { |
126 if (gBreakpadRef == NULL) { | 136 if (gBreakpadRef == NULL) { |
127 return; | 137 return; |
128 } | 138 } |
129 | 139 |
130 BreakpadRemoveUploadParameter(gBreakpadRef, key); | 140 BreakpadRemoveUploadParameter(gBreakpadRef, key); |
131 } | 141 } |
132 | 142 |
133 } | 143 } |
134 | 144 |
OLD | NEW |