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

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

Issue 2761263003: Allow CollectionViewModel/Controller queries without SectionIdentifier (Closed)
Patch Set: Cleanup Created 3 years, 7 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
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 [self openURL:item.URL]; 278 [self openURL:item.URL];
279 } 279 }
280 280
281 - (void)historyEntryItemDidRequestDelete:(HistoryEntryItem*)item { 281 - (void)historyEntryItemDidRequestDelete:(HistoryEntryItem*)item {
282 NSInteger sectionIdentifier = 282 NSInteger sectionIdentifier =
283 [self.entryInserter sectionIdentifierForTimestamp:item.timestamp]; 283 [self.entryInserter sectionIdentifierForTimestamp:item.timestamp];
284 if ([self.collectionViewModel 284 if ([self.collectionViewModel
285 hasSectionForSectionIdentifier:sectionIdentifier] && 285 hasSectionForSectionIdentifier:sectionIdentifier] &&
286 [self.collectionViewModel hasItem:item 286 [self.collectionViewModel hasItem:item
287 inSectionWithIdentifier:sectionIdentifier]) { 287 inSectionWithIdentifier:sectionIdentifier]) {
288 NSIndexPath* indexPath = 288 NSIndexPath* indexPath = [self.collectionViewModel indexPathForItem:item];
289 [self.collectionViewModel indexPathForItem:item
290 inSectionWithIdentifier:sectionIdentifier];
291 [self.collectionView 289 [self.collectionView
292 selectItemAtIndexPath:indexPath 290 selectItemAtIndexPath:indexPath
293 animated:NO 291 animated:NO
294 scrollPosition:UICollectionViewScrollPositionNone]; 292 scrollPosition:UICollectionViewScrollPositionNone];
295 [self deleteSelectedItemsFromHistory]; 293 [self deleteSelectedItemsFromHistory];
296 } 294 }
297 } 295 }
298 296
299 - (void)historyEntryItemDidRequestCopy:(HistoryEntryItem*)item { 297 - (void)historyEntryItemDidRequestCopy:(HistoryEntryItem*)item {
300 StoreURLInPasteboard(item.URL); 298 StoreURLInPasteboard(item.URL);
301 } 299 }
302 300
303 - (void)historyEntryItemDidRequestOpenInNewTab:(HistoryEntryItem*)item { 301 - (void)historyEntryItemDidRequestOpenInNewTab:(HistoryEntryItem*)item {
304 [self openURLInNewTab:item.URL]; 302 [self openURLInNewTab:item.URL];
305 } 303 }
306 304
307 - (void)historyEntryItemDidRequestOpenInNewIncognitoTab: 305 - (void)historyEntryItemDidRequestOpenInNewIncognitoTab:
308 (HistoryEntryItem*)item { 306 (HistoryEntryItem*)item {
309 [self openURLInNewIncognitoTab:item.URL]; 307 [self openURLInNewIncognitoTab:item.URL];
310 } 308 }
311 309
312 - (void)historyEntryItemShouldUpdateView:(HistoryEntryItem*)item { 310 - (void)historyEntryItemShouldUpdateView:(HistoryEntryItem*)item {
313 NSInteger sectionIdentifier = 311 NSInteger sectionIdentifier =
314 [self.entryInserter sectionIdentifierForTimestamp:item.timestamp]; 312 [self.entryInserter sectionIdentifierForTimestamp:item.timestamp];
315 // If the item is still in the model, reconfigure it. 313 // If the item is still in the model, reconfigure it.
316 if ([self.collectionViewModel 314 if ([self.collectionViewModel
317 hasSectionForSectionIdentifier:sectionIdentifier] && 315 hasSectionForSectionIdentifier:sectionIdentifier] &&
318 [self.collectionViewModel hasItem:item 316 [self.collectionViewModel hasItem:item
319 inSectionWithIdentifier:sectionIdentifier]) { 317 inSectionWithIdentifier:sectionIdentifier]) {
320 [self 318 [self reconfigureCellsForItems:@[ item ]];
321 reconfigureCellsForItems:@[ item ]
322 inSectionWithIdentifier:
323 [self.entryInserter sectionIdentifierForTimestamp:item.timestamp]];
324 } 319 }
325 } 320 }
326 321
327 #pragma mark - HistoryServiceFacadeDelegate 322 #pragma mark - HistoryServiceFacadeDelegate
328 323
329 - (void)historyServiceFacade:(HistoryServiceFacade*)facade 324 - (void)historyServiceFacade:(HistoryServiceFacade*)facade
330 didReceiveQueryResult:(HistoryServiceFacade::QueryResult)result { 325 didReceiveQueryResult:(HistoryServiceFacade::QueryResult)result {
331 self.loading = NO; 326 self.loading = NO;
332 // If history sync is enabled and there hasn't been a response from synced 327 // If history sync is enabled and there hasn't been a response from synced
333 // history, try fetching again. 328 // history, try fetching again.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 [self.collectionViewModel sectionIdentifierForSection:section]; 661 [self.collectionViewModel sectionIdentifierForSection:section];
667 if ([self.collectionViewModel 662 if ([self.collectionViewModel
668 hasSectionForSectionIdentifier:sectionIdentifier]) { 663 hasSectionForSectionIdentifier:sectionIdentifier]) {
669 NSArray* items = [self.collectionViewModel 664 NSArray* items = [self.collectionViewModel
670 itemsInSectionWithIdentifier:sectionIdentifier]; 665 itemsInSectionWithIdentifier:sectionIdentifier];
671 for (id item in items) { 666 for (id item in items) {
672 HistoryEntryItem* historyItem = 667 HistoryEntryItem* historyItem =
673 base::mac::ObjCCastStrict<HistoryEntryItem>(item); 668 base::mac::ObjCCastStrict<HistoryEntryItem>(item);
674 if (![entries containsObject:historyItem]) { 669 if (![entries containsObject:historyItem]) {
675 NSIndexPath* indexPath = 670 NSIndexPath* indexPath =
676 [self.collectionViewModel indexPathForItem:historyItem 671 [self.collectionViewModel indexPathForItem:historyItem];
677 inSectionWithIdentifier:sectionIdentifier];
678 [self.collectionView 672 [self.collectionView
679 selectItemAtIndexPath:indexPath 673 selectItemAtIndexPath:indexPath
680 animated:NO 674 animated:NO
681 scrollPosition:UICollectionViewScrollPositionNone]; 675 scrollPosition:UICollectionViewScrollPositionNone];
682 } 676 }
683 } 677 }
684 } 678 }
685 } 679 }
686 } 680 }
687 681
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 shouldCloseWithCompletion:^{ 808 shouldCloseWithCompletion:^{
815 [self.URLLoader webPageOrderedOpen:copiedURL 809 [self.URLLoader webPageOrderedOpen:copiedURL
816 referrer:web::Referrer() 810 referrer:web::Referrer()
817 inIncognito:YES 811 inIncognito:YES
818 inBackground:NO 812 inBackground:NO
819 appendTo:kLastTab]; 813 appendTo:kLastTab];
820 }]; 814 }];
821 } 815 }
822 816
823 @end 817 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698