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

Side by Side Diff: ios/chrome/browser/ui/history/history_collection_view_controller.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 #include "ios/chrome/browser/ui/history/history_collection_view_controller.h" 5 #include "ios/chrome/browser/ui/history/history_collection_view_controller.h"
6 6
7 #import <MobileCoreServices/MobileCoreServices.h> 7 #import <MobileCoreServices/MobileCoreServices.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #import "base/ios/weak_nsobject.h" 11 #import "base/ios/weak_nsobject.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #import "base/mac/objc_property_releaser.h" 13 #include "base/mac/objc_release_properties.h"
14 #include "base/mac/scoped_nsobject.h" 14 #include "base/mac/scoped_nsobject.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "components/browsing_data/core/history_notice_utils.h" 17 #include "components/browsing_data/core/history_notice_utils.h"
18 #include "components/strings/grit/components_strings.h" 18 #include "components/strings/grit/components_strings.h"
19 #include "components/url_formatter/url_formatter.h" 19 #include "components/url_formatter/url_formatter.h"
20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
21 #include "ios/chrome/browser/chrome_url_constants.h" 21 #include "ios/chrome/browser/chrome_url_constants.h"
22 #import "ios/chrome/browser/signin/authentication_service.h" 22 #import "ios/chrome/browser/signin/authentication_service.h"
23 #include "ios/chrome/browser/signin/authentication_service_factory.h" 23 #include "ios/chrome/browser/signin/authentication_service_factory.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Maximum number of entries to retrieve in a single query to history service. 57 // Maximum number of entries to retrieve in a single query to history service.
58 const int kMaxFetchCount = 100; 58 const int kMaxFetchCount = 100;
59 // Horizontal inset for item separators. 59 // Horizontal inset for item separators.
60 const CGFloat kSeparatorInset = 10; 60 const CGFloat kSeparatorInset = 10;
61 } 61 }
62 62
63 @interface HistoryCollectionViewController ()<HistoryEntriesStatusItemDelegate, 63 @interface HistoryCollectionViewController ()<HistoryEntriesStatusItemDelegate,
64 HistoryEntryInserterDelegate, 64 HistoryEntryInserterDelegate,
65 HistoryEntryItemDelegate, 65 HistoryEntryItemDelegate,
66 HistoryServiceFacadeDelegate> { 66 HistoryServiceFacadeDelegate> {
67 base::mac::ObjCPropertyReleaser
68 _propertyReleaser_HistoryCollectionViewController;
69 // Facade for communicating with HistoryService and WebHistoryService. 67 // Facade for communicating with HistoryService and WebHistoryService.
70 std::unique_ptr<HistoryServiceFacade> _historyServiceFacade; 68 std::unique_ptr<HistoryServiceFacade> _historyServiceFacade;
71 // The main browser state. Not owned by HistoryCollectionViewController. 69 // The main browser state. Not owned by HistoryCollectionViewController.
72 ios::ChromeBrowserState* _browserState; 70 ios::ChromeBrowserState* _browserState;
73 // Backing ivar for delegate property. 71 // Backing ivar for delegate property.
74 base::WeakNSProtocol<id<HistoryCollectionViewControllerDelegate>> _delegate; 72 base::WeakNSProtocol<id<HistoryCollectionViewControllerDelegate>> _delegate;
75 // Backing ivar for URLLoader property. 73 // Backing ivar for URLLoader property.
76 base::WeakNSProtocol<id<UrlLoader>> _URLLoader; 74 base::WeakNSProtocol<id<UrlLoader>> _URLLoader;
77 } 75 }
78 76
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 @synthesize loading = _loading; 140 @synthesize loading = _loading;
143 @synthesize finishedLoading = _finishedLoading; 141 @synthesize finishedLoading = _finishedLoading;
144 @synthesize filterQueryResult = _filterQueryResult; 142 @synthesize filterQueryResult = _filterQueryResult;
145 143
146 - (instancetype)initWithLoader:(id<UrlLoader>)loader 144 - (instancetype)initWithLoader:(id<UrlLoader>)loader
147 browserState:(ios::ChromeBrowserState*)browserState 145 browserState:(ios::ChromeBrowserState*)browserState
148 delegate:(id<HistoryCollectionViewControllerDelegate>) 146 delegate:(id<HistoryCollectionViewControllerDelegate>)
149 delegate { 147 delegate {
150 self = [super initWithStyle:CollectionViewControllerStyleDefault]; 148 self = [super initWithStyle:CollectionViewControllerStyleDefault];
151 if (self) { 149 if (self) {
152 _propertyReleaser_HistoryCollectionViewController.Init(
153 self, [HistoryCollectionViewController class]);
154 _historyServiceFacade.reset(new HistoryServiceFacade(browserState, self)); 150 _historyServiceFacade.reset(new HistoryServiceFacade(browserState, self));
155 _browserState = browserState; 151 _browserState = browserState;
156 _delegate.reset(delegate); 152 _delegate.reset(delegate);
157 _URLLoader.reset(loader); 153 _URLLoader.reset(loader);
158 [self loadModel]; 154 [self loadModel];
159 // Add initial info section as header. 155 // Add initial info section as header.
160 [self.collectionViewModel 156 [self.collectionViewModel
161 addSectionWithIdentifier:kEntriesStatusSectionIdentifier]; 157 addSectionWithIdentifier:kEntriesStatusSectionIdentifier];
162 _entryInserter = 158 _entryInserter =
163 [[HistoryEntryInserter alloc] initWithModel:self.collectionViewModel]; 159 [[HistoryEntryInserter alloc] initWithModel:self.collectionViewModel];
164 _entryInserter.delegate = self; 160 _entryInserter.delegate = self;
165 _entriesType = NO_ENTRIES; 161 _entriesType = NO_ENTRIES;
166 [self showHistoryMatchingQuery:nil]; 162 [self showHistoryMatchingQuery:nil];
167 } 163 }
168 return self; 164 return self;
169 } 165 }
170 166
167 - (void)dealloc {
168 base::mac::ReleaseProperties(self);
169 [super dealloc];
170 }
171
171 - (void)viewDidLoad { 172 - (void)viewDidLoad {
172 [super viewDidLoad]; 173 [super viewDidLoad];
173 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList; 174 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList;
174 self.styler.separatorInset = 175 self.styler.separatorInset =
175 UIEdgeInsetsMake(0, kSeparatorInset, 0, kSeparatorInset); 176 UIEdgeInsetsMake(0, kSeparatorInset, 0, kSeparatorInset);
176 self.styler.allowsItemInlay = NO; 177 self.styler.allowsItemInlay = NO;
177 178
178 self.clearsSelectionOnViewWillAppear = NO; 179 self.clearsSelectionOnViewWillAppear = NO;
179 self.collectionView.keyboardDismissMode = 180 self.collectionView.keyboardDismissMode =
180 UIScrollViewKeyboardDismissModeOnDrag; 181 UIScrollViewKeyboardDismissModeOnDrag;
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 NSData* plainText = [base::SysUTF8ToNSString(URL.spec()) 809 NSData* plainText = [base::SysUTF8ToNSString(URL.spec())
809 dataUsingEncoding:NSUTF8StringEncoding]; 810 dataUsingEncoding:NSUTF8StringEncoding];
810 NSDictionary* copiedItem = @{ 811 NSDictionary* copiedItem = @{
811 (NSString*)kUTTypeURL : net::NSURLWithGURL(URL), 812 (NSString*)kUTTypeURL : net::NSURLWithGURL(URL),
812 (NSString*)kUTTypeUTF8PlainText : plainText, 813 (NSString*)kUTTypeUTF8PlainText : plainText,
813 }; 814 };
814 [[UIPasteboard generalPasteboard] setItems:@[ copiedItem ]]; 815 [[UIPasteboard generalPasteboard] setItems:@[ copiedItem ]];
815 } 816 }
816 817
817 @end 818 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698