Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/first_run/welcome_to_chrome_view.h" | 5 #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #import "base/ios/weak_nsobject.h" | |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 #import "base/mac/scoped_nsobject.h" | |
| 11 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 12 #import "ios/chrome/browser/ui/UIView+SizeClassSupport.h" | 10 #import "ios/chrome/browser/ui/UIView+SizeClassSupport.h" |
| 13 #include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h" | 11 #include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h" |
| 14 #include "ios/chrome/browser/ui/first_run/first_run_util.h" | 12 #include "ios/chrome/browser/ui/first_run/first_run_util.h" |
| 15 #include "ios/chrome/browser/ui/ui_util.h" | 13 #include "ios/chrome/browser/ui/ui_util.h" |
| 16 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 14 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 17 #import "ios/chrome/browser/ui/util/CRUILabel+AttributeUtils.h" | 15 #import "ios/chrome/browser/ui/util/CRUILabel+AttributeUtils.h" |
| 18 #import "ios/chrome/browser/ui/util/label_link_controller.h" | 16 #import "ios/chrome/browser/ui/util/label_link_controller.h" |
| 19 #include "ios/chrome/common/string_util.h" | 17 #include "ios/chrome/common/string_util.h" |
| 20 #include "ios/chrome/grit/ios_chromium_strings.h" | 18 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 21 #include "ios/chrome/grit/ios_strings.h" | 19 #include "ios/chrome/grit/ios_strings.h" |
| 22 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" | 20 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 25 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 25 #error "This file requires ARC support." | |
| 26 #endif | |
| 27 | |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 // Accessibility identifier for the checkbox button. | 30 // Accessibility identifier for the checkbox button. |
| 29 NSString* const kUMAMetricsButtonAccessibilityIdentifier = | 31 NSString* const kUMAMetricsButtonAccessibilityIdentifier = |
| 30 @"UMAMetricsButtonAccessibilityIdentifier"; | 32 @"UMAMetricsButtonAccessibilityIdentifier"; |
| 31 | 33 |
| 32 // Color of "Terms of Service" link text. | 34 // Color of "Terms of Service" link text. |
| 33 const int kLinkColorRGB = 0x5D9AFF; | 35 const int kLinkColorRGB = 0x5D9AFF; |
| 34 | 36 |
| 35 // The width of the container view for a REGULAR width size class. | 37 // The width of the container view for a REGULAR width size class. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 64 | 66 |
| 65 // Image names. | 67 // Image names. |
| 66 NSString* const kAppLogoImageName = @"launchscreen_app_logo"; | 68 NSString* const kAppLogoImageName = @"launchscreen_app_logo"; |
| 67 NSString* const kCheckBoxImageName = @"checkbox"; | 69 NSString* const kCheckBoxImageName = @"checkbox"; |
| 68 NSString* const kCheckBoxCheckedImageName = @"checkbox_checked"; | 70 NSString* const kCheckBoxCheckedImageName = @"checkbox_checked"; |
| 69 | 71 |
| 70 } // namespace | 72 } // namespace |
| 71 | 73 |
| 72 @interface WelcomeToChromeView () { | 74 @interface WelcomeToChromeView () { |
| 73 // Backing objects for properties of the same name. | 75 // Backing objects for properties of the same name. |
| 74 base::WeakNSProtocol<id<WelcomeToChromeViewDelegate>> _delegate; | 76 __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.
| |
| 75 base::scoped_nsobject<UIView> _containerView; | 77 UIView* _containerView; |
| 76 base::scoped_nsobject<UILabel> _titleLabel; | 78 UILabel* _titleLabel; |
| 77 base::scoped_nsobject<UIImageView> _imageView; | 79 UIImageView* _imageView; |
| 78 base::scoped_nsobject<UILabel> _TOSLabel; | 80 UILabel* _TOSLabel; |
| 79 base::scoped_nsobject<LabelLinkController> _TOSLabelLinkController; | 81 LabelLinkController* _TOSLabelLinkController; |
| 80 base::scoped_nsobject<UIButton> _checkBoxButton; | 82 UIButton* _checkBoxButton; |
| 81 base::scoped_nsobject<UILabel> _optInLabel; | 83 UILabel* _optInLabel; |
| 82 base::scoped_nsobject<PrimaryActionButton> _OKButton; | 84 PrimaryActionButton* _OKButton; |
| 83 } | 85 } |
| 84 | 86 |
| 85 // Subview properties are lazily instantiated upon their first use. | 87 // Subview properties are lazily instantiated upon their first use. |
| 86 | 88 |
| 87 // A container view used to layout and center subviews. | 89 // A container view used to layout and center subviews. |
| 88 @property(nonatomic, readonly) UIView* containerView; | 90 @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.
| |
| 89 // The "Welcome to Chrome" label that appears at the top of the view. | 91 // The "Welcome to Chrome" label that appears at the top of the view. |
| 90 @property(nonatomic, readonly) UILabel* titleLabel; | 92 @property(weak, nonatomic, readonly) UILabel* titleLabel; |
| 91 // The Chrome logo image view. | 93 // The Chrome logo image view. |
| 92 @property(nonatomic, readonly) UIImageView* imageView; | 94 @property(weak, nonatomic, readonly) UIImageView* imageView; |
| 93 // The "Terms of Service" label. | 95 // The "Terms of Service" label. |
| 94 @property(nonatomic, readonly) UILabel* TOSLabel; | 96 @property(weak, nonatomic, readonly) UILabel* TOSLabel; |
| 95 // The stats reporting opt-in label. | 97 // The stats reporting opt-in label. |
| 96 @property(nonatomic, readonly) UILabel* optInLabel; | 98 @property(weak, nonatomic, readonly) UILabel* optInLabel; |
| 97 // The stats reporting opt-in checkbox button. | 99 // The stats reporting opt-in checkbox button. |
| 98 @property(nonatomic, readonly) UIButton* checkBoxButton; | 100 @property(weak, nonatomic, readonly) UIButton* checkBoxButton; |
| 99 // The "Accept & Continue" button. | 101 // The "Accept & Continue" button. |
| 100 @property(nonatomic, readonly) PrimaryActionButton* OKButton; | 102 @property(weak, nonatomic, readonly) PrimaryActionButton* OKButton; |
| 101 | 103 |
| 102 // Subview layout methods. They must be called in the order declared here, as | 104 // Subview layout methods. They must be called in the order declared here, as |
| 103 // subsequent subview layouts depend on the layouts that precede them. | 105 // subsequent subview layouts depend on the layouts that precede them. |
| 104 - (void)layoutTitleLabel; | 106 - (void)layoutTitleLabel; |
| 105 - (void)layoutImageView; | 107 - (void)layoutImageView; |
| 106 - (void)layoutTOSLabel; | 108 - (void)layoutTOSLabel; |
| 107 - (void)layoutOptInLabel; | 109 - (void)layoutOptInLabel; |
| 108 - (void)layoutCheckBoxButton; | 110 - (void)layoutCheckBoxButton; |
| 109 - (void)layoutContainerView; | 111 - (void)layoutContainerView; |
| 110 - (void)layoutOKButton; | 112 - (void)layoutOKButton; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 157 |
| 156 // Get final location of logo based on result from previously run | 158 // Get final location of logo based on result from previously run |
| 157 // layoutSubviews. | 159 // layoutSubviews. |
| 158 CGRect finalLogoFrame = self.imageView.frame; | 160 CGRect finalLogoFrame = self.imageView.frame; |
| 159 // Ensure that frame position is valid and that layoutSubviews ran | 161 // Ensure that frame position is valid and that layoutSubviews ran |
| 160 // before this method. | 162 // before this method. |
| 161 DCHECK(finalLogoFrame.origin.x >= 0 && finalLogoFrame.origin.y >= 0); | 163 DCHECK(finalLogoFrame.origin.x >= 0 && finalLogoFrame.origin.y >= 0); |
| 162 self.imageView.center = CGPointMake(CGRectGetMidX(self.containerView.bounds), | 164 self.imageView.center = CGPointMake(CGRectGetMidX(self.containerView.bounds), |
| 163 CGRectGetMidY(self.containerView.bounds)); | 165 CGRectGetMidY(self.containerView.bounds)); |
| 164 | 166 |
| 165 base::WeakNSObject<WelcomeToChromeView> weakSelf(self); | 167 __weak WelcomeToChromeView* weakSelf = self; |
| 166 [UIView animateWithDuration:kAnimationDuration | 168 [UIView animateWithDuration:kAnimationDuration |
| 167 delay:kAnimationDelay | 169 delay:kAnimationDelay |
| 168 options:UIViewAnimationCurveEaseInOut | 170 options:UIViewAnimationCurveEaseInOut |
| 169 animations:^{ | 171 animations:^{ |
| 170 [weakSelf imageView].frame = finalLogoFrame; | 172 [weakSelf imageView].frame = finalLogoFrame; |
| 171 [weakSelf titleLabel].alpha = 1.0; | 173 [weakSelf titleLabel].alpha = 1.0; |
| 172 [weakSelf TOSLabel].alpha = 1.0; | 174 [weakSelf TOSLabel].alpha = 1.0; |
| 173 [weakSelf optInLabel].alpha = 1.0; | 175 [weakSelf optInLabel].alpha = 1.0; |
| 174 [weakSelf checkBoxButton].alpha = 1.0; | 176 [weakSelf checkBoxButton].alpha = 1.0; |
| 175 [weakSelf OKButton].alpha = 1.0; | 177 [weakSelf OKButton].alpha = 1.0; |
| 176 } | 178 } |
| 177 completion:nil]; | 179 completion:nil]; |
| 178 } | 180 } |
| 179 | 181 |
| 180 #pragma mark - Accessors | 182 #pragma mark - Accessors |
| 181 | 183 |
| 182 - (id<WelcomeToChromeViewDelegate>)delegate { | 184 - (id<WelcomeToChromeViewDelegate>)delegate { |
| 183 return _delegate; | 185 return _delegate; |
| 184 } | 186 } |
| 185 | 187 |
| 186 - (void)setDelegate:(id<WelcomeToChromeViewDelegate>)delegate { | 188 - (void)setDelegate:(id<WelcomeToChromeViewDelegate>)delegate { |
| 187 _delegate.reset(delegate); | 189 _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.
| |
| 188 } | 190 } |
| 189 | 191 |
| 190 - (BOOL)isCheckBoxSelected { | 192 - (BOOL)isCheckBoxSelected { |
| 191 return self.checkBoxButton.selected; | 193 return self.checkBoxButton.selected; |
| 192 } | 194 } |
| 193 | 195 |
| 194 - (void)setCheckBoxSelected:(BOOL)checkBoxSelected { | 196 - (void)setCheckBoxSelected:(BOOL)checkBoxSelected { |
| 195 if (checkBoxSelected != self.checkBoxButton.selected) | 197 if (checkBoxSelected != self.checkBoxButton.selected) |
| 196 [self checkBoxButtonWasTapped]; | 198 [self checkBoxButtonWasTapped]; |
| 197 } | 199 } |
| 198 | 200 |
| 199 - (UIView*)containerView { | 201 - (UIView*)containerView { |
| 200 if (!_containerView) { | 202 if (!_containerView) { |
| 201 _containerView.reset([[UIView alloc] initWithFrame:CGRectZero]); | 203 _containerView = [[UIView alloc] initWithFrame:CGRectZero]; |
| 202 [_containerView setBackgroundColor:[UIColor whiteColor]]; | 204 [_containerView setBackgroundColor:[UIColor whiteColor]]; |
| 203 } | 205 } |
| 204 return _containerView.get(); | 206 return _containerView; |
| 205 } | 207 } |
| 206 | 208 |
| 207 - (UILabel*)titleLabel { | 209 - (UILabel*)titleLabel { |
| 208 if (!_titleLabel) { | 210 if (!_titleLabel) { |
| 209 _titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 211 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 210 [_titleLabel setBackgroundColor:[UIColor whiteColor]]; | 212 [_titleLabel setBackgroundColor:[UIColor whiteColor]]; |
| 211 [_titleLabel setNumberOfLines:0]; | 213 [_titleLabel setNumberOfLines:0]; |
| 212 [_titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; | 214 [_titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; |
| 213 [_titleLabel setBaselineAdjustment:UIBaselineAdjustmentAlignBaselines]; | 215 [_titleLabel setBaselineAdjustment:UIBaselineAdjustmentAlignBaselines]; |
| 214 [_titleLabel | 216 [_titleLabel |
| 215 setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_WELCOME_TO_CHROME)]; | 217 setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_WELCOME_TO_CHROME)]; |
| 216 } | 218 } |
| 217 return _titleLabel.get(); | 219 return _titleLabel; |
| 218 } | 220 } |
| 219 | 221 |
| 220 - (UIImageView*)imageView { | 222 - (UIImageView*)imageView { |
| 221 if (!_imageView) { | 223 if (!_imageView) { |
| 222 UIImage* image = [UIImage imageNamed:kAppLogoImageName]; | 224 UIImage* image = [UIImage imageNamed:kAppLogoImageName]; |
| 223 _imageView.reset([[UIImageView alloc] initWithImage:image]); | 225 _imageView = [[UIImageView alloc] initWithImage:image]; |
| 224 [_imageView setBackgroundColor:[UIColor whiteColor]]; | 226 [_imageView setBackgroundColor:[UIColor whiteColor]]; |
| 225 } | 227 } |
| 226 return _imageView.get(); | 228 return _imageView; |
| 227 } | 229 } |
| 228 | 230 |
| 229 - (UILabel*)TOSLabel { | 231 - (UILabel*)TOSLabel { |
| 230 if (!_TOSLabel) { | 232 if (!_TOSLabel) { |
| 231 _TOSLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 233 _TOSLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 232 [_TOSLabel setNumberOfLines:0]; | 234 [_TOSLabel setNumberOfLines:0]; |
| 233 [_TOSLabel setTextAlignment:NSTextAlignmentCenter]; | 235 [_TOSLabel setTextAlignment:NSTextAlignmentCenter]; |
| 234 } | 236 } |
| 235 return _TOSLabel.get(); | 237 return _TOSLabel; |
| 236 } | 238 } |
| 237 | 239 |
| 238 - (UILabel*)optInLabel { | 240 - (UILabel*)optInLabel { |
| 239 if (!_optInLabel) { | 241 if (!_optInLabel) { |
| 240 _optInLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 242 _optInLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 241 [_optInLabel setNumberOfLines:0]; | 243 [_optInLabel setNumberOfLines:0]; |
| 242 [_optInLabel | 244 [_optInLabel |
| 243 setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL)]; | 245 setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL)]; |
| 244 [_optInLabel setTextAlignment:NSTextAlignmentNatural]; | 246 [_optInLabel setTextAlignment:NSTextAlignmentNatural]; |
| 245 } | 247 } |
| 246 return _optInLabel.get(); | 248 return _optInLabel; |
| 247 } | 249 } |
| 248 | 250 |
| 249 - (UIButton*)checkBoxButton { | 251 - (UIButton*)checkBoxButton { |
| 250 if (!_checkBoxButton) { | 252 if (!_checkBoxButton) { |
| 251 _checkBoxButton.reset([[UIButton alloc] initWithFrame:CGRectZero]); | 253 _checkBoxButton = [[UIButton alloc] initWithFrame:CGRectZero]; |
| 252 [_checkBoxButton setBackgroundColor:[UIColor clearColor]]; | 254 [_checkBoxButton setBackgroundColor:[UIColor clearColor]]; |
| 253 [_checkBoxButton addTarget:self | 255 [_checkBoxButton addTarget:self |
| 254 action:@selector(checkBoxButtonWasTapped) | 256 action:@selector(checkBoxButtonWasTapped) |
| 255 forControlEvents:UIControlEventTouchUpInside]; | 257 forControlEvents:UIControlEventTouchUpInside]; |
| 256 SetA11yLabelAndUiAutomationName(_checkBoxButton, | 258 SetA11yLabelAndUiAutomationName(_checkBoxButton, |
| 257 IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL, | 259 IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL, |
| 258 kUMAMetricsButtonAccessibilityIdentifier); | 260 kUMAMetricsButtonAccessibilityIdentifier); |
| 259 [_checkBoxButton | 261 [_checkBoxButton |
| 260 setAccessibilityValue:l10n_util::GetNSString(IDS_IOS_SETTING_OFF)]; | 262 setAccessibilityValue:l10n_util::GetNSString(IDS_IOS_SETTING_OFF)]; |
| 261 [_checkBoxButton setImage:[UIImage imageNamed:kCheckBoxImageName] | 263 [_checkBoxButton setImage:[UIImage imageNamed:kCheckBoxImageName] |
| 262 forState:UIControlStateNormal]; | 264 forState:UIControlStateNormal]; |
| 263 [_checkBoxButton setImage:[UIImage imageNamed:kCheckBoxCheckedImageName] | 265 [_checkBoxButton setImage:[UIImage imageNamed:kCheckBoxCheckedImageName] |
| 264 forState:UIControlStateSelected]; | 266 forState:UIControlStateSelected]; |
| 265 } | 267 } |
| 266 return _checkBoxButton.get(); | 268 return _checkBoxButton; |
| 267 } | 269 } |
| 268 | 270 |
| 269 - (PrimaryActionButton*)OKButton { | 271 - (PrimaryActionButton*)OKButton { |
| 270 if (!_OKButton) { | 272 if (!_OKButton) { |
| 271 _OKButton.reset([[PrimaryActionButton alloc] initWithFrame:CGRectZero]); | 273 _OKButton = [[PrimaryActionButton alloc] initWithFrame:CGRectZero]; |
| 272 [_OKButton addTarget:self | 274 [_OKButton addTarget:self |
| 273 action:@selector(OKButtonWasTapped) | 275 action:@selector(OKButtonWasTapped) |
| 274 forControlEvents:UIControlEventTouchUpInside]; | 276 forControlEvents:UIControlEventTouchUpInside]; |
| 275 NSString* acceptAndContinue = | 277 NSString* acceptAndContinue = |
| 276 l10n_util::GetNSString(IDS_IOS_FIRSTRUN_OPT_IN_ACCEPT_BUTTON); | 278 l10n_util::GetNSString(IDS_IOS_FIRSTRUN_OPT_IN_ACCEPT_BUTTON); |
| 277 [_OKButton setTitle:acceptAndContinue forState:UIControlStateNormal]; | 279 [_OKButton setTitle:acceptAndContinue forState:UIControlStateNormal]; |
| 278 [_OKButton setTitle:acceptAndContinue forState:UIControlStateHighlighted]; | 280 [_OKButton setTitle:acceptAndContinue forState:UIControlStateHighlighted]; |
| 279 // UIAutomation tests look for the Accept button to skip through the | 281 // UIAutomation tests look for the Accept button to skip through the |
| 280 // First Run UI when it shows up. | 282 // First Run UI when it shows up. |
| 281 SetA11yLabelAndUiAutomationName( | 283 SetA11yLabelAndUiAutomationName( |
| 282 _OKButton, IDS_IOS_FIRSTRUN_OPT_IN_ACCEPT_BUTTON, @"Accept & Continue"); | 284 _OKButton, IDS_IOS_FIRSTRUN_OPT_IN_ACCEPT_BUTTON, @"Accept & Continue"); |
| 283 } | 285 } |
| 284 return _OKButton.get(); | 286 return _OKButton; |
| 285 } | 287 } |
| 286 | 288 |
| 287 #pragma mark - Layout | 289 #pragma mark - Layout |
| 288 | 290 |
| 289 - (void)willMoveToSuperview:(nullable UIView*)newSuperview { | 291 - (void)willMoveToSuperview:(nullable UIView*)newSuperview { |
| 290 [super willMoveToSuperview:newSuperview]; | 292 [super willMoveToSuperview:newSuperview]; |
| 291 | 293 |
| 292 // Early return if the view hierarchy is already built. | 294 // Early return if the view hierarchy is already built. |
| 293 if (self.containerView.superview) { | 295 if (self.containerView.superview) { |
| 294 DCHECK_EQ(self, self.containerView.superview); | 296 DCHECK_EQ(self, self.containerView.superview); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 self.TOSLabel.text = strippedText; | 354 self.TOSLabel.text = strippedText; |
| 353 if (ios_internal::FixOrphanWord(self.TOSLabel)) { | 355 if (ios_internal::FixOrphanWord(self.TOSLabel)) { |
| 354 // If a newline is inserted, check whether it was added mid-link and adjust | 356 // If a newline is inserted, check whether it was added mid-link and adjust |
| 355 // |linkTextRange| accordingly. | 357 // |linkTextRange| accordingly. |
| 356 NSRange newlineRange = | 358 NSRange newlineRange = |
| 357 [self.TOSLabel.text rangeOfString:@"\n" options:0 range:linkTextRange]; | 359 [self.TOSLabel.text rangeOfString:@"\n" options:0 range:linkTextRange]; |
| 358 if (newlineRange.length) | 360 if (newlineRange.length) |
| 359 linkTextRange.length++; | 361 linkTextRange.length++; |
| 360 } | 362 } |
| 361 | 363 |
| 362 base::WeakNSObject<WelcomeToChromeView> weakSelf(self); | 364 __weak WelcomeToChromeView* weakSelf = self; |
| 363 ProceduralBlockWithURL action = ^(const GURL& url) { | 365 ProceduralBlockWithURL action = ^(const GURL& url) { |
| 364 base::scoped_nsobject<WelcomeToChromeView> strongSelf([weakSelf retain]); | 366 WelcomeToChromeView* strongSelf = weakSelf; |
| 365 if (!strongSelf) | 367 if (!strongSelf) |
| 366 return; | 368 return; |
| 367 [[strongSelf delegate] welcomeToChromeViewDidTapTOSLink:strongSelf]; | 369 [[strongSelf delegate] welcomeToChromeViewDidTapTOSLink:strongSelf]; |
| 368 }; | 370 }; |
| 369 | 371 |
| 370 _TOSLabelLinkController.reset( | 372 _TOSLabelLinkController = |
| 371 [[LabelLinkController alloc] initWithLabel:_TOSLabel action:action]); | 373 [[LabelLinkController alloc] initWithLabel:_TOSLabel action:action]; |
| 372 [_TOSLabelLinkController | 374 [_TOSLabelLinkController |
| 373 addLinkWithRange:linkTextRange | 375 addLinkWithRange:linkTextRange |
| 374 url:GURL("internal://terms-of-service")]; | 376 url:GURL("internal://terms-of-service")]; |
| 375 [_TOSLabelLinkController setLinkColor:UIColorFromRGB(kLinkColorRGB)]; | 377 [_TOSLabelLinkController setLinkColor:UIColorFromRGB(kLinkColorRGB)]; |
| 376 | 378 |
| 377 CGSize TOSLabelSize = [self.TOSLabel sizeThatFits:containerSize]; | 379 CGSize TOSLabelSize = [self.TOSLabel sizeThatFits:containerSize]; |
| 378 CGFloat TOSLabelTopPadding = kTOSLabelTopPadding[self.cr_heightSizeClass]; | 380 CGFloat TOSLabelTopPadding = kTOSLabelTopPadding[self.cr_heightSizeClass]; |
| 379 self.TOSLabel.frame = AlignRectOriginAndSizeToPixels( | 381 self.TOSLabel.frame = AlignRectOriginAndSizeToPixels( |
| 380 CGRectMake((containerSize.width - TOSLabelSize.width) / 2.0, | 382 CGRectMake((containerSize.width - TOSLabelSize.width) / 2.0, |
| 381 CGRectGetMaxY(self.imageView.frame) + TOSLabelTopPadding, | 383 CGRectGetMaxY(self.imageView.frame) + TOSLabelTopPadding, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 532 |
| 531 - (void)OKButtonWasTapped { | 533 - (void)OKButtonWasTapped { |
| 532 [self.delegate welcomeToChromeViewDidTapOKButton:self]; | 534 [self.delegate welcomeToChromeViewDidTapOKButton:self]; |
| 533 } | 535 } |
| 534 | 536 |
| 535 - (void)TOSLinkWasTapped { | 537 - (void)TOSLinkWasTapped { |
| 536 [self.delegate welcomeToChromeViewDidTapTOSLink:self]; | 538 [self.delegate welcomeToChromeViewDidTapTOSLink:self]; |
| 537 } | 539 } |
| 538 | 540 |
| 539 @end | 541 @end |
| OLD | NEW |