Commit 18c51c84 authored by stkhapugin's avatar stkhapugin Committed by Commit Bot

[ObjC ARC] Converts ios/chrome/browser/ui/main:main to ARC.

Automatically generated ARCMigrate commit
Notable issues:None
BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2886043003
Cr-Commit-Position: refs/heads/master@{#481918}
parent 37fd3477
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
source_set("main") { source_set("main") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"browser_view_information.h", "browser_view_information.h",
"browser_view_wrangler.h", "browser_view_wrangler.h",
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#import "ios/chrome/browser/ui/main/browser_view_wrangler.h" #import "ios/chrome/browser/ui/main/browser_view_wrangler.h"
#include "base/mac/objc_property_releaser.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
...@@ -24,17 +22,19 @@ ...@@ -24,17 +22,19 @@
#import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface BrowserViewWrangler ()<TabModelObserver> { @interface BrowserViewWrangler ()<TabModelObserver> {
ios::ChromeBrowserState* _browserState; ios::ChromeBrowserState* _browserState;
__unsafe_unretained id<TabModelObserver> _tabModelObserver; __unsafe_unretained id<TabModelObserver> _tabModelObserver;
BOOL _isShutdown; BOOL _isShutdown;
base::mac::ObjCPropertyReleaser _propertyReleaser_BrowserViewWrangler;
} }
// Responsible for maintaining all state related to sharing to other devices. // Responsible for maintaining all state related to sharing to other devices.
// Redeclared readwrite from the readonly declaration in the Testing interface. // Redeclared readwrite from the readonly declaration in the Testing interface.
@property(nonatomic, retain, readwrite) @property(nonatomic, strong, readwrite)
DeviceSharingManager* deviceSharingManager; DeviceSharingManager* deviceSharingManager;
// Creates a new autoreleased tab model for |browserState|; if |empty| is NO, // Creates a new autoreleased tab model for |browserState|; if |empty| is NO,
...@@ -69,8 +69,6 @@ ...@@ -69,8 +69,6 @@
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
tabModelObserver:(id<TabModelObserver>)tabModelObserver { tabModelObserver:(id<TabModelObserver>)tabModelObserver {
if ((self = [super init])) { if ((self = [super init])) {
_propertyReleaser_BrowserViewWrangler.Init(self,
[BrowserViewWrangler class]);
_browserState = browserState; _browserState = browserState;
_tabModelObserver = tabModelObserver; _tabModelObserver = tabModelObserver;
} }
...@@ -84,7 +82,6 @@ ...@@ -84,7 +82,6 @@
- (void)dealloc { - (void)dealloc {
DCHECK(_isShutdown) << "-shutdown must be called before -dealloc"; DCHECK(_isShutdown) << "-shutdown must be called before -dealloc";
[super dealloc];
} }
#pragma mark - BrowserViewInformation property implementations #pragma mark - BrowserViewInformation property implementations
...@@ -108,10 +105,9 @@ ...@@ -108,10 +105,9 @@
if (_mainBVC) { if (_mainBVC) {
[_mainBVC browserStateDestroyed]; [_mainBVC browserStateDestroyed];
[_mainBVC shutdown]; [_mainBVC shutdown];
[_mainBVC autorelease];
} }
_mainBVC = [mainBVC retain]; _mainBVC = mainBVC;
} }
- (TabModel*)mainTabModel { - (TabModel*)mainTabModel {
...@@ -135,10 +131,9 @@ ...@@ -135,10 +131,9 @@
[_mainTabModel removeObserver:_tabModelObserver]; [_mainTabModel removeObserver:_tabModelObserver];
} }
[_mainTabModel removeObserver:self]; [_mainTabModel removeObserver:self];
[_mainTabModel autorelease];
} }
_mainTabModel = [mainTabModel retain]; _mainTabModel = mainTabModel;
} }
- (BrowserViewController*)otrBVC { - (BrowserViewController*)otrBVC {
...@@ -163,10 +158,9 @@ ...@@ -163,10 +158,9 @@
if (_otrBVC) { if (_otrBVC) {
[_otrBVC browserStateDestroyed]; [_otrBVC browserStateDestroyed];
[_otrBVC shutdown]; [_otrBVC shutdown];
[_otrBVC autorelease];
} }
_otrBVC = [otrBVC retain]; _otrBVC = otrBVC;
} }
- (TabModel*)otrTabModel { - (TabModel*)otrTabModel {
...@@ -186,10 +180,9 @@ ...@@ -186,10 +180,9 @@
[_otrTabModel removeObserver:_tabModelObserver]; [_otrTabModel removeObserver:_tabModelObserver];
} }
[_otrTabModel removeObserver:self]; [_otrTabModel removeObserver:self];
[_otrTabModel autorelease];
} }
_otrTabModel = [otrTabModel retain]; _otrTabModel = otrTabModel;
} }
- (void)setCurrentBVC:(BrowserViewController*)bvc - (void)setCurrentBVC:(BrowserViewController*)bvc
...@@ -259,8 +252,7 @@ ...@@ -259,8 +252,7 @@
- (void)updateDeviceSharingManager { - (void)updateDeviceSharingManager {
if (!self.deviceSharingManager) { if (!self.deviceSharingManager) {
self.deviceSharingManager = self.deviceSharingManager = [[DeviceSharingManager alloc] init];
[[[DeviceSharingManager alloc] init] autorelease];
} }
[self.deviceSharingManager updateBrowserState:_browserState]; [self.deviceSharingManager updateBrowserState:_browserState];
...@@ -375,9 +367,9 @@ ...@@ -375,9 +367,9 @@
// Create tab model from saved session (nil is ok). // Create tab model from saved session (nil is ok).
TabModel* tabModel = TabModel* tabModel =
[[[TabModel alloc] initWithSessionWindow:sessionWindow [[TabModel alloc] initWithSessionWindow:sessionWindow
sessionService:[SessionServiceIOS sharedService] sessionService:[SessionServiceIOS sharedService]
browserState:browserState] autorelease]; browserState:browserState];
// Add observers. // Add observers.
if (_tabModelObserver) { if (_tabModelObserver) {
[tabModel addObserver:_tabModelObserver]; [tabModel addObserver:_tabModelObserver];
...@@ -391,12 +383,12 @@ ...@@ -391,12 +383,12 @@
- (BrowserViewController*)bvcForBrowserState: - (BrowserViewController*)bvcForBrowserState:
(ios::ChromeBrowserState*)browserState (ios::ChromeBrowserState*)browserState
tabModel:(TabModel*)tabModel { tabModel:(TabModel*)tabModel {
base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( BrowserViewControllerDependencyFactory* factory =
[[BrowserViewControllerDependencyFactory alloc] [[BrowserViewControllerDependencyFactory alloc]
initWithBrowserState:browserState]); initWithBrowserState:browserState];
return [[[BrowserViewController alloc] initWithTabModel:tabModel return [[BrowserViewController alloc] initWithTabModel:tabModel
browserState:browserState browserState:browserState
dependencyFactory:factory] autorelease]; dependencyFactory:factory];
} }
@end @end
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
// The view controller this coordinator creates and manages. // The view controller this coordinator creates and manages.
// (This is only public while the view controller architecture is being // (This is only public while the view controller architecture is being
// refactored). // refactored).
@property(nonatomic, readonly, nullable) MainViewController* mainViewController; @property(nonatomic, weak, readonly, nullable)
MainViewController* mainViewController;
@end @end
......
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
#import "ios/chrome/browser/ui/main/main_coordinator.h" #import "ios/chrome/browser/ui/main/main_coordinator.h"
#include "base/ios/weak_nsobject.h"
#include "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/ui/main/main_view_controller.h" #import "ios/chrome/browser/ui/main/main_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface MainCoordinator () { @interface MainCoordinator () {
// Instance variables backing properties of the same name. // Instance variables backing properties of the same name.
// |_mainViewController| will be owned by |self.window|. // |_mainViewController| will be owned by |self.window|.
base::WeakNSObject<MainViewController> _mainViewController; __weak MainViewController* _mainViewController;
} }
@end @end
...@@ -27,9 +29,8 @@ ...@@ -27,9 +29,8 @@
#pragma mark - ChromeCoordinator implementation. #pragma mark - ChromeCoordinator implementation.
- (void)start { - (void)start {
base::scoped_nsobject<MainViewController> mainViewController( MainViewController* mainViewController = [[MainViewController alloc] init];
[[MainViewController alloc] init]); _mainViewController = mainViewController;
_mainViewController.reset(mainViewController);
self.window.rootViewController = self.mainViewController; self.window.rootViewController = self.mainViewController;
// Size the main view controller to fit the whole screen. // Size the main view controller to fit the whole screen.
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@interface MainViewController : UIViewController @interface MainViewController : UIViewController
// The child view controller, if any, that is active. Assigning to // The child view controller, if any, that is active. Assigning to
// |activeViewController| will remove any previous active view controller. // |activeViewController| will remove any previous active view controller.
@property(nonatomic, retain) UIViewController* activeViewController; @property(nonatomic, strong) UIViewController* activeViewController;
@end @end
#endif // IOS_CHROME_BROWSER_UI_MAIN_MAIN_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_MAIN_MAIN_VIEW_CONTROLLER_H_
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#import "base/logging.h" #import "base/logging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation MainViewController @implementation MainViewController
- (UIViewController*)activeViewController { - (UIViewController*)activeViewController {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment