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

Unified Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm

Issue 2741413005: [ObjC ARC] Converts ios/chrome/browser/ui/bookmarks:bookmarks_arc to ARC. (Closed)
Patch Set: Created 3 years, 9 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/bookmarks/bookmark_collection_view.mm
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm b/ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm
index e342f092a4d743ec0c3ae614a2943f93f13a33f2..01654b9867960432c4225d6ff1c66d7ce0d16cdb 100644
--- a/ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm
+++ b/ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm
@@ -9,11 +9,8 @@
#include <map>
#include <memory>
-#include "base/ios/weak_nsobject.h"
#include "base/mac/bind_objc_block.h"
#include "base/mac/foundation_util.h"
-#include "base/mac/objc_property_releaser.h"
-#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_model_observer.h"
@@ -34,6 +31,10 @@
#include "skia/ext/skia_utils_ios.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using bookmarks::BookmarkNode;
namespace {
@@ -62,8 +63,6 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge;
ios::ChromeBrowserState* _browserState;
- base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkCollectionView;
-
// Map of favicon load tasks for each index path. Used to keep track of
// pending favicon load operations so that they can be cancelled upon cell
// reuse. Keys are (section, item) pairs of cell index paths.
@@ -75,16 +74,16 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
// Redefined to be readwrite.
@property(nonatomic, assign) bookmarks::BookmarkModel* bookmarkModel;
// Redefined to be readwrite.
-@property(nonatomic, retain) UICollectionView* collectionView;
+@property(nonatomic, strong) UICollectionView* collectionView;
// Redefined to be readwrite.
@property(nonatomic, assign) BOOL editing;
// Detects a long press on a cell.
-@property(nonatomic, retain) UILongPressGestureRecognizer* longPressRecognizer;
+@property(nonatomic, strong) UILongPressGestureRecognizer* longPressRecognizer;
// Background view of the collection view shown when there is no items.
-@property(nonatomic, retain)
+@property(nonatomic, strong)
BookmarkCollectionViewBackground* emptyCollectionBackgroundView;
// Shadow to display over the content.
-@property(nonatomic, retain) UIView* shadow;
+@property(nonatomic, strong) UIView* shadow;
// Updates the editing state for the cell.
- (void)updateEditingStateOfCell:(BookmarkCell*)cell
@@ -137,9 +136,6 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
frame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
- _propertyReleaser_BookmarkCollectionView.Init(
- self, [BookmarkCollectionView class]);
-
_browserState = browserState;
// Set up connection to the BookmarkModel.
@@ -170,17 +166,16 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
[moi self];
});
_faviconTaskTracker.TryCancelAll();
- [super dealloc];
}
- (void)setupViews {
self.backgroundColor = bookmark_utils_ios::mainBackgroundColor();
- base::scoped_nsobject<UICollectionViewFlowLayout> layout(
- [[UICollectionViewFlowLayout alloc] init]);
+ UICollectionViewFlowLayout* layout =
+ [[UICollectionViewFlowLayout alloc] init];
- base::scoped_nsobject<UICollectionView> collectionView(
+ UICollectionView* collectionView =
[[UICollectionView alloc] initWithFrame:self.bounds
- collectionViewLayout:layout]);
+ collectionViewLayout:layout];
self.collectionView = collectionView;
self.collectionView.backgroundColor = [UIColor clearColor];
self.collectionView.autoresizingMask =
@@ -205,9 +200,8 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
[self addSubview:self.collectionView];
// Set up the background view shown when the collection is empty.
- base::scoped_nsobject<BookmarkCollectionViewBackground>
- emptyCollectionBackgroundView(
- [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero]);
+ BookmarkCollectionViewBackground* emptyCollectionBackgroundView =
+ [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero];
self.emptyCollectionBackgroundView = emptyCollectionBackgroundView;
self.emptyCollectionBackgroundView.autoresizingMask =
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
@@ -219,11 +213,9 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
[self updateShadow];
- self.longPressRecognizer =
- base::scoped_nsobject<UILongPressGestureRecognizer>(
- [[UILongPressGestureRecognizer alloc]
- initWithTarget:self
- action:@selector(longPress:)]);
+ self.longPressRecognizer = [[UILongPressGestureRecognizer alloc]
+ initWithTarget:self
+ action:@selector(longPress:)];
self.longPressRecognizer.delegate = self;
[self.collectionView addGestureRecognizer:self.longPressRecognizer];
}
@@ -240,10 +232,9 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
self.shadow =
bookmark_utils_ios::dropShadowWithWidth(CGRectGetWidth(self.bounds));
} else {
- self.shadow = [[[UIView alloc]
+ self.shadow = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds),
- 1 / [[UIScreen mainScreen] scale])]
- autorelease];
+ 1 / [[UIScreen mainScreen] scale])];
self.shadow.backgroundColor = [UIColor colorWithWhite:0.0 alpha:.12];
}
@@ -486,12 +477,12 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
[self cancelLoadingFaviconAtIndexPath:indexPath];
// Start loading a favicon.
- base::WeakNSObject<BookmarkCollectionView> weakSelf(self);
+ __weak BookmarkCollectionView* weakSelf = self;
const bookmarks::BookmarkNode* node = [self nodeAtIndexPath:indexPath];
GURL blockURL(node->url());
void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^(
const favicon_base::LargeIconResult& result) {
- base::scoped_nsobject<BookmarkCollectionView> strongSelf([weakSelf retain]);
+ BookmarkCollectionView* strongSelf = weakSelf;
if (!strongSelf)
return;
UIImage* favIcon = nil;
@@ -499,8 +490,7 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
UIColor* textColor = nil;
NSString* fallbackText = nil;
if (result.bitmap.is_valid()) {
- scoped_refptr<base::RefCountedMemory> data =
- result.bitmap.bitmap_data.get();
+ scoped_refptr<base::RefCountedMemory> data = result.bitmap.bitmap_data;
favIcon = [UIImage imageWithData:[NSData dataWithBytes:data->front()
length:data->size()]];
} else if (result.fallback_icon_style) {
@@ -527,7 +517,7 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
base::CancelableTaskTracker::TaskId taskId =
IOSChromeLargeIconServiceFactory::GetForBrowserState(self.browserState)
->GetLargeIconOrFallbackStyle(node->url(), minSize, preferredSize,
- base::BindBlock(faviconBlock),
+ base::BindBlockArc(faviconBlock),
&_faviconTaskTracker);
_faviconLoadTasks[IntegerPair(indexPath.section, indexPath.item)] = taskId;
}
@@ -701,8 +691,7 @@ const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
UICollectionViewCell* cell =
[self.collectionView cellForItemAtIndexPath:indexPath];
if (!cell) {
- cell = [[[BookmarkPromoCell alloc] initWithFrame:estimatedFrame]
- autorelease];
+ cell = [[BookmarkPromoCell alloc] initWithFrame:estimatedFrame];
}
cell.frame = estimatedFrame;
[cell layoutIfNeeded];

Powered by Google App Engine
This is Rietveld 408576698