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

Unified Diff: ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm

Issue 2680433002: [ObjC ARC] Converts ios/chrome/browser/ui/first_run:first_run to ARC. (Closed)
Patch Set: weaks Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
diff --git a/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
index 8cad5b6712557873d561f23b203a3e52db09c051..8904dfdb99a6451393565ebf9bb6806583ae15d2 100644
--- a/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
+++ b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
@@ -5,9 +5,7 @@
#import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view.h"
#include "base/i18n/rtl.h"
-#import "base/ios/weak_nsobject.h"
#include "base/logging.h"
-#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/UIView+SizeClassSupport.h"
#include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h"
@@ -23,6 +21,10 @@
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace {
// Accessibility identifier for the checkbox button.
@@ -71,33 +73,33 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
@interface WelcomeToChromeView () {
// Backing objects for properties of the same name.
- base::WeakNSProtocol<id<WelcomeToChromeViewDelegate>> _delegate;
- base::scoped_nsobject<UIView> _containerView;
- base::scoped_nsobject<UILabel> _titleLabel;
- base::scoped_nsobject<UIImageView> _imageView;
- base::scoped_nsobject<UILabel> _TOSLabel;
- base::scoped_nsobject<LabelLinkController> _TOSLabelLinkController;
- base::scoped_nsobject<UIButton> _checkBoxButton;
- base::scoped_nsobject<UILabel> _optInLabel;
- base::scoped_nsobject<PrimaryActionButton> _OKButton;
+ __weak id<WelcomeToChromeViewDelegate> _delegate;
bzanotti 2017/02/06 18:35:31 You should be able to remove this entirely and use
lody 2017/02/07 15:46:50 Done.
+ UIView* _containerView;
+ UILabel* _titleLabel;
+ UIImageView* _imageView;
+ UILabel* _TOSLabel;
+ LabelLinkController* _TOSLabelLinkController;
+ UIButton* _checkBoxButton;
+ UILabel* _optInLabel;
+ PrimaryActionButton* _OKButton;
}
// Subview properties are lazily instantiated upon their first use.
// A container view used to layout and center subviews.
-@property(nonatomic, readonly) UIView* containerView;
+@property(weak, nonatomic, readonly) UIView* containerView;
stkhapugin 2017/02/06 18:07:20 Here and below, since those were backed with scope
lody 2017/02/07 15:46:50 Done.
// The "Welcome to Chrome" label that appears at the top of the view.
-@property(nonatomic, readonly) UILabel* titleLabel;
+@property(weak, nonatomic, readonly) UILabel* titleLabel;
// The Chrome logo image view.
-@property(nonatomic, readonly) UIImageView* imageView;
+@property(weak, nonatomic, readonly) UIImageView* imageView;
// The "Terms of Service" label.
-@property(nonatomic, readonly) UILabel* TOSLabel;
+@property(weak, nonatomic, readonly) UILabel* TOSLabel;
// The stats reporting opt-in label.
-@property(nonatomic, readonly) UILabel* optInLabel;
+@property(weak, nonatomic, readonly) UILabel* optInLabel;
// The stats reporting opt-in checkbox button.
-@property(nonatomic, readonly) UIButton* checkBoxButton;
+@property(weak, nonatomic, readonly) UIButton* checkBoxButton;
// The "Accept & Continue" button.
-@property(nonatomic, readonly) PrimaryActionButton* OKButton;
+@property(weak, nonatomic, readonly) PrimaryActionButton* OKButton;
// Subview layout methods. They must be called in the order declared here, as
// subsequent subview layouts depend on the layouts that precede them.
@@ -162,7 +164,7 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
self.imageView.center = CGPointMake(CGRectGetMidX(self.containerView.bounds),
CGRectGetMidY(self.containerView.bounds));
- base::WeakNSObject<WelcomeToChromeView> weakSelf(self);
+ __weak WelcomeToChromeView* weakSelf = self;
[UIView animateWithDuration:kAnimationDuration
delay:kAnimationDelay
options:UIViewAnimationCurveEaseInOut
@@ -184,7 +186,7 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
}
- (void)setDelegate:(id<WelcomeToChromeViewDelegate>)delegate {
- _delegate.reset(delegate);
+ _delegate = delegate;
stkhapugin 2017/02/06 18:07:20 Remove this, as this can now be synthesized. Same
lody 2017/02/07 15:46:50 Done.
}
- (BOOL)isCheckBoxSelected {
@@ -198,15 +200,15 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
- (UIView*)containerView {
if (!_containerView) {
- _containerView.reset([[UIView alloc] initWithFrame:CGRectZero]);
+ _containerView = [[UIView alloc] initWithFrame:CGRectZero];
[_containerView setBackgroundColor:[UIColor whiteColor]];
}
- return _containerView.get();
+ return _containerView;
}
- (UILabel*)titleLabel {
if (!_titleLabel) {
- _titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
+ _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[_titleLabel setBackgroundColor:[UIColor whiteColor]];
[_titleLabel setNumberOfLines:0];
[_titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
@@ -214,41 +216,41 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
[_titleLabel
setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_WELCOME_TO_CHROME)];
}
- return _titleLabel.get();
+ return _titleLabel;
}
- (UIImageView*)imageView {
if (!_imageView) {
UIImage* image = [UIImage imageNamed:kAppLogoImageName];
- _imageView.reset([[UIImageView alloc] initWithImage:image]);
+ _imageView = [[UIImageView alloc] initWithImage:image];
[_imageView setBackgroundColor:[UIColor whiteColor]];
}
- return _imageView.get();
+ return _imageView;
}
- (UILabel*)TOSLabel {
if (!_TOSLabel) {
- _TOSLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
+ _TOSLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[_TOSLabel setNumberOfLines:0];
[_TOSLabel setTextAlignment:NSTextAlignmentCenter];
}
- return _TOSLabel.get();
+ return _TOSLabel;
}
- (UILabel*)optInLabel {
if (!_optInLabel) {
- _optInLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
+ _optInLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[_optInLabel setNumberOfLines:0];
[_optInLabel
setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL)];
[_optInLabel setTextAlignment:NSTextAlignmentNatural];
}
- return _optInLabel.get();
+ return _optInLabel;
}
- (UIButton*)checkBoxButton {
if (!_checkBoxButton) {
- _checkBoxButton.reset([[UIButton alloc] initWithFrame:CGRectZero]);
+ _checkBoxButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_checkBoxButton setBackgroundColor:[UIColor clearColor]];
[_checkBoxButton addTarget:self
action:@selector(checkBoxButtonWasTapped)
@@ -263,12 +265,12 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
[_checkBoxButton setImage:[UIImage imageNamed:kCheckBoxCheckedImageName]
forState:UIControlStateSelected];
}
- return _checkBoxButton.get();
+ return _checkBoxButton;
}
- (PrimaryActionButton*)OKButton {
if (!_OKButton) {
- _OKButton.reset([[PrimaryActionButton alloc] initWithFrame:CGRectZero]);
+ _OKButton = [[PrimaryActionButton alloc] initWithFrame:CGRectZero];
[_OKButton addTarget:self
action:@selector(OKButtonWasTapped)
forControlEvents:UIControlEventTouchUpInside];
@@ -281,7 +283,7 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
SetA11yLabelAndUiAutomationName(
_OKButton, IDS_IOS_FIRSTRUN_OPT_IN_ACCEPT_BUTTON, @"Accept & Continue");
}
- return _OKButton.get();
+ return _OKButton;
}
#pragma mark - Layout
@@ -359,16 +361,16 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
linkTextRange.length++;
}
- base::WeakNSObject<WelcomeToChromeView> weakSelf(self);
+ __weak WelcomeToChromeView* weakSelf = self;
ProceduralBlockWithURL action = ^(const GURL& url) {
- base::scoped_nsobject<WelcomeToChromeView> strongSelf([weakSelf retain]);
+ WelcomeToChromeView* strongSelf = weakSelf;
if (!strongSelf)
return;
[[strongSelf delegate] welcomeToChromeViewDidTapTOSLink:strongSelf];
};
- _TOSLabelLinkController.reset(
- [[LabelLinkController alloc] initWithLabel:_TOSLabel action:action]);
+ _TOSLabelLinkController =
+ [[LabelLinkController alloc] initWithLabel:_TOSLabel action:action];
[_TOSLabelLinkController
addLinkWithRange:linkTextRange
url:GURL("internal://terms-of-service")];

Powered by Google App Engine
This is Rietveld 408576698