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

Side by Side Diff: ios/chrome/browser/passwords/password_generation_prompt_view_controller.mm

Issue 2932333002: [ObjC ARC] Converts ios/chrome/browser/passwords:passwords_internal to ARC. (Closed)
Patch Set: Created 3 years, 6 months 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
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/passwords/password_generation_prompt_view_controller .h" 5 #import "ios/chrome/browser/passwords/password_generation_prompt_view_controller .h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/ios/weak_nsobject.h"
10 #include "base/mac/scoped_nsobject.h"
11 #import "ios/chrome/browser/passwords/password_generation_prompt_view.h" 9 #import "ios/chrome/browser/passwords/password_generation_prompt_view.h"
12 #import "ios/chrome/browser/ui/rtl_geometry.h" 10 #import "ios/chrome/browser/ui/rtl_geometry.h"
13 #import "ios/chrome/browser/ui/uikit_ui_util.h" 11 #import "ios/chrome/browser/ui/uikit_ui_util.h"
14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h" 12 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h"
15 13
14 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support."
16 #endif
17
16 namespace { 18 namespace {
17 // Material Design Component constraints. 19 // Material Design Component constraints.
18 const CGFloat kMDCPadding = 24; 20 const CGFloat kMDCPadding = 24;
19 const CGFloat kMDCMargin = 40; 21 const CGFloat kMDCMargin = 40;
20 22
21 // Maximum size of the dialog. 23 // Maximum size of the dialog.
22 const CGFloat kPrefWidth = 450; 24 const CGFloat kPrefWidth = 450;
23 const CGFloat kPrefHeight = 500; 25 const CGFloat kPrefHeight = 500;
24 26
25 } // namespace 27 } // namespace
26 28
27 @interface PasswordGenerationPromptViewController () { 29 @interface PasswordGenerationPromptViewController () {
28 base::scoped_nsobject<NSString> _password; 30 NSString* _password;
29 base::WeakNSObject<UIViewController> _viewController; 31 __weak UIViewController* _viewController;
30 base::WeakNSObject<PasswordGenerationPromptDialog> _contentView; 32 __weak PasswordGenerationPromptDialog* _contentView;
33 MDCDialogTransitionController* _dialogTransitionController;
31 } 34 }
32 35
33 // Returns the maximum size of the dialog. 36 // Returns the maximum size of the dialog.
34 - (CGFloat)maxDialogWidth; 37 - (CGFloat)maxDialogWidth;
35 38
36 @end 39 @end
37 40
38 @implementation PasswordGenerationPromptViewController 41 @implementation PasswordGenerationPromptViewController
39 42
40 - (CGFloat)maxDialogWidth { 43 - (CGFloat)maxDialogWidth {
41 CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width; 44 CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
42 return MIN(kPrefWidth, screenWidth - 2 * kMDCMargin); 45 return MIN(kPrefWidth, screenWidth - 2 * kMDCMargin);
43 } 46 }
44 47
45 - (instancetype)initWithPassword:(NSString*)password 48 - (instancetype)initWithPassword:(NSString*)password
46 contentView:(PasswordGenerationPromptDialog*)contentView 49 contentView:(PasswordGenerationPromptDialog*)contentView
47 viewController:(UIViewController*)viewController { 50 viewController:(UIViewController*)viewController {
48 self = [super initWithNibName:nil bundle:nil]; 51 self = [super initWithNibName:nil bundle:nil];
49 if (self) { 52 if (self) {
50 _password.reset([password copy]); 53 _password = [password copy];
51 _viewController.reset(viewController); 54 _viewController = viewController;
52 _contentView.reset(contentView); 55 _contentView = contentView;
56 _dialogTransitionController = [[MDCDialogTransitionController alloc] init];
53 self.modalPresentationStyle = UIModalPresentationCustom; 57 self.modalPresentationStyle = UIModalPresentationCustom;
54 self.transitioningDelegate = 58 self.transitioningDelegate = _dialogTransitionController;
55 [[[MDCDialogTransitionController alloc] init] autorelease];
56 } 59 }
57 return self; 60 return self;
58 } 61 }
59 62
60 - (void)viewDidLoad { 63 - (void)viewDidLoad {
61 [super viewDidLoad]; 64 [super viewDidLoad];
62 65
63 self.view.backgroundColor = [UIColor whiteColor]; 66 self.view.backgroundColor = [UIColor whiteColor];
64 67
65 [_contentView configureGlobalViewWithPassword:_password]; 68 [_contentView configureGlobalViewWithPassword:_password];
(...skipping 13 matching lines...) Expand all
79 constraints, viewsDictionary, metrics, LayoutOptionForRTLSupport()); 82 constraints, viewsDictionary, metrics, LayoutOptionForRTLSupport());
80 } 83 }
81 84
82 - (void)viewDidLayoutSubviews { 85 - (void)viewDidLayoutSubviews {
83 CGSize currentSize = CGSizeMake( 86 CGSize currentSize = CGSizeMake(
84 [self maxDialogWidth], [_contentView frame].size.height + kMDCPadding); 87 [self maxDialogWidth], [_contentView frame].size.height + kMDCPadding);
85 self.preferredContentSize = currentSize; 88 self.preferredContentSize = currentSize;
86 } 89 }
87 90
88 @end 91 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698