| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_edit_view.h" | 5 #import "ios/chrome/browser/passwords/password_generation_edit_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/scoped_nsobject.h" | |
| 10 #include "ios/chrome/browser/passwords/password_generation_utils.h" | 9 #include "ios/chrome/browser/passwords/password_generation_utils.h" |
| 11 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
| 12 namespace { | 15 namespace { |
| 13 // Constants for the edit view. | 16 // Constants for the edit view. |
| 14 const CGFloat kEditViewFontSize = 15; | 17 const CGFloat kEditViewFontSize = 15; |
| 15 } // namespace | 18 } // namespace |
| 16 | 19 |
| 17 @implementation PasswordGenerationEditView { | 20 @implementation PasswordGenerationEditView { |
| 18 base::scoped_nsobject<UITextField> _textField; | 21 UITextField* _textField; |
| 19 } | 22 } |
| 20 | 23 |
| 21 - (instancetype)initWithPassword:(NSString*)password { | 24 - (instancetype)initWithPassword:(NSString*)password { |
| 22 // Frame size will updated later. | 25 // Frame size will updated later. |
| 23 const CGRect defaultFrameSize = CGRectMake(0, 0, 100, 30); | 26 const CGRect defaultFrameSize = CGRectMake(0, 0, 100, 30); |
| 24 self = [super initWithFrame:defaultFrameSize]; | 27 self = [super initWithFrame:defaultFrameSize]; |
| 25 if (self) { | 28 if (self) { |
| 26 _textField.reset([[UITextField alloc] init]); | 29 _textField = [[UITextField alloc] init]; |
| 27 [_textField setText:password]; | 30 [_textField setText:password]; |
| 28 [_textField setFont:[UIFont systemFontOfSize:kEditViewFontSize]]; | 31 [_textField setFont:[UIFont systemFontOfSize:kEditViewFontSize]]; |
| 29 [_textField setBackgroundColor:[UIColor clearColor]]; | 32 [_textField setBackgroundColor:[UIColor clearColor]]; |
| 30 [_textField sizeToFit]; | 33 [_textField sizeToFit]; |
| 31 [_textField setUserInteractionEnabled:NO]; | 34 [_textField setUserInteractionEnabled:NO]; |
| 32 [_textField setFrame:passwords::GetGenerationAccessoryFrame( | 35 [_textField setFrame:passwords::GetGenerationAccessoryFrame( |
| 33 [self bounds], [_textField frame])]; | 36 [self bounds], [_textField frame])]; |
| 34 [_textField setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | | 37 [_textField setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | |
| 35 UIViewAutoresizingFlexibleBottomMargin | | 38 UIViewAutoresizingFlexibleBottomMargin | |
| 36 UIViewAutoresizingFlexibleWidth]; | 39 UIViewAutoresizingFlexibleWidth]; |
| 37 [self addSubview:_textField]; | 40 [self addSubview:_textField]; |
| 38 } | 41 } |
| 39 return self; | 42 return self; |
| 40 } | 43 } |
| 41 | 44 |
| 42 - (instancetype)initWithFrame:(CGRect)frame { | 45 - (instancetype)initWithFrame:(CGRect)frame { |
| 43 NOTREACHED(); | 46 NOTREACHED(); |
| 44 return nil; | 47 return nil; |
| 45 } | 48 } |
| 46 | 49 |
| 47 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 50 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 48 NOTREACHED(); | 51 NOTREACHED(); |
| 49 return nil; | 52 return nil; |
| 50 } | 53 } |
| 51 | 54 |
| 52 @end | 55 @end |
| OLD | NEW |