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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm

Issue 2891363002: Add long press actions for Most Visited tiles (Closed)
Patch Set: Address comments Created 3 years, 6 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
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/content_suggestions/content_suggestions_view_cont roller.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont roller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 NSIndexPath* touchedItemIndexPath = 241 NSIndexPath* touchedItemIndexPath =
242 [self.collectionView indexPathForItemAtPoint:touchLocation]; 242 [self.collectionView indexPathForItemAtPoint:touchLocation];
243 if (!touchedItemIndexPath || 243 if (!touchedItemIndexPath ||
244 ![self.collectionViewModel hasItemAtIndexPath:touchedItemIndexPath]) { 244 ![self.collectionViewModel hasItemAtIndexPath:touchedItemIndexPath]) {
245 // Make sure there is an item at this position. 245 // Make sure there is an item at this position.
246 return; 246 return;
247 } 247 }
248 CollectionViewItem* touchedItem = 248 CollectionViewItem* touchedItem =
249 [self.collectionViewModel itemAtIndexPath:touchedItemIndexPath]; 249 [self.collectionViewModel itemAtIndexPath:touchedItemIndexPath];
250 250
251 if ([self.collectionUpdater contentSuggestionTypeForItem:touchedItem] != 251 ContentSuggestionType type =
252 ContentSuggestionTypeArticle) { 252 [self.collectionUpdater contentSuggestionTypeForItem:touchedItem];
253 // Only trigger context menu on articles. 253 switch (type) {
254 return; 254 case ContentSuggestionTypeArticle:
255 [self.suggestionCommandHandler
256 displayContextMenuForArticle:touchedItem
257 atPoint:touchLocation
258 atIndexPath:touchedItemIndexPath];
259 break;
260 case ContentSuggestionTypeMostVisited:
261 [self.suggestionCommandHandler
262 displayContextMenuForMostVisitedItem:touchedItem
263 atPoint:touchLocation
264 atIndexPath:touchedItemIndexPath];
265 break;
266 default:
267 break;
255 } 268 }
256 269
257 [self.suggestionCommandHandler
258 displayContextMenuForArticle:touchedItem
259 atPoint:touchLocation
260 atIndexPath:touchedItemIndexPath];
261 } 270 }
262 271
263 // Checks if the |section| is empty and add an empty element if it is the case. 272 // Checks if the |section| is empty and add an empty element if it is the case.
264 // Must be called from inside a performBatchUpdates: block. 273 // Must be called from inside a performBatchUpdates: block.
265 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { 274 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section {
266 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) 275 if ([self.collectionViewModel numberOfItemsInSection:section] > 0)
267 return; 276 return;
268 277
269 NSIndexPath* emptyItem = 278 NSIndexPath* emptyItem =
270 [self.collectionUpdater addEmptyItemForSection:section]; 279 [self.collectionUpdater addEmptyItemForSection:section];
271 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; 280 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]];
272 } 281 }
273 282
274 // Tells WebToolbarController to resign focus to the omnibox. 283 // Tells WebToolbarController to resign focus to the omnibox.
275 - (void)blurOmnibox { 284 - (void)blurOmnibox {
276 // TODO(crbug.com/700375): once the omnibox is part of Content Suggestions, 285 // TODO(crbug.com/700375): once the omnibox is part of Content Suggestions,
277 // remove the fake omnibox focus here. 286 // remove the fake omnibox focus here.
278 } 287 }
279 288
280 @end 289 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698