Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: ios/chrome/browser/web/resubmit_data_controller.mm

Issue 2518583002: [ObjC ARC] Converts ios/chrome/browser/web:web to ARC. (Closed)
Patch Set: Removes scoped_block and scoped_nsobject Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/web/dom_altering_lock.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/web/resubmit_data_controller.h" 5 #import "ios/chrome/browser/web/resubmit_data_controller.h"
6 6
7 #import "base/logging.h" 7 #import "base/logging.h"
8 #include "base/mac/scoped_block.h"
9 #import "base/mac/scoped_nsobject.h"
10 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.h"
11 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
12 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
13 @interface ResubmitDataController () { 15 @interface ResubmitDataController () {
14 base::scoped_nsobject<UIAlertController> _alertController; 16 UIAlertController* _alertController;
15 } 17 }
16 @end 18 @end
17 19
18 @implementation ResubmitDataController 20 @implementation ResubmitDataController
19 21
20 - (instancetype)init { 22 - (instancetype)init {
21 NOTREACHED(); 23 NOTREACHED();
22 return nil; 24 return nil;
23 } 25 }
24 26
25 - (instancetype)initWithContinueBlock:(ProceduralBlock)continueBlock 27 - (instancetype)initWithContinueBlock:(ProceduralBlock)continueBlock
26 cancelBlock:(ProceduralBlock)cancelBlock { 28 cancelBlock:(ProceduralBlock)cancelBlock {
27 DCHECK(continueBlock); 29 DCHECK(continueBlock);
28 DCHECK(cancelBlock); 30 DCHECK(cancelBlock);
29 self = [super init]; 31 self = [super init];
30 if (self) { 32 if (self) {
31 NSString* message = [NSString 33 NSString* message = [NSString
32 stringWithFormat:@"%@\n\n%@", 34 stringWithFormat:@"%@\n\n%@",
33 l10n_util::GetNSString(IDS_HTTP_POST_WARNING_TITLE), 35 l10n_util::GetNSString(IDS_HTTP_POST_WARNING_TITLE),
34 l10n_util::GetNSString(IDS_HTTP_POST_WARNING)]; 36 l10n_util::GetNSString(IDS_HTTP_POST_WARNING)];
35 NSString* buttonTitle = 37 NSString* buttonTitle =
36 l10n_util::GetNSString(IDS_HTTP_POST_WARNING_RESEND); 38 l10n_util::GetNSString(IDS_HTTP_POST_WARNING_RESEND);
37 NSString* cancelTitle = l10n_util::GetNSString(IDS_CANCEL); 39 NSString* cancelTitle = l10n_util::GetNSString(IDS_CANCEL);
38 40
39 _alertController.reset([[UIAlertController 41 _alertController = [UIAlertController
40 alertControllerWithTitle:nil 42 alertControllerWithTitle:nil
41 message:message 43 message:message
42 preferredStyle:UIAlertControllerStyleActionSheet] retain]); 44 preferredStyle:UIAlertControllerStyleActionSheet];
43 45 continueBlock = [^() {
lpromero 2016/12/05 14:39:10 Remove this.
stkhapugin 2016/12/05 16:24:28 Done.
46 } copy];
44 // Make sure the blocks are located on the heap. 47 // Make sure the blocks are located on the heap.
45 base::mac::ScopedBlock<ProceduralBlock> guaranteeOnHeap; 48 continueBlock = [continueBlock copy];
46 guaranteeOnHeap.reset([continueBlock copy]); 49 cancelBlock = [cancelBlock copy];
47 guaranteeOnHeap.reset([cancelBlock copy]);
48 50
49 UIAlertAction* cancelAction = 51 UIAlertAction* cancelAction =
50 [UIAlertAction actionWithTitle:cancelTitle 52 [UIAlertAction actionWithTitle:cancelTitle
51 style:UIAlertActionStyleCancel 53 style:UIAlertActionStyleCancel
52 handler:^(UIAlertAction* _Nonnull action) { 54 handler:^(UIAlertAction* _Nonnull action) {
53 cancelBlock(); 55 cancelBlock();
54 }]; 56 }];
55 [_alertController addAction:cancelAction]; 57 [_alertController addAction:cancelAction];
56 UIAlertAction* continueAction = 58 UIAlertAction* continueAction =
57 [UIAlertAction actionWithTitle:buttonTitle 59 [UIAlertAction actionWithTitle:buttonTitle
58 style:UIAlertActionStyleDefault 60 style:UIAlertActionStyleDefault
59 handler:^(UIAlertAction* _Nonnull action) { 61 handler:^(UIAlertAction* _Nonnull action) {
60 continueBlock(); 62 continueBlock();
61 }]; 63 }];
62 [_alertController addAction:continueAction]; 64 [_alertController addAction:continueAction];
63 } 65 }
64 return self; 66 return self;
65 } 67 }
66 68
67 - (void)presentActionSheetFromRect:(CGRect)rect inView:(UIView*)view { 69 - (void)presentActionSheetFromRect:(CGRect)rect inView:(UIView*)view {
68 _alertController.get().modalPresentationStyle = UIModalPresentationPopover; 70 _alertController.modalPresentationStyle = UIModalPresentationPopover;
69 UIPopoverPresentationController* popPresenter = 71 UIPopoverPresentationController* popPresenter =
70 _alertController.get().popoverPresentationController; 72 _alertController.popoverPresentationController;
71 popPresenter.sourceView = view; 73 popPresenter.sourceView = view;
72 popPresenter.sourceRect = rect; 74 popPresenter.sourceRect = rect;
73 75
74 UIViewController* topController = view.window.rootViewController; 76 UIViewController* topController = view.window.rootViewController;
75 while (topController.presentedViewController) 77 while (topController.presentedViewController)
76 topController = topController.presentedViewController; 78 topController = topController.presentedViewController;
77 [topController presentViewController:_alertController 79 [topController presentViewController:_alertController
78 animated:YES 80 animated:YES
79 completion:nil]; 81 completion:nil];
80 } 82 }
81 83
82 - (void)dismissActionSheet { 84 - (void)dismissActionSheet {
83 [_alertController.get().presentingViewController 85 [_alertController.presentingViewController dismissViewControllerAnimated:YES
84 dismissViewControllerAnimated:YES 86 completion:nil];
85 completion:nil];
86 } 87 }
87 88
88 @end 89 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/dom_altering_lock.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698