OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 | |
5 // ====== New Architecture ===== | |
6 // = This code is only used in the new iOS Chrome architecture. = | |
7 // ============================================================================ | |
8 | |
9 #import <UIKit/UIKit.h> | |
10 | |
11 #include "base/at_exit.h" | |
12 #include "base/debug/crash_logging.h" | |
13 #include "components/crash/core/common/crash_keys.h" | |
14 #include "ios/chrome/app/app_delegate.h" | |
15 #include "ios/chrome/app/startup/ios_chrome_main.h" | |
16 #include "ios/chrome/browser/crash_report/breakpad_helper.h" | |
17 #include "ios/chrome/browser/crash_report/crash_keys.h" | |
18 #include "ios/chrome/common/channel_info.h" | |
19 | |
20 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
21 #error "This file requires ARC support." | |
22 #endif | |
23 | |
24 namespace { | |
25 | |
26 void StartCrashController() { | |
27 std::string channel_string = GetChannelString(); | |
28 | |
29 RegisterChromeIOSCrashKeys(); | |
30 base::debug::SetCrashKeyValue(crash_keys::kChannel, channel_string); | |
31 breakpad_helper::Start(channel_string); | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 int main(int argc, char* argv[]) { | |
37 // Create the AtExitManager for the application before the crash controller | |
38 // is started. This needs to be stack allocated and live for the lifetime of | |
39 // the app. | |
40 base::AtExitManager at_exit; | |
41 | |
42 IOSChromeMain::InitStartTime(); | |
43 | |
44 // Pre-launch actions are in their own autorelease pool so they get cleaned | |
45 // up before the main app starts. | |
46 @autoreleasepool { | |
47 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; | |
48 | |
49 // Set NSUserDefaults keys to force pseudo-RTL if needed. | |
50 if ([standardDefaults boolForKey:@"EnablePseudoRTL"]) { | |
51 NSDictionary* pseudoDict = @{ @"YES" : @"AppleTextDirection" }; | |
52 [standardDefaults registerDefaults:pseudoDict]; | |
53 } | |
54 | |
55 // The crash controller is started here, even though the user may have opted | |
56 // out; it needs to start as soon as possible to catch crashes during app | |
57 // launch. Since user preferences aren't loaded yet, it isn't known if the | |
58 // user has opted out. Once the preferences are loaded, the crash | |
59 // controller is stopped for opted-out users, and any crash reports that | |
60 // are collected before then are not sent. | |
61 StartCrashController(); | |
62 | |
63 // Always ignore SIGPIPE. Chrome should always check the return value of | |
64 // write() instead of relying on this signal. | |
65 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); | |
66 } | |
67 | |
68 @autoreleasepool { | |
69 return UIApplicationMain(argc, argv, nil, | |
70 NSStringFromClass([AppDelegate class])); | |
71 } | |
72 } | |
OLD | NEW |