Commit b806e284 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

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

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

Review-Url: https://codereview.chromium.org/2568843002
Cr-Commit-Position: refs/heads/master@{#438861}
parent a3f67a21
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
source_set("elements") { source_set("elements") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"selector_coordinator.h", "selector_coordinator.h",
"selector_coordinator.mm", "selector_coordinator.mm",
......
...@@ -4,19 +4,21 @@ ...@@ -4,19 +4,21 @@
#import "ios/chrome/browser/ui/elements/selector_coordinator.h" #import "ios/chrome/browser/ui/elements/selector_coordinator.h"
#import "base/mac/objc_property_releaser.h"
#import "ios/chrome/browser/ui/elements/selector_picker_view_controller.h" #import "ios/chrome/browser/ui/elements/selector_picker_view_controller.h"
#import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.h" #import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.h"
#import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SelectorCoordinator ()<SelectorViewControllerDelegate, @interface SelectorCoordinator ()<SelectorViewControllerDelegate,
UIViewControllerTransitioningDelegate> { UIViewControllerTransitioningDelegate> {
base::mac::ObjCPropertyReleaser _propertyReleaser_SelectorCoordinator;
__unsafe_unretained id<SelectorCoordinatorDelegate> _delegate; __unsafe_unretained id<SelectorCoordinatorDelegate> _delegate;
} }
// Redeclaration of infoBarPickerController as readwrite. // Redeclaration of infoBarPickerController as readwrite.
@property(nonatomic, nullable, retain) @property(nonatomic, nullable, strong)
SelectorPickerViewController* selectorPickerViewController; SelectorPickerViewController* selectorPickerViewController;
@end @end
...@@ -28,20 +30,10 @@ ...@@ -28,20 +30,10 @@
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
@synthesize selectorPickerViewController = _selectorPickerViewController; @synthesize selectorPickerViewController = _selectorPickerViewController;
- (nullable instancetype)initWithBaseViewController:
(nullable UIViewController*)viewController {
self = [super initWithBaseViewController:viewController];
if (self) {
_propertyReleaser_SelectorCoordinator.Init(self,
[SelectorCoordinator class]);
}
return self;
}
- (void)start { - (void)start {
self.selectorPickerViewController = [[[SelectorPickerViewController alloc] self.selectorPickerViewController =
initWithOptions:self.options [[SelectorPickerViewController alloc] initWithOptions:self.options
default:self.defaultOption] autorelease]; default:self.defaultOption];
self.selectorPickerViewController.delegate = self; self.selectorPickerViewController.delegate = self;
self.selectorPickerViewController.modalTransitionStyle = self.selectorPickerViewController.modalTransitionStyle =
...@@ -75,9 +67,9 @@ ...@@ -75,9 +67,9 @@
presentationControllerForPresentedViewController:(UIViewController*)presented presentationControllerForPresentedViewController:(UIViewController*)presented
presentingViewController:(UIViewController*)presenting presentingViewController:(UIViewController*)presenting
sourceViewController:(UIViewController*)source { sourceViewController:(UIViewController*)source {
return [[[SelectorPickerPresentationController alloc] return [[SelectorPickerPresentationController alloc]
initWithPresentedViewController:self.selectorPickerViewController initWithPresentedViewController:self.selectorPickerViewController
presentingViewController:self.baseViewController] autorelease]; presentingViewController:self.baseViewController];
} }
@end @end
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
#import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.h" #import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.h"
#import "base/mac/objc_property_releaser.h" #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SelectorPickerPresentationController () { @interface SelectorPickerPresentationController ()
base::mac::ObjCPropertyReleaser @property(nonatomic, strong) UIView* dimmingView;
_propertyReleaser_SelectorPickerPresentationController;
}
@property(nonatomic, retain) UIView* dimmingView;
@end @end
@implementation SelectorPickerPresentationController @implementation SelectorPickerPresentationController
...@@ -22,8 +21,6 @@ ...@@ -22,8 +21,6 @@
self = [super initWithPresentedViewController:presented self = [super initWithPresentedViewController:presented
presentingViewController:presenting]; presentingViewController:presenting];
if (self) { if (self) {
_propertyReleaser_SelectorPickerPresentationController.Init(
self, [SelectorPickerPresentationController class]);
_dimmingView = [[UIView alloc] initWithFrame:CGRectZero]; _dimmingView = [[UIView alloc] initWithFrame:CGRectZero];
_dimmingView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; _dimmingView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
} }
......
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
#import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h"
#include "base/logging.h" #include "base/logging.h"
#import "base/mac/objc_property_releaser.h" #import "base/mac/foundation_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Font size of text in the picker view. // Font size of text in the picker view.
...@@ -15,8 +19,6 @@ CGFloat kUIPickerFontSize = 26; ...@@ -15,8 +19,6 @@ CGFloat kUIPickerFontSize = 26;
@interface SelectorPickerViewController ()<UIPickerViewDelegate, @interface SelectorPickerViewController ()<UIPickerViewDelegate,
UIPickerViewDataSource> { UIPickerViewDataSource> {
base::mac::ObjCPropertyReleaser
_propertyReleaser_SelectorPickerViewController;
__unsafe_unretained id<SelectorViewControllerDelegate> _delegate; __unsafe_unretained id<SelectorViewControllerDelegate> _delegate;
} }
// Options to display. // Options to display.
...@@ -24,9 +26,9 @@ CGFloat kUIPickerFontSize = 26; ...@@ -24,9 +26,9 @@ CGFloat kUIPickerFontSize = 26;
// The default option. // The default option.
@property(nonatomic, copy) NSString* defaultOption; @property(nonatomic, copy) NSString* defaultOption;
// The displayed UINavigationBar. Exposed for testing. // The displayed UINavigationBar. Exposed for testing.
@property(nonatomic, retain) UINavigationBar* navigationBar; @property(nonatomic, strong) UINavigationBar* navigationBar;
// The displayed UIPickerView. Exposed for testing. // The displayed UIPickerView. Exposed for testing.
@property(nonatomic, retain) UIPickerView* pickerView; @property(nonatomic, strong) UIPickerView* pickerView;
// Action for the "Done" button. // Action for the "Done" button.
- (void)doneButtonPressed; - (void)doneButtonPressed;
// Action for the "Cancel" button. // Action for the "Cancel" button.
...@@ -45,10 +47,8 @@ CGFloat kUIPickerFontSize = 26; ...@@ -45,10 +47,8 @@ CGFloat kUIPickerFontSize = 26;
default:(NSString*)defaultOption { default:(NSString*)defaultOption {
self = [super initWithNibName:nil bundle:nil]; self = [super initWithNibName:nil bundle:nil];
if (self) { if (self) {
_propertyReleaser_SelectorPickerViewController.Init(
self, [SelectorPickerViewController class]);
_options = [options copy];
_defaultOption = [defaultOption copy]; _defaultOption = [defaultOption copy];
_options = [options copy];
} }
return self; return self;
} }
...@@ -64,15 +64,12 @@ CGFloat kUIPickerFontSize = 26; ...@@ -64,15 +64,12 @@ CGFloat kUIPickerFontSize = 26;
} }
- (void)loadView { - (void)loadView {
self.pickerView = self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
[[[UIPickerView alloc] initWithFrame:CGRectZero] autorelease]; self.navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
self.navigationBar =
[[[UINavigationBar alloc] initWithFrame:CGRectZero] autorelease];
self.pickerView.translatesAutoresizingMaskIntoConstraints = NO; self.pickerView.translatesAutoresizingMaskIntoConstraints = NO;
self.navigationBar.translatesAutoresizingMaskIntoConstraints = NO; self.navigationBar.translatesAutoresizingMaskIntoConstraints = NO;
UIStackView* stackView = [[[UIStackView alloc] UIStackView* stackView = [[UIStackView alloc]
initWithArrangedSubviews:@[ self.navigationBar, self.pickerView ]] initWithArrangedSubviews:@[ self.navigationBar, self.pickerView ]];
autorelease];
stackView.axis = UILayoutConstraintAxisVertical; stackView.axis = UILayoutConstraintAxisVertical;
self.view = stackView; self.view = stackView;
} }
...@@ -91,15 +88,15 @@ CGFloat kUIPickerFontSize = 26; ...@@ -91,15 +88,15 @@ CGFloat kUIPickerFontSize = 26;
} }
UINavigationItem* navigationItem = UINavigationItem* navigationItem =
[[[UINavigationItem alloc] initWithTitle:@""] autorelease]; [[UINavigationItem alloc] initWithTitle:@""];
UIBarButtonItem* doneButton = [[[UIBarButtonItem alloc] UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self target:self
action:@selector(doneButtonPressed)] autorelease]; action:@selector(doneButtonPressed)];
UIBarButtonItem* cancelButton = [[[UIBarButtonItem alloc] UIBarButtonItem* cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self target:self
action:@selector(cancelButtonPressed)] autorelease]; action:@selector(cancelButtonPressed)];
[navigationItem setRightBarButtonItem:doneButton]; [navigationItem setRightBarButtonItem:doneButton];
[navigationItem setLeftBarButtonItem:cancelButton]; [navigationItem setLeftBarButtonItem:cancelButton];
[navigationItem setHidesBackButton:YES]; [navigationItem setHidesBackButton:YES];
...@@ -133,8 +130,8 @@ CGFloat kUIPickerFontSize = 26; ...@@ -133,8 +130,8 @@ CGFloat kUIPickerFontSize = 26;
reusingView:(UIView*)view { reusingView:(UIView*)view {
DCHECK_EQ(0, component); DCHECK_EQ(0, component);
UILabel* label = [view isKindOfClass:[UILabel class]] UILabel* label = [view isKindOfClass:[UILabel class]]
? (UILabel*)view ? base::mac::ObjCCastStrict<UILabel>(view)
: [[[UILabel alloc] init] autorelease]; : [[UILabel alloc] init];
NSString* text = self.options[row]; NSString* text = self.options[row];
label.text = text; label.text = text;
label.textAlignment = NSTextAlignmentCenter; label.textAlignment = NSTextAlignmentCenter;
......
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