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

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

Issue 2933873002: [ObjC ARC] Converts ios/chrome/browser/passwords:passwords to ARC. (Closed)
Patch Set: fix names and nil assignments. 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 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_offer_view.h" 5 #import "ios/chrome/browser/passwords/password_generation_offer_view.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/mac/scoped_nsobject.h"
9 #include "ios/chrome/browser/passwords/password_generation_utils.h" 8 #include "ios/chrome/browser/passwords/password_generation_utils.h"
10 #import "ios/chrome/browser/ui/uikit_ui_util.h" 9 #import "ios/chrome/browser/ui/uikit_ui_util.h"
11 #include "ios/chrome/grit/ios_strings.h" 10 #include "ios/chrome/grit/ios_strings.h"
12 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
13 12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
14 namespace { 17 namespace {
15 // Constants for the offer view. 18 // Constants for the offer view.
16 const int kOfferLabelColor = 0x007AFF; 19 const int kOfferLabelColor = 0x007AFF;
17 const CGFloat kOfferLabelFontSize = 15.0; 20 const CGFloat kOfferLabelFontSize = 15.0;
18 } // namespace 21 } // namespace
19 22
20 @implementation PasswordGenerationOfferView 23 @implementation PasswordGenerationOfferView
21 24
22 - (instancetype)initWithDelegate:(id<PasswordGenerationOfferDelegate>)delegate { 25 - (instancetype)initWithDelegate:(id<PasswordGenerationOfferDelegate>)delegate {
23 // Frame will be updated later. 26 // Frame will be updated later.
24 const CGRect defaultFrame = CGRectMake(0, 0, 100, 100); 27 const CGRect defaultFrame = CGRectMake(0, 0, 100, 100);
25 self = [super initWithFrame:defaultFrame]; 28 self = [super initWithFrame:defaultFrame];
26 if (self) { 29 if (self) {
27 base::scoped_nsobject<UILabel> label([[UILabel alloc] init]); 30 UILabel* label = [[UILabel alloc] init];
28 [label setText:l10n_util::GetNSString(IDS_IOS_GENERATE_PASSWORD_LABEL)]; 31 [label setText:l10n_util::GetNSString(IDS_IOS_GENERATE_PASSWORD_LABEL)];
29 UIFont* font = [UIFont systemFontOfSize:kOfferLabelFontSize]; 32 UIFont* font = [UIFont systemFontOfSize:kOfferLabelFontSize];
30 [label setFont:font]; 33 [label setFont:font];
31 [label setTextColor:UIColorFromRGB(kOfferLabelColor)]; 34 [label setTextColor:UIColorFromRGB(kOfferLabelColor)];
32 [label setBackgroundColor:[UIColor clearColor]]; 35 [label setBackgroundColor:[UIColor clearColor]];
33 [label sizeToFit]; 36 [label sizeToFit];
34 [label setFrame:passwords::GetGenerationAccessoryFrame([self bounds], 37 [label setFrame:passwords::GetGenerationAccessoryFrame([self bounds],
35 [label frame])]; 38 [label frame])];
36 [label setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | 39 [label setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin |
37 UIViewAutoresizingFlexibleBottomMargin | 40 UIViewAutoresizingFlexibleBottomMargin |
38 (base::i18n::IsRTL() 41 (base::i18n::IsRTL()
39 ? UIViewAutoresizingFlexibleLeftMargin 42 ? UIViewAutoresizingFlexibleLeftMargin
40 : UIViewAutoresizingFlexibleRightMargin)]; 43 : UIViewAutoresizingFlexibleRightMargin)];
41 [self addSubview:label]; 44 [self addSubview:label];
42 45
43 // Invisible button for tap recognition. 46 // Invisible button for tap recognition.
44 base::scoped_nsobject<UIButton> button( 47 UIButton* button = [[UIButton alloc] initWithFrame:[self bounds]];
45 [[UIButton alloc] initWithFrame:[self bounds]]);
46 [button setBackgroundColor:[UIColor clearColor]]; 48 [button setBackgroundColor:[UIColor clearColor]];
47 [button setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 49 [button setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
48 UIViewAutoresizingFlexibleHeight]; 50 UIViewAutoresizingFlexibleHeight];
49 [button addTarget:delegate 51 [button addTarget:delegate
50 action:@selector(generatePassword) 52 action:@selector(generatePassword)
51 forControlEvents:UIControlEventTouchUpInside]; 53 forControlEvents:UIControlEventTouchUpInside];
52 [self addSubview:button]; 54 [self addSubview:button];
53 } 55 }
54 return self; 56 return self;
55 } 57 }
56 58
57 @end 59 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698