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