Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: ios/chrome/app/safe_mode/safe_mode_coordinator.mm

Issue 2915043003: [ObjC ARC] Converts ios/chrome/app/safe_mode:safe_mode to ARC. (Closed)
Patch Set: missing_include Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "ios/chrome/app/safe_mode/safe_mode_coordinator.h" 5 #import "ios/chrome/app/safe_mode/safe_mode_coordinator.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #import "base/logging.h"
8 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h" 8 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h"
9 #include "ios/chrome/browser/crash_loop_detection_util.h" 9 #include "ios/chrome/browser/crash_loop_detection_util.h"
10 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
11 namespace { 15 namespace {
12 const int kStartupCrashLoopThreshold = 2; 16 const int kStartupCrashLoopThreshold = 2;
13 } 17 }
14 18
15 @interface SafeModeCoordinator ()<SafeModeViewControllerDelegate> { 19 @interface SafeModeCoordinator ()<SafeModeViewControllerDelegate>
16 // Weak pointer to window passed on init. 20 @end
17 base::WeakNSObject<UIWindow> _window; 21
18 // Weak pointer backing property of the same name. 22 @implementation SafeModeCoordinator {
19 base::WeakNSProtocol<id<SafeModeCoordinatorDelegate>> _delegate; 23 __weak UIWindow* _window;
20 } 24 }
21 25
22 @end 26 @synthesize delegate = _delegate;
23
24 @implementation SafeModeCoordinator
25
26 #pragma mark - property implementation.
27
28 - (id<SafeModeCoordinatorDelegate>)delegate {
29 return _delegate;
30 }
31
32 - (void)setDelegate:(id<SafeModeCoordinatorDelegate>)delegate {
33 _delegate.reset(delegate);
34 }
35 27
36 #pragma mark - Public class methods 28 #pragma mark - Public class methods
37 29
38 + (BOOL)shouldStart { 30 + (BOOL)shouldStart {
39 // Check whether there appears to be a startup crash loop. If not, don't look 31 // Check whether there appears to be a startup crash loop. If not, don't look
40 // at anything else. 32 // at anything else.
41 if (crash_util::GetFailedStartupAttemptCount() < kStartupCrashLoopThreshold) 33 if (crash_util::GetFailedStartupAttemptCount() < kStartupCrashLoopThreshold)
42 return NO; 34 return NO;
43 35
44 return [SafeModeViewController hasSuggestions]; 36 return [SafeModeViewController hasSuggestions];
45 } 37 }
46 38
47 #pragma mark - ChromeCoordinator implementation 39 #pragma mark - ChromeCoordinator implementation
48 40
49 - (void)start { 41 - (void)start {
50 // Create the SafeModeViewController and make it the root view controller for 42 // Create the SafeModeViewController and make it the root view controller for
51 // the window. The window has ownership of it and will dispose of it when 43 // the window. The window has ownership of it and will dispose of it when
52 // another view controller is made root. 44 // another view controller is made root.
53 // 45 //
54 // General note: Safe mode should be safe; it should not depend on other 46 // General note: Safe mode should be safe; it should not depend on other
55 // objects being created. Be extremely conservative when adding code to this 47 // objects being created. Be extremely conservative when adding code to this
56 // method. 48 // method.
57 base::scoped_nsobject<SafeModeViewController> viewController( 49 SafeModeViewController* viewController =
58 [[SafeModeViewController alloc] initWithDelegate:self]); 50 [[SafeModeViewController alloc] initWithDelegate:self];
59 [self.window setRootViewController:viewController]; 51 [self.window setRootViewController:viewController];
60 52
61 // Reset the crash count; the user may change something based on the recovery 53 // Reset the crash count; the user may change something based on the recovery
62 // UI that will fix the crash, and having the next launch start in recovery 54 // UI that will fix the crash, and having the next launch start in recovery
63 // mode would be strange. 55 // mode would be strange.
64 crash_util::ResetFailedStartupAttemptCount(); 56 crash_util::ResetFailedStartupAttemptCount();
65 } 57 }
66 58
67 // Override of ChildCoordinators method, which is not supported in this class. 59 // Override of ChildCoordinators method, which is not supported in this class.
68 - (MutableCoordinatorArray*)childCoordinators { 60 - (MutableCoordinatorArray*)childCoordinators {
69 NOTREACHED() << "Do not add child coordinators to SafeModeCoordinator."; 61 NOTREACHED() << "Do not add child coordinators to SafeModeCoordinator.";
70 return nil; 62 return nil;
71 } 63 }
72 64
73 #pragma mark - SafeModeViewControllerDelegate implementation 65 #pragma mark - SafeModeViewControllerDelegate implementation
74 66
75 - (void)startBrowserFromSafeMode { 67 - (void)startBrowserFromSafeMode {
76 [self.delegate coordinatorDidExitSafeMode:self]; 68 [self.delegate coordinatorDidExitSafeMode:self];
77 } 69 }
78 70
79 @end 71 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/safe_mode/safe_mode_coordinator.h ('k') | ios/chrome/app/safe_mode/safe_mode_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698