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

Side by Side Diff: ios/chrome/browser/ui/history/history_entry_item.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: weak -> assign Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/history/history_entry_item.h" 5 #import "ios/chrome/browser/ui/history/history_entry_item.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/ios/weak_nsobject.h" 8 #include "base/ios/weak_nsobject.h"
9 #import "base/mac/foundation_util.h" 9 #import "base/mac/foundation_util.h"
10 #import "base/mac/objc_property_releaser.h" 10 #include "base/mac/objc_release_properties.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/history/core/browser/url_row.h" 13 #include "components/history/core/browser/url_row.h"
14 #include "components/strings/grit/components_strings.h" 14 #include "components/strings/grit/components_strings.h"
15 #include "components/url_formatter/url_formatter.h" 15 #include "components/url_formatter/url_formatter.h"
16 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" 16 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
17 #import "ios/chrome/browser/ui/history/favicon_view.h" 17 #import "ios/chrome/browser/ui/history/favicon_view.h"
18 #import "ios/chrome/browser/ui/history/favicon_view_provider.h" 18 #import "ios/chrome/browser/ui/history/favicon_view_provider.h"
19 #import "ios/chrome/browser/ui/history/history_entry.h" 19 #import "ios/chrome/browser/ui/history/history_entry.h"
20 #include "ios/chrome/browser/ui/rtl_geometry.h" 20 #include "ios/chrome/browser/ui/rtl_geometry.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 else 52 else
53 base::i18n::AdjustStringForLocaleDirection(&formatted_title); 53 base::i18n::AdjustStringForLocaleDirection(&formatted_title);
54 } 54 }
55 return base::SysUTF16ToNSString(formatted_title); 55 return base::SysUTF16ToNSString(formatted_title);
56 } 56 }
57 } // namespace 57 } // namespace
58 58
59 #pragma mark - HistoryEntryItem 59 #pragma mark - HistoryEntryItem
60 60
61 @interface HistoryEntryItem ()<FaviconViewProviderDelegate> { 61 @interface HistoryEntryItem ()<FaviconViewProviderDelegate> {
62 // Property releaser for HistoryEntryItem.
63 base::mac::ObjCPropertyReleaser _propertyReleaser_HistoryEntryItem;
64 // Delegate for HistoryEntryItem. 62 // Delegate for HistoryEntryItem.
65 base::WeakNSProtocol<id<HistoryEntryItemDelegate>> _delegate; 63 base::WeakNSProtocol<id<HistoryEntryItemDelegate>> _delegate;
66 } 64 }
67 65
68 // FaviconViewProvider to fetch the favicon and format the favicon view. 66 // FaviconViewProvider to fetch the favicon and format the favicon view.
69 @property(nonatomic, retain) FaviconViewProvider* faviconViewProvider; 67 @property(nonatomic, retain) FaviconViewProvider* faviconViewProvider;
70 68
71 // Custom accessibility actions for the history entry view. 69 // Custom accessibility actions for the history entry view.
72 - (NSArray*)accessibilityActions; 70 - (NSArray*)accessibilityActions;
73 // Custom accessibility action to delete the history entry. 71 // Custom accessibility action to delete the history entry.
(...skipping 15 matching lines...) Expand all
89 @synthesize timeText = _timeText; 87 @synthesize timeText = _timeText;
90 @synthesize URL = _URL; 88 @synthesize URL = _URL;
91 @synthesize timestamp = _timestamp; 89 @synthesize timestamp = _timestamp;
92 90
93 - (instancetype)initWithType:(NSInteger)type 91 - (instancetype)initWithType:(NSInteger)type
94 historyEntry:(const history::HistoryEntry&)entry 92 historyEntry:(const history::HistoryEntry&)entry
95 browserState:(ios::ChromeBrowserState*)browserState 93 browserState:(ios::ChromeBrowserState*)browserState
96 delegate:(id<HistoryEntryItemDelegate>)delegate { 94 delegate:(id<HistoryEntryItemDelegate>)delegate {
97 self = [super initWithType:type]; 95 self = [super initWithType:type];
98 if (self) { 96 if (self) {
99 _propertyReleaser_HistoryEntryItem.Init(self, [HistoryEntryItem class]);
100 self.cellClass = [HistoryEntryCell class]; 97 self.cellClass = [HistoryEntryCell class];
101 favicon::LargeIconService* largeIconService = 98 favicon::LargeIconService* largeIconService =
102 IOSChromeLargeIconServiceFactory::GetForBrowserState(browserState); 99 IOSChromeLargeIconServiceFactory::GetForBrowserState(browserState);
103 _faviconViewProvider = 100 _faviconViewProvider =
104 [[FaviconViewProvider alloc] initWithURL:entry.url 101 [[FaviconViewProvider alloc] initWithURL:entry.url
105 faviconSize:kFaviconSize 102 faviconSize:kFaviconSize
106 minFaviconSize:kMinFaviconSize 103 minFaviconSize:kMinFaviconSize
107 largeIconService:largeIconService 104 largeIconService:largeIconService
108 delegate:self]; 105 delegate:self];
109 _text = [FormattedTitle(entry.title, entry.url) copy]; 106 _text = [FormattedTitle(entry.title, entry.url) copy];
110 _detailText = [base::SysUTF8ToNSString(entry.url.spec()) copy]; 107 _detailText = [base::SysUTF8ToNSString(entry.url.spec()) copy];
111 _timeText = 108 _timeText =
112 [base::SysUTF16ToNSString(base::TimeFormatTimeOfDay(entry.time)) copy]; 109 [base::SysUTF16ToNSString(base::TimeFormatTimeOfDay(entry.time)) copy];
113 _URL = GURL(entry.url); 110 _URL = GURL(entry.url);
114 _timestamp = entry.time; 111 _timestamp = entry.time;
115 _delegate.reset(delegate); 112 _delegate.reset(delegate);
116 } 113 }
117 return self; 114 return self;
118 } 115 }
119 116
117 - (void)dealloc {
118 base::mac::ReleaseProperties(self);
119 [super dealloc];
120 }
121
120 - (instancetype)initWithType:(NSInteger)type { 122 - (instancetype)initWithType:(NSInteger)type {
121 NOTREACHED(); 123 NOTREACHED();
122 return nil; 124 return nil;
123 } 125 }
124 126
125 - (BOOL)isEqualToHistoryEntryItem:(HistoryEntryItem*)item { 127 - (BOOL)isEqualToHistoryEntryItem:(HistoryEntryItem*)item {
126 return item && item.URL == _URL && item.timestamp == _timestamp; 128 return item && item.URL == _URL && item.timestamp == _timestamp;
127 } 129 }
128 130
129 - (BOOL)isEqual:(id)object { 131 - (BOOL)isEqual:(id)object {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 215 }
214 216
215 - (void)faviconViewProviderFaviconDidLoad:(FaviconViewProvider*)provider { 217 - (void)faviconViewProviderFaviconDidLoad:(FaviconViewProvider*)provider {
216 [_delegate historyEntryItemShouldUpdateView:self]; 218 [_delegate historyEntryItemShouldUpdateView:self];
217 } 219 }
218 220
219 @end 221 @end
220 222
221 #pragma mark - HistoryEntryCell 223 #pragma mark - HistoryEntryCell
222 224
223 @interface HistoryEntryCell () {
224 // Property releaser for HistoryEntryCell.
225 base::mac::ObjCPropertyReleaser _propertyReleaser_HistoryEntryCell;
226 }
227
228 // Redeclare as readwrite to allow property releaser to handle these properties.
229 @property(nonatomic, readwrite, retain) UILabel* textLabel;
230 @property(nonatomic, readwrite, retain) UILabel* detailTextLabel;
231 @property(nonatomic, readwrite, retain) UILabel* timeLabel;
Sidney San Martín 2017/01/05 03:24:05 This pattern of redeclaring properties as readwrit
noyau (Ping after 24h) 2017/01/05 10:02:52 At some point the property releaser had a bug (inh
232 @end
233
234 @implementation HistoryEntryCell 225 @implementation HistoryEntryCell
235 226
236 @synthesize faviconViewContainer = _faviconViewContainer; 227 @synthesize faviconViewContainer = _faviconViewContainer;
237 @synthesize textLabel = _textLabel; 228 @synthesize textLabel = _textLabel;
238 @synthesize detailTextLabel = _detailTextLabel; 229 @synthesize detailTextLabel = _detailTextLabel;
239 @synthesize timeLabel = _timeLabel; 230 @synthesize timeLabel = _timeLabel;
240 231
241 - (id)initWithFrame:(CGRect)frame { 232 - (id)initWithFrame:(CGRect)frame {
242 self = [super initWithFrame:frame]; 233 self = [super initWithFrame:frame];
243 if (self) { 234 if (self) {
244 _propertyReleaser_HistoryEntryCell.Init(self, [HistoryEntryCell class]);
245
246 _faviconViewContainer = [[UIView alloc] initWithFrame:CGRectZero]; 235 _faviconViewContainer = [[UIView alloc] initWithFrame:CGRectZero];
247 236
248 _textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 237 _textLabel = [[UILabel alloc] initWithFrame:CGRectZero];
249 [_textLabel 238 [_textLabel
250 setFont:[[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:16]]; 239 setFont:[[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:16]];
251 [_textLabel setTextColor:[[MDCPalette greyPalette] tint900]]; 240 [_textLabel setTextColor:[[MDCPalette greyPalette] tint900]];
252 241
253 _detailTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 242 _detailTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
254 [_detailTextLabel 243 [_detailTextLabel
255 setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]]; 244 setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 AddSameCenterYConstraint(_faviconViewContainer, _textLabel); 284 AddSameCenterYConstraint(_faviconViewContainer, _textLabel);
296 285
297 [_timeLabel 286 [_timeLabel
298 setContentCompressionResistancePriority:UILayoutPriorityRequired 287 setContentCompressionResistancePriority:UILayoutPriorityRequired
299 forAxis: 288 forAxis:
300 UILayoutConstraintAxisHorizontal]; 289 UILayoutConstraintAxisHorizontal];
301 } 290 }
302 return self; 291 return self;
303 } 292 }
304 293
294 - (void)dealloc {
295 base::mac::ReleaseProperties(self);
296 [super dealloc];
297 }
298
305 - (void)prepareForReuse { 299 - (void)prepareForReuse {
306 [super prepareForReuse]; 300 [super prepareForReuse];
307 _textLabel.text = nil; 301 _textLabel.text = nil;
308 _detailTextLabel.text = nil; 302 _detailTextLabel.text = nil;
309 _timeLabel.text = nil; 303 _timeLabel.text = nil;
310 for (UIView* subview in _faviconViewContainer.subviews) { 304 for (UIView* subview in _faviconViewContainer.subviews) {
311 [subview removeFromSuperview]; 305 [subview removeFromSuperview];
312 } 306 }
313 } 307 }
314 308
315 @end 309 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698