OLD | NEW |
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_folder_collection_view.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_folder_collection_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/objc_property_releaser.h" | |
9 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
10 #include "components/bookmarks/browser/bookmark_model.h" | 9 #include "components/bookmarks/browser/bookmark_model.h" |
11 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" | 10 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" |
12 #include "ios/chrome/browser/experimental_flags.h" | 11 #include "ios/chrome/browser/experimental_flags.h" |
13 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h" | 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h" |
14 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" | 13 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" |
15 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 14 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
16 | 15 |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 17 #error "This file requires ARC support." |
| 18 #endif |
| 19 |
17 using bookmarks::BookmarkNode; | 20 using bookmarks::BookmarkNode; |
18 | 21 |
19 @interface BookmarkFolderCollectionView ()<BookmarkPromoCellDelegate> { | 22 @interface BookmarkFolderCollectionView ()<BookmarkPromoCellDelegate> { |
20 base::mac::ObjCPropertyReleaser | |
21 _propertyReleaser_BookmarkFolderCollectionView; | |
22 // A vector of folders to display in the collection view. | 23 // A vector of folders to display in the collection view. |
23 std::vector<const BookmarkNode*> _subFolders; | 24 std::vector<const BookmarkNode*> _subFolders; |
24 // A vector of bookmark urls to display in the collection view. | 25 // A vector of bookmark urls to display in the collection view. |
25 std::vector<const BookmarkNode*> _subItems; | 26 std::vector<const BookmarkNode*> _subItems; |
26 | 27 |
27 // True if the promo is visible. | 28 // True if the promo is visible. |
28 BOOL _promoVisible; | 29 BOOL _promoVisible; |
29 } | 30 } |
30 @property(nonatomic, assign) const bookmarks::BookmarkNode* folder; | 31 @property(nonatomic, assign) const bookmarks::BookmarkNode* folder; |
31 | 32 |
32 // Section indices. | 33 // Section indices. |
33 @property(nonatomic, readonly, assign) NSInteger promoSection; | 34 @property(nonatomic, readonly, assign) NSInteger promoSection; |
34 @property(nonatomic, readonly, assign) NSInteger folderSection; | 35 @property(nonatomic, readonly, assign) NSInteger folderSection; |
35 @property(nonatomic, readonly, assign) NSInteger itemsSection; | 36 @property(nonatomic, readonly, assign) NSInteger itemsSection; |
36 @property(nonatomic, readonly, assign) NSInteger sectionCount; | 37 @property(nonatomic, readonly, assign) NSInteger sectionCount; |
37 | 38 |
38 // Keep a reference to the promo cell to deregister as delegate. | 39 // Keep a reference to the promo cell to deregister as delegate. |
39 @property(nonatomic, retain) BookmarkPromoCell* promoCell; | 40 @property(nonatomic, strong) BookmarkPromoCell* promoCell; |
40 | 41 |
41 @end | 42 @end |
42 | 43 |
43 @implementation BookmarkFolderCollectionView | 44 @implementation BookmarkFolderCollectionView |
44 @synthesize delegate = _delegate; | 45 @synthesize delegate = _delegate; |
45 @synthesize folder = _folder; | 46 @synthesize folder = _folder; |
46 @synthesize promoCell = _promoCell; | 47 @synthesize promoCell = _promoCell; |
47 | 48 |
48 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState | 49 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
49 frame:(CGRect)frame { | 50 frame:(CGRect)frame { |
50 self = [super initWithBrowserState:browserState frame:frame]; | 51 self = [super initWithBrowserState:browserState frame:frame]; |
51 if (self) { | 52 if (self) { |
52 _propertyReleaser_BookmarkFolderCollectionView.Init( | |
53 self, [BookmarkFolderCollectionView class]); | |
54 | |
55 [self updateCollectionView]; | 53 [self updateCollectionView]; |
56 } | 54 } |
57 return self; | 55 return self; |
58 } | 56 } |
59 | 57 |
60 - (void)dealloc { | 58 - (void)dealloc { |
61 _promoCell.delegate = nil; | 59 _promoCell.delegate = nil; |
62 [super dealloc]; | |
63 } | 60 } |
64 | 61 |
65 - (void)setDelegate:(id<BookmarkFolderCollectionViewDelegate>)delegate { | 62 - (void)setDelegate:(id<BookmarkFolderCollectionViewDelegate>)delegate { |
66 _delegate = delegate; | 63 _delegate = delegate; |
67 [self promoStateChangedAnimated:NO]; | 64 [self promoStateChangedAnimated:NO]; |
68 } | 65 } |
69 | 66 |
70 - (NSInteger)promoSection { | 67 - (NSInteger)promoSection { |
71 return [self shouldShowPromoCell] ? 0 : -1; | 68 return [self shouldShowPromoCell] ? 0 : -1; |
72 } | 69 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 [self.delegate bookmarkCollectionViewDismissPromo:self]; | 459 [self.delegate bookmarkCollectionViewDismissPromo:self]; |
463 } | 460 } |
464 | 461 |
465 #pragma mark - Promo Cell | 462 #pragma mark - Promo Cell |
466 | 463 |
467 - (BOOL)shouldShowPromoCell { | 464 - (BOOL)shouldShowPromoCell { |
468 return _promoVisible; | 465 return _promoVisible; |
469 } | 466 } |
470 | 467 |
471 @end | 468 @end |
OLD | NEW |