breakpad_mac.mm 2.5 KB

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