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

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

Powered by Google App Engine
This is Rietveld 408576698