| 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/alert_coordinator/action_sheet_coordinator.h" | 5 #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/logging.h" |
| 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 8 | 12 |
| 9 @interface ActionSheetCoordinator () { | 13 @interface ActionSheetCoordinator () { |
| 10 // Rectangle for the popover alert. | 14 // Rectangle for the popover alert. |
| 11 CGRect _rect; | 15 CGRect _rect; |
| 12 // View for the popovert alert. | 16 // View for the popovert alert. |
| 13 base::scoped_nsobject<UIView> _view; | 17 UIView* _view; |
| 14 } | 18 } |
| 15 | 19 |
| 16 @end | 20 @end |
| 17 | 21 |
| 18 @implementation ActionSheetCoordinator | 22 @implementation ActionSheetCoordinator |
| 19 | 23 |
| 20 - (instancetype)initWithBaseViewController:(UIViewController*)viewController | 24 - (instancetype)initWithBaseViewController:(UIViewController*)viewController |
| 21 title:(NSString*)title | 25 title:(NSString*)title |
| 22 message:(NSString*)message { | 26 message:(NSString*)message { |
| 23 NOTREACHED(); | 27 NOTREACHED(); |
| 24 return nil; | 28 return nil; |
| 25 } | 29 } |
| 26 | 30 |
| 27 - (instancetype)initWithBaseViewController:(UIViewController*)viewController | 31 - (instancetype)initWithBaseViewController:(UIViewController*)viewController |
| 28 title:(NSString*)title | 32 title:(NSString*)title |
| 29 message:(NSString*)message | 33 message:(NSString*)message |
| 30 rect:(CGRect)rect | 34 rect:(CGRect)rect |
| 31 view:(UIView*)view { | 35 view:(UIView*)view { |
| 32 self = [super initWithBaseViewController:viewController | 36 self = [super initWithBaseViewController:viewController |
| 33 title:title | 37 title:title |
| 34 message:message]; | 38 message:message]; |
| 35 if (self) { | 39 if (self) { |
| 36 _rect = rect; | 40 _rect = rect; |
| 37 _view.reset([view retain]); | 41 _view = view; |
| 38 } | 42 } |
| 39 return self; | 43 return self; |
| 40 } | 44 } |
| 41 | 45 |
| 42 - (UIAlertController*)alertControllerWithTitle:(NSString*)title | 46 - (UIAlertController*)alertControllerWithTitle:(NSString*)title |
| 43 message:(NSString*)message { | 47 message:(NSString*)message { |
| 44 UIAlertController* alert = [UIAlertController | 48 UIAlertController* alert = [UIAlertController |
| 45 alertControllerWithTitle:title | 49 alertControllerWithTitle:title |
| 46 message:message | 50 message:message |
| 47 preferredStyle:UIAlertControllerStyleActionSheet]; | 51 preferredStyle:UIAlertControllerStyleActionSheet]; |
| 48 | 52 |
| 49 alert.popoverPresentationController.sourceView = _view; | 53 alert.popoverPresentationController.sourceView = _view; |
| 50 alert.popoverPresentationController.sourceRect = _rect; | 54 alert.popoverPresentationController.sourceRect = _rect; |
| 51 | 55 |
| 52 return alert; | 56 return alert; |
| 53 } | 57 } |
| 54 | 58 |
| 55 @end | 59 @end |
| OLD | NEW |