Index: ios/chrome/browser/ui/ntp/most_visited_cell.mm |
diff --git a/ios/chrome/browser/ui/ntp/most_visited_cell.mm b/ios/chrome/browser/ui/ntp/most_visited_cell.mm |
index c4bde1184dcb1a67664acd0a60c898ad24c6874b..ae4187eeef0eb8908788ae847afd80f326de9b1a 100644 |
--- a/ios/chrome/browser/ui/ntp/most_visited_cell.mm |
+++ b/ios/chrome/browser/ui/ntp/most_visited_cell.mm |
@@ -6,9 +6,7 @@ |
#include <memory> |
-#import "base/ios/weak_nsobject.h" |
#include "base/mac/bind_objc_block.h" |
-#import "base/mac/scoped_nsobject.h" |
#include "base/memory/ref_counted_memory.h" |
#include "base/strings/sys_string_conversions.h" |
#include "base/task/cancelable_task_tracker.h" |
@@ -29,6 +27,10 @@ |
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" |
#include "skia/ext/skia_utils_ios.h" |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
const CGFloat kFaviconSize = 48; |
const CGFloat kFaviconMinSize = 32; |
const CGFloat kImageViewBackgroundColor = 0.941; |
@@ -42,13 +44,13 @@ const CGFloat kMaximumHeight = 100; |
// Backs property with the same name. |
GURL _URL; |
// Weak reference to the relevant GoogleLandingDataSource. |
- base::WeakNSProtocol<id<GoogleLandingDataSource>> _dataSource; |
+ __weak id<GoogleLandingDataSource> _dataSource; |
// Backs property with the same name. |
ntp_tiles::TileVisualType _tileType; |
- base::scoped_nsobject<UILabel> _label; |
- base::scoped_nsobject<UILabel> _noIconLabel; |
- base::scoped_nsobject<UIImageView> _imageView; |
+ UILabel* _label; |
+ UILabel* _noIconLabel; |
+ UIImageView* _imageView; |
// Used to cancel tasks for the LargeIconService. |
base::CancelableTaskTracker _cancelable_task_tracker; |
} |
@@ -71,7 +73,7 @@ const CGFloat kMaximumHeight = 100; |
if (!self) { |
return nil; |
} |
- _label.reset([[UILabel alloc] initWithFrame:CGRectZero]); |
+ _label = [[UILabel alloc] initWithFrame:CGRectZero]; |
[_label setTextColor:[UIColor colorWithWhite:kLabelTextColor alpha:1.0]]; |
[_label setBackgroundColor:[UIColor clearColor]]; |
[_label setFont:[MDCTypography captionFont]]; |
@@ -80,12 +82,12 @@ const CGFloat kMaximumHeight = 100; |
[_label setPreferredMaxLayoutWidth:maxSize.width]; |
[_label setNumberOfLines:kLabelNumLines]; |
- _noIconLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); |
+ _noIconLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
[_noIconLabel setBackgroundColor:[UIColor clearColor]]; |
[_noIconLabel setFont:[MDCTypography headlineFont]]; |
[_noIconLabel setTextAlignment:NSTextAlignmentCenter]; |
- _imageView.reset([[UIImageView alloc] initWithFrame:CGRectZero]); |
+ _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; |
[_imageView layer].cornerRadius = kImageViewCornerRadius; |
[_imageView setClipsToBounds:YES]; |
[self addSubview:_imageView]; |
@@ -146,15 +148,15 @@ const CGFloat kMaximumHeight = 100; |
- (void)setupWithURL:(GURL)URL |
title:(NSString*)title |
dataSource:(id<GoogleLandingDataSource>)dataSource { |
- _dataSource.reset(dataSource); |
+ _dataSource = dataSource; |
_tileType = ntp_tiles::TileVisualType::NONE; |
[self setText:title]; |
[self setURL:URL]; |
- base::WeakNSObject<MostVisitedCell> weakSelf(self); |
+ __weak MostVisitedCell* weakSelf = self; |
void (^faviconBlock)(const favicon_base::LargeIconResult&) = |
^(const favicon_base::LargeIconResult& result) { |
- base::scoped_nsobject<MostVisitedCell> strongSelf([weakSelf retain]); |
+ MostVisitedCell* strongSelf = weakSelf; |
if (!strongSelf) |
return; |
@@ -181,7 +183,7 @@ const CGFloat kMaximumHeight = 100; |
if (result.bitmap.is_valid() || result.fallback_icon_style) { |
LargeIconCache* largeIconCache = |
- [strongSelf.get()->_dataSource largeIconCache]; |
+ [strongSelf->_dataSource largeIconCache]; |
if (largeIconCache) |
largeIconCache->SetCachedResult(URL, result); |
} |
@@ -200,7 +202,7 @@ const CGFloat kMaximumHeight = 100; |
CGFloat faviconSize = [UIScreen mainScreen].scale * kFaviconSize; |
CGFloat faviconMinSize = [UIScreen mainScreen].scale * kFaviconMinSize; |
large_icon_service->GetLargeIconOrFallbackStyle( |
- URL, faviconMinSize, faviconSize, base::BindBlock(faviconBlock), |
+ URL, faviconMinSize, faviconSize, base::BindBlockArc(faviconBlock), |
&_cancelable_task_tracker); |
} |