OLD | NEW |
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/browser/ui/main/main_coordinator.h" | 5 #import "ios/chrome/browser/ui/main/main_coordinator.h" |
6 | 6 |
7 #include "base/ios/weak_nsobject.h" | |
8 #include "base/mac/scoped_nsobject.h" | |
9 #import "ios/chrome/browser/ui/main/main_view_controller.h" | 7 #import "ios/chrome/browser/ui/main/main_view_controller.h" |
10 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
11 @interface MainCoordinator () { | 13 @interface MainCoordinator () { |
12 // Instance variables backing properties of the same name. | 14 // Instance variables backing properties of the same name. |
13 // |_mainViewController| will be owned by |self.window|. | 15 // |_mainViewController| will be owned by |self.window|. |
14 base::WeakNSObject<MainViewController> _mainViewController; | 16 __weak MainViewController* _mainViewController; |
15 } | 17 } |
16 | 18 |
17 @end | 19 @end |
18 | 20 |
19 @implementation MainCoordinator | 21 @implementation MainCoordinator |
20 | 22 |
21 #pragma mark - property implementation. | 23 #pragma mark - property implementation. |
22 | 24 |
23 - (MainViewController*)mainViewController { | 25 - (MainViewController*)mainViewController { |
24 return _mainViewController; | 26 return _mainViewController; |
25 } | 27 } |
26 | 28 |
27 #pragma mark - ChromeCoordinator implementation. | 29 #pragma mark - ChromeCoordinator implementation. |
28 | 30 |
29 - (void)start { | 31 - (void)start { |
30 base::scoped_nsobject<MainViewController> mainViewController( | 32 MainViewController* mainViewController = [[MainViewController alloc] init]; |
31 [[MainViewController alloc] init]); | 33 _mainViewController = mainViewController; |
32 _mainViewController.reset(mainViewController); | |
33 self.window.rootViewController = self.mainViewController; | 34 self.window.rootViewController = self.mainViewController; |
34 | 35 |
35 // Size the main view controller to fit the whole screen. | 36 // Size the main view controller to fit the whole screen. |
36 [self.mainViewController.view setFrame:self.window.bounds]; | 37 [self.mainViewController.view setFrame:self.window.bounds]; |
37 } | 38 } |
38 | 39 |
39 @end | 40 @end |
OLD | NEW |