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

Side by Side 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 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/ui/bookmarks/bookmark_collection_view.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h"
6 6
7 #import <UIKit/UIGestureRecognizerSubclass.h> 7 #import <UIKit/UIGestureRecognizerSubclass.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/ios/weak_nsobject.h"
13 #include "base/mac/bind_objc_block.h" 12 #include "base/mac/bind_objc_block.h"
14 #include "base/mac/foundation_util.h" 13 #include "base/mac/foundation_util.h"
15 #include "base/mac/objc_property_releaser.h"
16 #include "base/mac/scoped_nsobject.h"
17 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/browser/bookmark_model_observer.h" 16 #include "components/bookmarks/browser/bookmark_model_observer.h"
20 #include "components/favicon/core/fallback_url_util.h" 17 #include "components/favicon/core/fallback_url_util.h"
21 #include "components/favicon/core/large_icon_service.h" 18 #include "components/favicon/core/large_icon_service.h"
22 #include "components/favicon_base/fallback_icon_style.h" 19 #include "components/favicon_base/fallback_icon_style.h"
23 #include "components/favicon_base/favicon_types.h" 20 #include "components/favicon_base/favicon_types.h"
24 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" 22 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h"
26 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" 23 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
27 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h" 24 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h"
28 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h" 25 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h"
29 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" 26 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h"
30 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 27 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
31 #include "ios/chrome/browser/ui/ui_util.h" 28 #include "ios/chrome/browser/ui/ui_util.h"
32 #import "ios/chrome/browser/ui/uikit_ui_util.h" 29 #import "ios/chrome/browser/ui/uikit_ui_util.h"
33 #include "ios/chrome/grit/ios_strings.h" 30 #include "ios/chrome/grit/ios_strings.h"
34 #include "skia/ext/skia_utils_ios.h" 31 #include "skia/ext/skia_utils_ios.h"
35 #include "ui/base/l10n/l10n_util_mac.h" 32 #include "ui/base/l10n/l10n_util_mac.h"
36 33
34 #if !defined(__has_feature) || !__has_feature(objc_arc)
35 #error "This file requires ARC support."
36 #endif
37
37 using bookmarks::BookmarkNode; 38 using bookmarks::BookmarkNode;
38 39
39 namespace { 40 namespace {
40 41
41 // Used to store a pair of NSIntegers when storing a NSIndexPath in C++ 42 // Used to store a pair of NSIntegers when storing a NSIndexPath in C++
42 // collections. 43 // collections.
43 using IntegerPair = std::pair<NSInteger, NSInteger>; 44 using IntegerPair = std::pair<NSInteger, NSInteger>;
44 45
45 // The margin between the side of the view and the first and last tile. 46 // The margin between the side of the view and the first and last tile.
46 CGFloat rowMarginTablet = 24.0; 47 CGFloat rowMarginTablet = 24.0;
47 CGFloat rowHeight = 48.0; 48 CGFloat rowHeight = 48.0;
48 // Minimal acceptable favicon size, in points. 49 // Minimal acceptable favicon size, in points.
49 CGFloat minFaviconSizePt = 16; 50 CGFloat minFaviconSizePt = 16;
50 51
51 // Delay in seconds to which the empty background view will be shown when the 52 // Delay in seconds to which the empty background view will be shown when the
52 // collection view is empty. 53 // collection view is empty.
53 // This delay should not be too small to let enough time to load bookmarks 54 // This delay should not be too small to let enough time to load bookmarks
54 // from network. 55 // from network.
55 const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0; 56 const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
56 57
57 } // namespace 58 } // namespace
58 59
59 @interface BookmarkCollectionView ()<UICollectionViewDataSource, 60 @interface BookmarkCollectionView ()<UICollectionViewDataSource,
60 UICollectionViewDelegateFlowLayout, 61 UICollectionViewDelegateFlowLayout,
61 UIGestureRecognizerDelegate> { 62 UIGestureRecognizerDelegate> {
62 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge; 63 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge;
63 ios::ChromeBrowserState* _browserState; 64 ios::ChromeBrowserState* _browserState;
64 65
65 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkCollectionView;
66
67 // Map of favicon load tasks for each index path. Used to keep track of 66 // Map of favicon load tasks for each index path. Used to keep track of
68 // pending favicon load operations so that they can be cancelled upon cell 67 // pending favicon load operations so that they can be cancelled upon cell
69 // reuse. Keys are (section, item) pairs of cell index paths. 68 // reuse. Keys are (section, item) pairs of cell index paths.
70 std::map<IntegerPair, base::CancelableTaskTracker::TaskId> _faviconLoadTasks; 69 std::map<IntegerPair, base::CancelableTaskTracker::TaskId> _faviconLoadTasks;
71 // Task tracker used for async favicon loads. 70 // Task tracker used for async favicon loads.
72 base::CancelableTaskTracker _faviconTaskTracker; 71 base::CancelableTaskTracker _faviconTaskTracker;
73 } 72 }
74 73
75 // Redefined to be readwrite. 74 // Redefined to be readwrite.
76 @property(nonatomic, assign) bookmarks::BookmarkModel* bookmarkModel; 75 @property(nonatomic, assign) bookmarks::BookmarkModel* bookmarkModel;
77 // Redefined to be readwrite. 76 // Redefined to be readwrite.
78 @property(nonatomic, retain) UICollectionView* collectionView; 77 @property(nonatomic, strong) UICollectionView* collectionView;
79 // Redefined to be readwrite. 78 // Redefined to be readwrite.
80 @property(nonatomic, assign) BOOL editing; 79 @property(nonatomic, assign) BOOL editing;
81 // Detects a long press on a cell. 80 // Detects a long press on a cell.
82 @property(nonatomic, retain) UILongPressGestureRecognizer* longPressRecognizer; 81 @property(nonatomic, strong) UILongPressGestureRecognizer* longPressRecognizer;
83 // Background view of the collection view shown when there is no items. 82 // Background view of the collection view shown when there is no items.
84 @property(nonatomic, retain) 83 @property(nonatomic, strong)
85 BookmarkCollectionViewBackground* emptyCollectionBackgroundView; 84 BookmarkCollectionViewBackground* emptyCollectionBackgroundView;
86 // Shadow to display over the content. 85 // Shadow to display over the content.
87 @property(nonatomic, retain) UIView* shadow; 86 @property(nonatomic, strong) UIView* shadow;
88 87
89 // Updates the editing state for the cell. 88 // Updates the editing state for the cell.
90 - (void)updateEditingStateOfCell:(BookmarkCell*)cell 89 - (void)updateEditingStateOfCell:(BookmarkCell*)cell
91 atIndexPath:(NSIndexPath*)indexPath 90 atIndexPath:(NSIndexPath*)indexPath
92 animateMenuVisibility:(BOOL)animateMenuVisibility 91 animateMenuVisibility:(BOOL)animateMenuVisibility
93 animateSelectedState:(BOOL)animateSelectedState; 92 animateSelectedState:(BOOL)animateSelectedState;
94 93
95 // Callback received when the user taps the menu button on the cell. 94 // Callback received when the user taps the menu button on the cell.
96 - (void)didTapMenuButton:(BookmarkItemCell*)cell view:(UIView*)view; 95 - (void)didTapMenuButton:(BookmarkItemCell*)cell view:(UIView*)view;
97 96
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 129
131 - (id)initWithFrame:(CGRect)frame { 130 - (id)initWithFrame:(CGRect)frame {
132 NOTREACHED(); 131 NOTREACHED();
133 return nil; 132 return nil;
134 } 133 }
135 134
136 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState 135 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
137 frame:(CGRect)frame { 136 frame:(CGRect)frame {
138 self = [super initWithFrame:frame]; 137 self = [super initWithFrame:frame];
139 if (self) { 138 if (self) {
140 _propertyReleaser_BookmarkCollectionView.Init(
141 self, [BookmarkCollectionView class]);
142
143 _browserState = browserState; 139 _browserState = browserState;
144 140
145 // Set up connection to the BookmarkModel. 141 // Set up connection to the BookmarkModel.
146 _bookmarkModel = 142 _bookmarkModel =
147 ios::BookmarkModelFactory::GetForBrowserState(browserState); 143 ios::BookmarkModelFactory::GetForBrowserState(browserState);
148 144
149 // Set up observers. 145 // Set up observers.
150 _modelBridge.reset( 146 _modelBridge.reset(
151 new bookmarks::BookmarkModelBridge(self, _bookmarkModel)); 147 new bookmarks::BookmarkModelBridge(self, _bookmarkModel));
152 148
(...skipping 10 matching lines...) Expand all
163 // A collection view with a layout that uses a dynamic animator (aka 159 // A collection view with a layout that uses a dynamic animator (aka
164 // something that changes the layout over time) will crash if it is 160 // something that changes the layout over time) will crash if it is
165 // deallocated while the animation is currently playing. 161 // deallocated while the animation is currently playing.
166 // Apparently if a tick has been dispatched it will execute, invoking a 162 // Apparently if a tick has been dispatched it will execute, invoking a
167 // method on the deallocated collection. 163 // method on the deallocated collection.
168 // The only purpose of this block is to retain the collection view for a 164 // The only purpose of this block is to retain the collection view for a
169 // while, giving the layout a chance to perform its last tick. 165 // while, giving the layout a chance to perform its last tick.
170 [moi self]; 166 [moi self];
171 }); 167 });
172 _faviconTaskTracker.TryCancelAll(); 168 _faviconTaskTracker.TryCancelAll();
173 [super dealloc];
174 } 169 }
175 170
176 - (void)setupViews { 171 - (void)setupViews {
177 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); 172 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor();
178 base::scoped_nsobject<UICollectionViewFlowLayout> layout( 173 UICollectionViewFlowLayout* layout =
179 [[UICollectionViewFlowLayout alloc] init]); 174 [[UICollectionViewFlowLayout alloc] init];
180 175
181 base::scoped_nsobject<UICollectionView> collectionView( 176 UICollectionView* collectionView =
182 [[UICollectionView alloc] initWithFrame:self.bounds 177 [[UICollectionView alloc] initWithFrame:self.bounds
183 collectionViewLayout:layout]); 178 collectionViewLayout:layout];
184 self.collectionView = collectionView; 179 self.collectionView = collectionView;
185 self.collectionView.backgroundColor = [UIColor clearColor]; 180 self.collectionView.backgroundColor = [UIColor clearColor];
186 self.collectionView.autoresizingMask = 181 self.collectionView.autoresizingMask =
187 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 182 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
188 self.collectionView.alwaysBounceVertical = YES; 183 self.collectionView.alwaysBounceVertical = YES;
189 self.collectionView.delegate = self; 184 self.collectionView.delegate = self;
190 self.collectionView.dataSource = self; 185 self.collectionView.dataSource = self;
191 [self.collectionView registerClass:[BookmarkFolderCell class] 186 [self.collectionView registerClass:[BookmarkFolderCell class]
192 forCellWithReuseIdentifier:[BookmarkFolderCell reuseIdentifier]]; 187 forCellWithReuseIdentifier:[BookmarkFolderCell reuseIdentifier]];
193 [self.collectionView registerClass:[BookmarkItemCell class] 188 [self.collectionView registerClass:[BookmarkItemCell class]
194 forCellWithReuseIdentifier:[BookmarkItemCell reuseIdentifier]]; 189 forCellWithReuseIdentifier:[BookmarkItemCell reuseIdentifier]];
195 [self.collectionView registerClass:[BookmarkHeaderView class] 190 [self.collectionView registerClass:[BookmarkHeaderView class]
196 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader 191 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
197 withReuseIdentifier:[BookmarkHeaderView reuseIdentifier]]; 192 withReuseIdentifier:[BookmarkHeaderView reuseIdentifier]];
198 [self.collectionView 193 [self.collectionView
199 registerClass:[BookmarkHeaderSeparatorView class] 194 registerClass:[BookmarkHeaderSeparatorView class]
200 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader 195 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
201 withReuseIdentifier:[BookmarkHeaderSeparatorView reuseIdentifier]]; 196 withReuseIdentifier:[BookmarkHeaderSeparatorView reuseIdentifier]];
202 [self.collectionView registerClass:[BookmarkPromoCell class] 197 [self.collectionView registerClass:[BookmarkPromoCell class]
203 forCellWithReuseIdentifier:[BookmarkPromoCell reuseIdentifier]]; 198 forCellWithReuseIdentifier:[BookmarkPromoCell reuseIdentifier]];
204 199
205 [self addSubview:self.collectionView]; 200 [self addSubview:self.collectionView];
206 201
207 // Set up the background view shown when the collection is empty. 202 // Set up the background view shown when the collection is empty.
208 base::scoped_nsobject<BookmarkCollectionViewBackground> 203 BookmarkCollectionViewBackground* emptyCollectionBackgroundView =
209 emptyCollectionBackgroundView( 204 [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero];
210 [[BookmarkCollectionViewBackground alloc] initWithFrame:CGRectZero]);
211 self.emptyCollectionBackgroundView = emptyCollectionBackgroundView; 205 self.emptyCollectionBackgroundView = emptyCollectionBackgroundView;
212 self.emptyCollectionBackgroundView.autoresizingMask = 206 self.emptyCollectionBackgroundView.autoresizingMask =
213 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 207 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
214 self.emptyCollectionBackgroundView.alpha = 0; 208 self.emptyCollectionBackgroundView.alpha = 0;
215 self.emptyCollectionBackgroundView.text = [self textWhenCollectionIsEmpty]; 209 self.emptyCollectionBackgroundView.text = [self textWhenCollectionIsEmpty];
216 210
217 self.emptyCollectionBackgroundView.frame = self.collectionView.bounds; 211 self.emptyCollectionBackgroundView.frame = self.collectionView.bounds;
218 self.collectionView.backgroundView = self.emptyCollectionBackgroundView; 212 self.collectionView.backgroundView = self.emptyCollectionBackgroundView;
219 213
220 [self updateShadow]; 214 [self updateShadow];
221 215
222 self.longPressRecognizer = 216 self.longPressRecognizer = [[UILongPressGestureRecognizer alloc]
223 base::scoped_nsobject<UILongPressGestureRecognizer>( 217 initWithTarget:self
224 [[UILongPressGestureRecognizer alloc] 218 action:@selector(longPress:)];
225 initWithTarget:self
226 action:@selector(longPress:)]);
227 self.longPressRecognizer.delegate = self; 219 self.longPressRecognizer.delegate = self;
228 [self.collectionView addGestureRecognizer:self.longPressRecognizer]; 220 [self.collectionView addGestureRecognizer:self.longPressRecognizer];
229 } 221 }
230 222
231 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { 223 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
232 [self updateShadow]; 224 [self updateShadow];
233 } 225 }
234 226
235 - (void)updateShadow { 227 - (void)updateShadow {
236 // Remove the current one, if any. 228 // Remove the current one, if any.
237 [self.shadow removeFromSuperview]; 229 [self.shadow removeFromSuperview];
238 230
239 if (IsCompact(self)) { 231 if (IsCompact(self)) {
240 self.shadow = 232 self.shadow =
241 bookmark_utils_ios::dropShadowWithWidth(CGRectGetWidth(self.bounds)); 233 bookmark_utils_ios::dropShadowWithWidth(CGRectGetWidth(self.bounds));
242 } else { 234 } else {
243 self.shadow = [[[UIView alloc] 235 self.shadow = [[UIView alloc]
244 initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), 236 initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds),
245 1 / [[UIScreen mainScreen] scale])] 237 1 / [[UIScreen mainScreen] scale])];
246 autorelease];
247 self.shadow.backgroundColor = [UIColor colorWithWhite:0.0 alpha:.12]; 238 self.shadow.backgroundColor = [UIColor colorWithWhite:0.0 alpha:.12];
248 } 239 }
249 240
250 [self updateShadowFrame]; 241 [self updateShadowFrame];
251 self.shadow.autoresizingMask = UIViewAutoresizingFlexibleWidth; 242 self.shadow.autoresizingMask = UIViewAutoresizingFlexibleWidth;
252 if (self.editing) 243 if (self.editing)
253 self.shadow.alpha = 0.0; 244 self.shadow.alpha = 0.0;
254 245
255 // Add the new shadow. 246 // Add the new shadow.
256 [self addSubview:self.shadow]; 247 [self addSubview:self.shadow];
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 - (void)cancelLoadingFaviconAtIndexPath:(NSIndexPath*)indexPath { 470 - (void)cancelLoadingFaviconAtIndexPath:(NSIndexPath*)indexPath {
480 _faviconTaskTracker.TryCancel( 471 _faviconTaskTracker.TryCancel(
481 _faviconLoadTasks[IntegerPair(indexPath.section, indexPath.item)]); 472 _faviconLoadTasks[IntegerPair(indexPath.section, indexPath.item)]);
482 } 473 }
483 474
484 - (void)loadFaviconAtIndexPath:(NSIndexPath*)indexPath { 475 - (void)loadFaviconAtIndexPath:(NSIndexPath*)indexPath {
485 // Cancel previous load attempts. 476 // Cancel previous load attempts.
486 [self cancelLoadingFaviconAtIndexPath:indexPath]; 477 [self cancelLoadingFaviconAtIndexPath:indexPath];
487 478
488 // Start loading a favicon. 479 // Start loading a favicon.
489 base::WeakNSObject<BookmarkCollectionView> weakSelf(self); 480 __weak BookmarkCollectionView* weakSelf = self;
490 const bookmarks::BookmarkNode* node = [self nodeAtIndexPath:indexPath]; 481 const bookmarks::BookmarkNode* node = [self nodeAtIndexPath:indexPath];
491 GURL blockURL(node->url()); 482 GURL blockURL(node->url());
492 void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^( 483 void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^(
493 const favicon_base::LargeIconResult& result) { 484 const favicon_base::LargeIconResult& result) {
494 base::scoped_nsobject<BookmarkCollectionView> strongSelf([weakSelf retain]); 485 BookmarkCollectionView* strongSelf = weakSelf;
495 if (!strongSelf) 486 if (!strongSelf)
496 return; 487 return;
497 UIImage* favIcon = nil; 488 UIImage* favIcon = nil;
498 UIColor* backgroundColor = nil; 489 UIColor* backgroundColor = nil;
499 UIColor* textColor = nil; 490 UIColor* textColor = nil;
500 NSString* fallbackText = nil; 491 NSString* fallbackText = nil;
501 if (result.bitmap.is_valid()) { 492 if (result.bitmap.is_valid()) {
502 scoped_refptr<base::RefCountedMemory> data = 493 scoped_refptr<base::RefCountedMemory> data = result.bitmap.bitmap_data;
503 result.bitmap.bitmap_data.get();
504 favIcon = [UIImage imageWithData:[NSData dataWithBytes:data->front() 494 favIcon = [UIImage imageWithData:[NSData dataWithBytes:data->front()
505 length:data->size()]]; 495 length:data->size()]];
506 } else if (result.fallback_icon_style) { 496 } else if (result.fallback_icon_style) {
507 backgroundColor = skia::UIColorFromSkColor( 497 backgroundColor = skia::UIColorFromSkColor(
508 result.fallback_icon_style->background_color); 498 result.fallback_icon_style->background_color);
509 textColor = 499 textColor =
510 skia::UIColorFromSkColor(result.fallback_icon_style->text_color); 500 skia::UIColorFromSkColor(result.fallback_icon_style->text_color);
511 501
512 fallbackText = 502 fallbackText =
513 base::SysUTF16ToNSString(favicon::GetFallbackIconText(blockURL)); 503 base::SysUTF16ToNSString(favicon::GetFallbackIconText(blockURL));
514 } 504 }
515 505
516 [strongSelf updateCellAtIndexPath:indexPath 506 [strongSelf updateCellAtIndexPath:indexPath
517 withImage:favIcon 507 withImage:favIcon
518 backgroundColor:backgroundColor 508 backgroundColor:backgroundColor
519 textColor:textColor 509 textColor:textColor
520 fallbackText:fallbackText]; 510 fallbackText:fallbackText];
521 }; 511 };
522 512
523 CGFloat scale = [UIScreen mainScreen].scale; 513 CGFloat scale = [UIScreen mainScreen].scale;
524 CGFloat preferredSize = scale * [BookmarkItemCell preferredImageSize]; 514 CGFloat preferredSize = scale * [BookmarkItemCell preferredImageSize];
525 CGFloat minSize = scale * minFaviconSizePt; 515 CGFloat minSize = scale * minFaviconSizePt;
526 516
527 base::CancelableTaskTracker::TaskId taskId = 517 base::CancelableTaskTracker::TaskId taskId =
528 IOSChromeLargeIconServiceFactory::GetForBrowserState(self.browserState) 518 IOSChromeLargeIconServiceFactory::GetForBrowserState(self.browserState)
529 ->GetLargeIconOrFallbackStyle(node->url(), minSize, preferredSize, 519 ->GetLargeIconOrFallbackStyle(node->url(), minSize, preferredSize,
530 base::BindBlock(faviconBlock), 520 base::BindBlockArc(faviconBlock),
531 &_faviconTaskTracker); 521 &_faviconTaskTracker);
532 _faviconLoadTasks[IntegerPair(indexPath.section, indexPath.item)] = taskId; 522 _faviconLoadTasks[IntegerPair(indexPath.section, indexPath.item)] = taskId;
533 } 523 }
534 524
535 - (BookmarkFolderCell*)cellForFolder:(const BookmarkNode*)node 525 - (BookmarkFolderCell*)cellForFolder:(const BookmarkNode*)node
536 indexPath:(NSIndexPath*)indexPath { 526 indexPath:(NSIndexPath*)indexPath {
537 DCHECK(![self isPromoSection:indexPath.section]); 527 DCHECK(![self isPromoSection:indexPath.section]);
538 BookmarkFolderCell* cell = [self.collectionView 528 BookmarkFolderCell* cell = [self.collectionView
539 dequeueReusableCellWithReuseIdentifier:[BookmarkFolderCell 529 dequeueReusableCellWithReuseIdentifier:[BookmarkFolderCell
540 reuseIdentifier] 530 reuseIdentifier]
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 return UIEdgeInsetsZero; 684 return UIEdgeInsetsZero;
695 } 685 }
696 } 686 }
697 687
698 - (CGSize)cellSizeForIndexPath:(NSIndexPath*)indexPath { 688 - (CGSize)cellSizeForIndexPath:(NSIndexPath*)indexPath {
699 if ([self isPromoSection:indexPath.section]) { 689 if ([self isPromoSection:indexPath.section]) {
700 CGRect estimatedFrame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), 100); 690 CGRect estimatedFrame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), 100);
701 UICollectionViewCell* cell = 691 UICollectionViewCell* cell =
702 [self.collectionView cellForItemAtIndexPath:indexPath]; 692 [self.collectionView cellForItemAtIndexPath:indexPath];
703 if (!cell) { 693 if (!cell) {
704 cell = [[[BookmarkPromoCell alloc] initWithFrame:estimatedFrame] 694 cell = [[BookmarkPromoCell alloc] initWithFrame:estimatedFrame];
705 autorelease];
706 } 695 }
707 cell.frame = estimatedFrame; 696 cell.frame = estimatedFrame;
708 [cell layoutIfNeeded]; 697 [cell layoutIfNeeded];
709 return [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; 698 return [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
710 } 699 }
711 700
712 UIEdgeInsets insets = [self insetForSectionAtIndex:indexPath.section]; 701 UIEdgeInsets insets = [self insetForSectionAtIndex:indexPath.section];
713 return CGSizeMake(self.bounds.size.width - (insets.right + insets.left), 702 return CGSizeMake(self.bounds.size.width - (insets.right + insets.left),
714 rowHeight); 703 rowHeight);
715 } 704 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 839
851 - (BOOL)shouldShowPromoCell { 840 - (BOOL)shouldShowPromoCell {
852 return NO; 841 return NO;
853 } 842 }
854 843
855 - (BOOL)isPromoActive { 844 - (BOOL)isPromoActive {
856 return NO; 845 return NO;
857 } 846 }
858 847
859 @end 848 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698