Commit 51f2d432 authored by marq's avatar marq Committed by Commit Bot

[ObjC ARC] Converts ios/chrome/browser/passwords:passwords_internal to ARC.

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

Review-Url: https://codereview.chromium.org/2932333002
Cr-Commit-Position: refs/heads/master@{#478659}
parent e5ee4f9d
...@@ -136,6 +136,7 @@ js_compile_unchecked("injected_js") { ...@@ -136,6 +136,7 @@ js_compile_unchecked("injected_js") {
} }
source_set("passwords_internal") { source_set("passwords_internal") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"password_generation_prompt_view.h", "password_generation_prompt_view.h",
"password_generation_prompt_view.mm", "password_generation_prompt_view.mm",
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <memory> #include <memory>
#include "base/ios/weak_nsobject.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/passwords/password_generation_prompt_delegate.h" #import "ios/chrome/browser/passwords/password_generation_prompt_delegate.h"
...@@ -22,6 +20,10 @@ ...@@ -22,6 +20,10 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Material Design Component constraints. // Material Design Component constraints.
...@@ -84,10 +86,10 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -84,10 +86,10 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
@end @end
@implementation PasswordGenerationPromptView { @implementation PasswordGenerationPromptView {
base::scoped_nsobject<NSString> _password; NSString* _password;
base::WeakNSProtocol<id<PasswordGenerationPromptDelegate>> _delegate; __weak id<PasswordGenerationPromptDelegate> _delegate;
base::scoped_nsobject<NSURL> _URL; NSURL* _URL;
base::scoped_nsobject<UILabel> _title; UILabel* _title;
} }
- (instancetype)initWithPassword:(NSString*)password - (instancetype)initWithPassword:(NSString*)password
...@@ -95,22 +97,21 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -95,22 +97,21 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
(id<PasswordGenerationPromptDelegate>)delegate { (id<PasswordGenerationPromptDelegate>)delegate {
self = [super initWithFrame:CGRectZero]; self = [super initWithFrame:CGRectZero];
if (self) { if (self) {
_URL.reset( _URL = [NSURL URLWithString:@"chromeinternal://showpasswords"];
[[NSURL URLWithString:@"chromeinternal://showpasswords"] retain]); _delegate = delegate;
_delegate.reset(delegate); _password = [password copy];
_password.reset([password copy]);
} }
return self; return self;
} }
- (void)configure { - (void)configure {
UIView* headerView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; UIView* headerView = [[UIView alloc] initWithFrame:CGRectZero];
UIImageView* icon = [self keyIconView]; UIImageView* icon = [self keyIconView];
UILabel* title = [self titleLabel]; UILabel* title = [self titleLabel];
UILabel* password = [self passwordLabel:_password]; UILabel* password = [self passwordLabel:_password];
UITextView* description = [self description]; UITextView* description = [self description];
_title.reset([title retain]); _title = title;
[headerView addSubview:icon]; [headerView addSubview:icon];
[headerView addSubview:title]; [headerView addSubview:title];
...@@ -190,27 +191,27 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -190,27 +191,27 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
[attrsDictionary setObject:UIColorFromRGB(kTitleLabelFontColor) [attrsDictionary setObject:UIColorFromRGB(kTitleLabelFontColor)
forKey:NSForegroundColorAttributeName]; forKey:NSForegroundColorAttributeName];
NSMutableAttributedString* string = [[[NSMutableAttributedString alloc] NSMutableAttributedString* string = [[NSMutableAttributedString alloc]
initWithString:l10n_util::GetNSString( initWithString:l10n_util::GetNSString(
IDS_IOS_GENERATED_PASSWORD_PROMPT_TITLE) IDS_IOS_GENERATED_PASSWORD_PROMPT_TITLE)
attributes:attrsDictionary] autorelease]; attributes:attrsDictionary];
base::scoped_nsobject<UILabel> titleLabel([[UILabel alloc] init]); UILabel* titleLabel = [[UILabel alloc] init];
[titleLabel setAttributedText:string]; [titleLabel setAttributedText:string];
[titleLabel setNumberOfLines:0]; [titleLabel setNumberOfLines:0];
[titleLabel sizeToFit]; [titleLabel sizeToFit];
return titleLabel.autorelease(); return titleLabel = nil;
} }
- (UILabel*)passwordLabel:(NSString*)password { - (UILabel*)passwordLabel:(NSString*)password {
base::scoped_nsobject<UILabel> passwordLabel([[UILabel alloc] init]); UILabel* passwordLabel = [[UILabel alloc] init];
[passwordLabel setText:password]; [passwordLabel setText:password];
[passwordLabel setTextColor:UIColorFromRGB(kPasswordLabelFontColor)]; [passwordLabel setTextColor:UIColorFromRGB(kPasswordLabelFontColor)];
[passwordLabel setFont:[[MDCTypography fontLoader] [passwordLabel setFont:[[MDCTypography fontLoader]
regularFontOfSize:kPasswordLabelFontSize]]; regularFontOfSize:kPasswordLabelFontSize]];
[passwordLabel setNumberOfLines:1]; [passwordLabel setNumberOfLines:1];
[passwordLabel sizeToFit]; [passwordLabel sizeToFit];
return passwordLabel.autorelease(); return passwordLabel = nil;
} }
- (UITextView*)description { - (UITextView*)description {
...@@ -219,26 +220,25 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -219,26 +220,25 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
l10n_util::GetNSString(IDS_IOS_GENERATED_PASSWORD_PROMPT_DESCRIPTION), l10n_util::GetNSString(IDS_IOS_GENERATED_PASSWORD_PROMPT_DESCRIPTION),
&linkRange); &linkRange);
base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( NSMutableParagraphStyle* paragraphStyle =
[[NSMutableParagraphStyle alloc] init]); [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:kDescriptionLabelLineSpacing]; [paragraphStyle setLineSpacing:kDescriptionLabelLineSpacing];
NSDictionary* attributeDictionary = NSDictionary* attributeDictionary =
[NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys:
UIColorFromRGB(kDescriptionLabelFontColor), UIColorFromRGB(kDescriptionLabelFontColor),
NSForegroundColorAttributeName, paragraphStyle.get(), NSForegroundColorAttributeName, paragraphStyle,
NSParagraphStyleAttributeName, NSParagraphStyleAttributeName,
[[MDCTypography fontLoader] [[MDCTypography fontLoader]
regularFontOfSize:kDescriptionLabelFontSize], regularFontOfSize:kDescriptionLabelFontSize],
NSFontAttributeName, nil]; NSFontAttributeName, nil];
base::scoped_nsobject<NSMutableAttributedString> attributedString( NSMutableAttributedString* attributedString =
[[NSMutableAttributedString alloc] initWithString:description [[NSMutableAttributedString alloc] initWithString:description
attributes:attributeDictionary]); attributes:attributeDictionary];
UITextView* descriptionView = UITextView* descriptionView =
[[[UITextView alloc] initWithFrame:CGRectZero textContainer:nil] [[UITextView alloc] initWithFrame:CGRectZero textContainer:nil];
autorelease];
descriptionView.scrollEnabled = NO; descriptionView.scrollEnabled = NO;
descriptionView.selectable = YES; descriptionView.selectable = YES;
descriptionView.editable = NO; descriptionView.editable = NO;
...@@ -260,8 +260,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -260,8 +260,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
UIImage* keyIcon = ui::ResourceBundle::GetSharedInstance() UIImage* keyIcon = ui::ResourceBundle::GetSharedInstance()
.GetImageNamed(IDR_IOS_INFOBAR_AUTOLOGIN) .GetImageNamed(IDR_IOS_INFOBAR_AUTOLOGIN)
.ToUIImage(); .ToUIImage();
UIImageView* keyIconView = UIImageView* keyIconView = [[UIImageView alloc] initWithImage:keyIcon];
[[[UIImageView alloc] initWithImage:keyIcon] autorelease];
[keyIconView setFrame:{CGPointZero, keyIcon.size}]; [keyIconView setFrame:{CGPointZero, keyIcon.size}];
return keyIconView; return keyIconView;
} }
...@@ -272,7 +271,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -272,7 +271,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
shouldInteractWithURL:(NSURL*)URL shouldInteractWithURL:(NSURL*)URL
inRange:(NSRange)characterRange inRange:(NSRange)characterRange
interaction:(UITextItemInteraction)interaction { interaction:(UITextItemInteraction)interaction {
DCHECK([URL isEqual:_URL.get()]); DCHECK([URL isEqual:_URL]);
[_delegate showSavedPasswords:self]; [_delegate showSavedPasswords:self];
return NO; return NO;
} }
...@@ -282,8 +281,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -282,8 +281,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
#pragma mark - Classes emulating MDCDialog #pragma mark - Classes emulating MDCDialog
@interface PasswordGenerationPromptDialog () { @interface PasswordGenerationPromptDialog () {
base::WeakNSObject<UIViewController> _viewController; __weak UIViewController* _viewController;
base::WeakNSProtocol<id<PasswordGenerationPromptDelegate>> _weakDelegate; __weak id<PasswordGenerationPromptDelegate> _weakDelegate;
} }
// Dismiss the dialog. // Dismiss the dialog.
...@@ -301,8 +300,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -301,8 +300,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
viewController:(UIViewController*)viewController { viewController:(UIViewController*)viewController {
self = [super initWithFrame:CGRectZero]; self = [super initWithFrame:CGRectZero];
if (self) { if (self) {
_viewController.reset(viewController); _viewController = viewController;
_weakDelegate.reset(delegate); _weakDelegate = delegate;
} }
return self; return self;
} }
...@@ -318,10 +317,10 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -318,10 +317,10 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
// Creates the view containing the buttons. // Creates the view containing the buttons.
- (UIView*)createButtons { - (UIView*)createButtons {
UIView* view = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
NSString* cancelTitle = l10n_util::GetNSString(IDS_CANCEL); NSString* cancelTitle = l10n_util::GetNSString(IDS_CANCEL);
MDCFlatButton* cancelButton = [[[MDCFlatButton alloc] init] autorelease]; MDCFlatButton* cancelButton = [[MDCFlatButton alloc] init];
[cancelButton setTitle:cancelTitle forState:UIControlStateNormal]; [cancelButton setTitle:cancelTitle forState:UIControlStateNormal];
[cancelButton sizeToFit]; [cancelButton sizeToFit];
[cancelButton setCustomTitleColor:[UIColor blackColor]]; [cancelButton setCustomTitleColor:[UIColor blackColor]];
...@@ -331,7 +330,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -331,7 +330,7 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
NSString* acceptTitle = NSString* acceptTitle =
l10n_util::GetNSString(IDS_IOS_GENERATED_PASSWORD_ACCEPT); l10n_util::GetNSString(IDS_IOS_GENERATED_PASSWORD_ACCEPT);
MDCFlatButton* OKButton = [[[MDCFlatButton alloc] init] autorelease]; MDCFlatButton* OKButton = [[MDCFlatButton alloc] init];
[OKButton setTitle:acceptTitle forState:UIControlStateNormal]; [OKButton setTitle:acceptTitle forState:UIControlStateNormal];
[OKButton sizeToFit]; [OKButton sizeToFit];
[OKButton setCustomTitleColor:[UIColor blackColor]]; [OKButton setCustomTitleColor:[UIColor blackColor]];
...@@ -363,9 +362,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f; ...@@ -363,9 +362,8 @@ const CGFloat kDescriptionLabelTopPadding = 10.0f;
// Creates the view containing the password text and the buttons. // Creates the view containing the password text and the buttons.
- (void)configureGlobalViewWithPassword:(NSString*)password { - (void)configureGlobalViewWithPassword:(NSString*)password {
PasswordGenerationPromptView* passwordContentView = PasswordGenerationPromptView* passwordContentView =
[[[PasswordGenerationPromptView alloc] initWithPassword:password [[PasswordGenerationPromptView alloc] initWithPassword:password
delegate:_weakDelegate] delegate:_weakDelegate];
autorelease];
[passwordContentView configure]; [passwordContentView configure];
......
...@@ -6,13 +6,15 @@ ...@@ -6,13 +6,15 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include "base/ios/weak_nsobject.h"
#include "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/passwords/password_generation_prompt_view.h" #import "ios/chrome/browser/passwords/password_generation_prompt_view.h"
#import "ios/chrome/browser/ui/rtl_geometry.h" #import "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Dialogs/src/MaterialDialogs.h" #import "ios/third_party/material_components_ios/src/components/Dialogs/src/MaterialDialogs.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Material Design Component constraints. // Material Design Component constraints.
const CGFloat kMDCPadding = 24; const CGFloat kMDCPadding = 24;
...@@ -25,9 +27,10 @@ const CGFloat kPrefHeight = 500; ...@@ -25,9 +27,10 @@ const CGFloat kPrefHeight = 500;
} // namespace } // namespace
@interface PasswordGenerationPromptViewController () { @interface PasswordGenerationPromptViewController () {
base::scoped_nsobject<NSString> _password; NSString* _password;
base::WeakNSObject<UIViewController> _viewController; __weak UIViewController* _viewController;
base::WeakNSObject<PasswordGenerationPromptDialog> _contentView; __weak PasswordGenerationPromptDialog* _contentView;
MDCDialogTransitionController* _dialogTransitionController;
} }
// Returns the maximum size of the dialog. // Returns the maximum size of the dialog.
...@@ -47,12 +50,12 @@ const CGFloat kPrefHeight = 500; ...@@ -47,12 +50,12 @@ const CGFloat kPrefHeight = 500;
viewController:(UIViewController*)viewController { viewController:(UIViewController*)viewController {
self = [super initWithNibName:nil bundle:nil]; self = [super initWithNibName:nil bundle:nil];
if (self) { if (self) {
_password.reset([password copy]); _password = [password copy];
_viewController.reset(viewController); _viewController = viewController;
_contentView.reset(contentView); _contentView = contentView;
_dialogTransitionController = [[MDCDialogTransitionController alloc] init];
self.modalPresentationStyle = UIModalPresentationCustom; self.modalPresentationStyle = UIModalPresentationCustom;
self.transitioningDelegate = self.transitioningDelegate = _dialogTransitionController;
[[[MDCDialogTransitionController alloc] init] autorelease];
} }
return self; return self;
} }
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#import "ios/chrome/browser/passwords/password_generation_prompt_view.h" #import "ios/chrome/browser/passwords/password_generation_prompt_view.h"
#import "ios/chrome/browser/passwords/password_generation_prompt_view_controller.h" #import "ios/chrome/browser/passwords/password_generation_prompt_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation PasswordsUiDelegateImpl @implementation PasswordsUiDelegateImpl
#pragma mark - #pragma mark -
...@@ -31,15 +35,15 @@ ...@@ -31,15 +35,15 @@
} }
PasswordGenerationPromptDialog* contentView = PasswordGenerationPromptDialog* contentView =
[[[PasswordGenerationPromptDialog alloc] [[PasswordGenerationPromptDialog alloc]
initWithDelegate:delegate initWithDelegate:delegate
viewController:topViewController] autorelease]; viewController:topViewController];
UIViewController* viewController = UIViewController* viewController =
[[[PasswordGenerationPromptViewController alloc] [[PasswordGenerationPromptViewController alloc]
initWithPassword:password initWithPassword:password
contentView:contentView contentView:contentView
viewController:topViewController] autorelease]; viewController:topViewController];
[topViewController presentViewController:viewController [topViewController presentViewController:viewController
animated:YES animated:YES
......
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