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

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

Semi-auto generated ARCMigrate commit
Notable issues:None
BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2568143002
Cr-Commit-Position: refs/heads/master@{#438151}
parent 66bc013d
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
source_set("alert_coordinator") { source_set("alert_coordinator") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"action_sheet_coordinator.h", "action_sheet_coordinator.h",
"action_sheet_coordinator.mm", "action_sheet_coordinator.mm",
......
...@@ -4,13 +4,17 @@ ...@@ -4,13 +4,17 @@
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "base/mac/scoped_nsobject.h" #import "base/logging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface ActionSheetCoordinator () { @interface ActionSheetCoordinator () {
// Rectangle for the popover alert. // Rectangle for the popover alert.
CGRect _rect; CGRect _rect;
// View for the popovert alert. // View for the popovert alert.
base::scoped_nsobject<UIView> _view; UIView* _view;
} }
@end @end
...@@ -34,7 +38,7 @@ ...@@ -34,7 +38,7 @@
message:message]; message:message];
if (self) { if (self) {
_rect = rect; _rect = rect;
_view.reset([view retain]); _view = view;
} }
return self; return self;
} }
......
...@@ -4,23 +4,19 @@ ...@@ -4,23 +4,19 @@
#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
#import "base/ios/weak_nsobject.h" #include "base/logging.h"
#import "base/mac/scoped_block.h"
#import "base/mac/scoped_nsobject.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
@interface AlertCoordinator () { #if !defined(__has_feature) || !__has_feature(objc_arc)
// Variables backing properties of the same name. #error "This file requires ARC support."
base::scoped_nsobject<UIAlertController> _alertController; #endif
base::scoped_nsobject<NSString> _message;
base::mac::ScopedBlock<ProceduralBlock> _cancelAction;
base::mac::ScopedBlock<ProceduralBlock> _startAction;
base::mac::ScopedBlock<ProceduralBlock> _noInteractionAction;
base::mac::ScopedBlock<ProceduralBlock> _rawCancelAction;
@interface AlertCoordinator () {
// Variable backing a property from Subclassing category.
UIAlertController* _alertController;
// Title for the alert. // Title for the alert.
base::scoped_nsobject<NSString> _title; NSString* _title;
} }
// Redefined to readwrite. // Redefined to readwrite.
...@@ -42,6 +38,11 @@ ...@@ -42,6 +38,11 @@
@synthesize visible = _visible; @synthesize visible = _visible;
@synthesize cancelButtonAdded = _cancelButtonAdded; @synthesize cancelButtonAdded = _cancelButtonAdded;
@synthesize cancelAction = _cancelAction;
@synthesize startAction = _startAction;
@synthesize noInteractionAction = _noInteractionAction;
@synthesize rawCancelAction = _rawCancelAction;
@synthesize message = _message;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController { - (instancetype)initWithBaseViewController:(UIViewController*)viewController {
NOTREACHED(); NOTREACHED();
...@@ -53,8 +54,8 @@ ...@@ -53,8 +54,8 @@
message:(NSString*)message { message:(NSString*)message {
self = [super initWithBaseViewController:viewController]; self = [super initWithBaseViewController:viewController];
if (self) { if (self) {
_title.reset([title copy]); _title = [title copy];
_message.reset([message copy]); _message = [message copy];
} }
return self; return self;
} }
...@@ -72,7 +73,7 @@ ...@@ -72,7 +73,7 @@
if (style == UIAlertActionStyleCancel) if (style == UIAlertActionStyleCancel)
_cancelButtonAdded = YES; _cancelButtonAdded = YES;
base::WeakNSObject<AlertCoordinator> weakSelf(self); __weak AlertCoordinator* weakSelf = self;
UIAlertAction* alertAction = UIAlertAction* alertAction =
[UIAlertAction actionWithTitle:title [UIAlertAction actionWithTitle:title
...@@ -120,8 +121,8 @@ ...@@ -120,8 +121,8 @@
- (void)stop { - (void)stop {
if (_noInteractionAction) { if (_noInteractionAction) {
_noInteractionAction.get()(); _noInteractionAction();
_noInteractionAction.reset(); _noInteractionAction = nil;
} }
[[_alertController presentingViewController] [[_alertController presentingViewController]
dismissViewControllerAnimated:NO dismissViewControllerAnimated:NO
...@@ -137,7 +138,7 @@ ...@@ -137,7 +138,7 @@
[self alertControllerWithTitle:_title message:_message]; [self alertControllerWithTitle:_title message:_message];
if (alert) if (alert)
_alertController.reset([alert retain]); _alertController = alert;
} }
return _alertController; return _alertController;
} }
...@@ -146,50 +147,18 @@ ...@@ -146,50 +147,18 @@
return _message; return _message;
} }
- (void)setMessage:(NSString*)message {
_message.reset([message copy]);
}
- (ProceduralBlock)cancelAction {
return _cancelAction;
}
- (void)setCancelAction:(ProceduralBlock)cancelAction { - (void)setCancelAction:(ProceduralBlock)cancelAction {
base::WeakNSObject<AlertCoordinator> weakSelf(self); __weak AlertCoordinator* weakSelf = self;
self.rawCancelAction = cancelAction; self.rawCancelAction = cancelAction;
_cancelAction.reset([^{ _cancelAction = [^{
base::scoped_nsobject<AlertCoordinator> strongSelf([weakSelf retain]); AlertCoordinator* strongSelf = weakSelf;
[strongSelf setNoInteractionAction:nil]; [strongSelf setNoInteractionAction:nil];
if ([strongSelf rawCancelAction]) { if ([strongSelf rawCancelAction]) {
[strongSelf rawCancelAction](); [strongSelf rawCancelAction]();
} }
} copy]); } copy];
}
- (ProceduralBlock)startAction {
return _startAction;
}
- (void)setStartAction:(ProceduralBlock)startAction {
_startAction.reset([startAction copy]);
}
- (ProceduralBlock)noInteractionAction {
return _noInteractionAction;
}
- (void)setNoInteractionAction:(ProceduralBlock)noInteractionAction {
_noInteractionAction.reset([noInteractionAction copy]);
}
- (ProceduralBlock)rawCancelAction {
return _rawCancelAction;
}
- (void)setRawCancelAction:(ProceduralBlock)rawCancelAction {
_rawCancelAction.reset([rawCancelAction copy]);
} }
#pragma mark - Private Methods. #pragma mark - Private Methods.
...@@ -197,9 +166,9 @@ ...@@ -197,9 +166,9 @@
- (void)alertDismissed { - (void)alertDismissed {
self.visible = NO; self.visible = NO;
_cancelButtonAdded = NO; _cancelButtonAdded = NO;
_alertController.reset(); _alertController = nil;
_cancelAction.reset(); _cancelAction = nil;
_noInteractionAction.reset(); _noInteractionAction = nil;
} }
- (UIAlertController*)alertControllerWithTitle:(NSString*)title - (UIAlertController*)alertControllerWithTitle:(NSString*)title
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
@interface InputAlertCoordinator : AlertCoordinator @interface InputAlertCoordinator : AlertCoordinator
// Text fields displayed by the alert. // Text fields displayed by the alert.
@property(nonatomic, readonly) NSArray<UITextField*>* textFields; @property(strong, nonatomic, readonly) NSArray<UITextField*>* textFields;
// Add a text field to the alert. // Add a text field to the alert.
- (void)addTextFieldWithConfigurationHandler: - (void)addTextFieldWithConfigurationHandler:
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#import "ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation InputAlertCoordinator @implementation InputAlertCoordinator
- (NSArray<UITextField*>*)textFields { - (NSArray<UITextField*>*)textFields {
......
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