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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_all_collection_view.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Yank unrelated changes. Created 3 years, 10 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_all_collection_view.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_all_collection_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/objc_property_releaser.h" 11 #include "base/mac/objc_release_properties.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "components/bookmarks/browser/bookmark_model.h" 14 #include "components/bookmarks/browser/bookmark_model.h"
15 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" 15 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h"
16 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h" 16 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h"
17 #include "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" 17 #include "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h"
18 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 18 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/models/tree_node_iterator.h" 20 #include "ui/base/models/tree_node_iterator.h"
21 21
(...skipping 15 matching lines...) Expand all
37 // This enum tracks the state of the refresh. See -collectionViewNeedsUpdate 37 // This enum tracks the state of the refresh. See -collectionViewNeedsUpdate
38 // for the state machine. 38 // for the state machine.
39 typedef enum { kNoUpdate = 0, kOneUpdateDone, kUpdateScheduled } UpdateState; 39 typedef enum { kNoUpdate = 0, kOneUpdateDone, kUpdateScheduled } UpdateState;
40 } // namespace 40 } // namespace
41 41
42 @interface BookmarkAllCollectionView ()<BookmarkPromoCellDelegate> { 42 @interface BookmarkAllCollectionView ()<BookmarkPromoCellDelegate> {
43 // A vector of vectors. Url nodes are segregated by month of creation. 43 // A vector of vectors. Url nodes are segregated by month of creation.
44 std::vector<std::unique_ptr<NodesSection>> _nodesSectionVector; 44 std::vector<std::unique_ptr<NodesSection>> _nodesSectionVector;
45 // To avoid refreshing the internal model too often. 45 // To avoid refreshing the internal model too often.
46 UpdateState _updateScheduled; 46 UpdateState _updateScheduled;
47 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkAllCollectionView;
48 } 47 }
49 48
50 // Keep a reference to the promo cell to deregister as delegate. 49 // Keep a reference to the promo cell to deregister as delegate.
51 @property(nonatomic, retain) BookmarkPromoCell* promoCell; 50 @property(nonatomic, retain) BookmarkPromoCell* promoCell;
52 51
53 // Triggers an update of the collection, but delayed in order to coallesce a lot 52 // Triggers an update of the collection, but delayed in order to coallesce a lot
54 // of events into one update. 53 // of events into one update.
55 - (void)collectionViewNeedsUpdate; 54 - (void)collectionViewNeedsUpdate;
56 55
57 @end 56 @end
58 57
59 @implementation BookmarkAllCollectionView 58 @implementation BookmarkAllCollectionView
60 59
61 @synthesize delegate = _delegate; 60 @synthesize delegate = _delegate;
62 @synthesize promoCell = _promoCell; 61 @synthesize promoCell = _promoCell;
63 62
64 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState 63 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
65 frame:(CGRect)frame { 64 frame:(CGRect)frame {
66 self = [super initWithBrowserState:browserState frame:frame]; 65 self = [super initWithBrowserState:browserState frame:frame];
67 if (self) { 66 if (self) {
68 _propertyReleaser_BookmarkAllCollectionView.Init(
69 self, [BookmarkAllCollectionView class]);
70 self.accessibilityIdentifier = @"bookmark_all_collection_view"; 67 self.accessibilityIdentifier = @"bookmark_all_collection_view";
71 [self updateCollectionView]; 68 [self updateCollectionView];
72 } 69 }
73 return self; 70 return self;
74 } 71 }
75 72
76 - (void)dealloc { 73 - (void)dealloc {
77 _promoCell.delegate = nil; 74 _promoCell.delegate = nil;
75 base::mac::ReleaseProperties(self);
78 [super dealloc]; 76 [super dealloc];
79 } 77 }
80 78
81 - (void)updateCollectionView { 79 - (void)updateCollectionView {
82 if (!self.bookmarkModel->loaded()) 80 if (!self.bookmarkModel->loaded())
83 return; 81 return;
84 82
85 // Regenerate the list of all bookmarks. 83 // Regenerate the list of all bookmarks.
86 NodeVector allItems; 84 NodeVector allItems;
87 ui::TreeNodeIterator<const BookmarkNode> iterator( 85 ui::TreeNodeIterator<const BookmarkNode> iterator(
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 - (BOOL)isPromoActive { 406 - (BOOL)isPromoActive {
409 return [self.delegate bookmarkCollectionViewShouldShowPromoCell:self]; 407 return [self.delegate bookmarkCollectionViewShouldShowPromoCell:self];
410 } 408 }
411 409
412 - (BOOL)shouldShowPromoCell { 410 - (BOOL)shouldShowPromoCell {
413 // The promo cell is not shown in edit mode. 411 // The promo cell is not shown in edit mode.
414 return !self.editing && [self isPromoActive]; 412 return !self.editing && [self isPromoActive];
415 } 413 }
416 414
417 @end 415 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698