Update V8 to version 4.6.61.
[chromium-blink-merge.git] / remoting / base / breakpad_mac.mm
blob1dbd11fe31e439d6797aa137de801fd5e0cdaf50
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
3 // found in the LICENSE file.
5 #include "remoting/base/breakpad.h"
7 #include <Foundation/Foundation.h>
9 #include "base/logging.h"
10 #import "base/mac/scoped_nsautorelease_pool.h"
11 #import "breakpad/src/client/mac/Framework/Breakpad.h"
13 namespace remoting {
15 void InitializeCrashReporting() {
16   base::mac::ScopedNSAutoreleasePool autorelease_pool;
18   NSBundle* main_bundle = [NSBundle mainBundle];
20   // Tell Breakpad where crash_inspector and crash_report_sender are.
21   NSString* resource_path = [main_bundle resourcePath];
22   NSString* inspector_location =
23       [resource_path stringByAppendingPathComponent:@"crash_inspector"];
24   NSString* reporter_bundle_location =
25       [resource_path stringByAppendingPathComponent:@"crash_report_sender.app"];
26   NSString* reporter_location =
27       [[NSBundle bundleWithPath:reporter_bundle_location] executablePath];
29   NSDictionary* info_dictionary = [main_bundle infoDictionary];
30   NSMutableDictionary* breakpad_config =
31       [[info_dictionary mutableCopy] autorelease];
32   [breakpad_config setObject:inspector_location
33                       forKey:@BREAKPAD_INSPECTOR_LOCATION];
34   [breakpad_config setObject:reporter_location
35                       forKey:@BREAKPAD_REPORTER_EXE_LOCATION];
37   // Configure Breakpad settings here, if they are not already customized in
38   // the Info.plist. These settings should be added to the plist, but the
39   // problem is that the Breakpad URL contains a double-slash, which is broken
40   // by the INFOPLIST_PREPROCESS step.
41   // TODO(lambroslambrou): Add these to the Info.plist, similarly to what is
42   // done for Chrome Framework - see 'Tweak Info.plist' in
43   // chrome/chrome_dll_bundle.gypi.
44   if (![breakpad_config objectForKey:@BREAKPAD_SKIP_CONFIRM]) {
45     // Skip the upload confirmation dialog, since this is a remote-access
46     // service that shouldn't rely on a console user to dismiss any prompt.
47     // Also, this may be running in the LoginWindow context, where prompting
48     // might not be possible.
49     [breakpad_config setObject:@"YES"
50                         forKey:@BREAKPAD_SKIP_CONFIRM];
51   }
52   if (![breakpad_config objectForKey:@BREAKPAD_REPORT_INTERVAL]) {
53     // Set a minimum 6-hour interval between crash-reports, to match the
54     // throttling used on Windows.
55     [breakpad_config setObject:@"21600"
56                         forKey:@BREAKPAD_REPORT_INTERVAL];
57   }
58   if (![breakpad_config objectForKey:@BREAKPAD_URL]) {
59     [breakpad_config setObject:@"https://clients2.google.com/cr/report"
60                         forKey:@BREAKPAD_URL];
61   }
63   if (!BreakpadCreate(breakpad_config)) {
64     LOG(ERROR) << "Breakpad initialization failed";
65   }
68 }  // namespace remoting