Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 134 |
| 135 - (void)collectionView:(UICollectionView*)collectionView | 135 - (void)collectionView:(UICollectionView*)collectionView |
| 136 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 136 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 137 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 137 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
| 138 | 138 |
| 139 CollectionViewItem* item = | 139 CollectionViewItem* item = |
| 140 [self.collectionViewModel itemAtIndexPath:indexPath]; | 140 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 141 switch ([self.collectionUpdater contentSuggestionTypeForItem:item]) { | 141 switch ([self.collectionUpdater contentSuggestionTypeForItem:item]) { |
| 142 case ContentSuggestionTypeReadingList: | 142 case ContentSuggestionTypeReadingList: |
| 143 case ContentSuggestionTypeArticle: | 143 case ContentSuggestionTypeArticle: |
| 144 [self blurOmnibox]; | |
| 144 [self.suggestionCommandHandler openPageForItem:item]; | 145 [self.suggestionCommandHandler openPageForItem:item]; |
| 145 break; | 146 break; |
| 146 case ContentSuggestionTypeMostVisited: | 147 case ContentSuggestionTypeMostVisited: |
| 147 // TODO(crbug.com/707754): Open the most visited site. | 148 [self blurOmnibox]; |
| 149 [self.suggestionCommandHandler openMostVisitedItem:item | |
| 150 atIndex:indexPath.item]; | |
| 148 break; | 151 break; |
| 149 case ContentSuggestionTypeEmpty: | 152 case ContentSuggestionTypeEmpty: |
| 150 break; | 153 break; |
| 151 } | 154 } |
| 152 } | 155 } |
| 153 | 156 |
| 154 #pragma mark - UICollectionViewDelegateFlowLayout | 157 #pragma mark - UICollectionViewDelegateFlowLayout |
| 155 | 158 |
| 156 - (CGSize)collectionView:(UICollectionView*)collectionView | 159 - (CGSize)collectionView:(UICollectionView*)collectionView |
| 157 layout:(UICollectionViewLayout*)collectionViewLayout | 160 layout:(UICollectionViewLayout*)collectionViewLayout |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 // Must be called from inside a performBatchUpdates: block. | 267 // Must be called from inside a performBatchUpdates: block. |
| 265 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { | 268 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { |
| 266 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) | 269 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) |
| 267 return; | 270 return; |
| 268 | 271 |
| 269 NSIndexPath* emptyItem = | 272 NSIndexPath* emptyItem = |
| 270 [self.collectionUpdater addEmptyItemForSection:section]; | 273 [self.collectionUpdater addEmptyItemForSection:section]; |
| 271 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; | 274 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; |
| 272 } | 275 } |
| 273 | 276 |
| 277 // Tells WebToolbarController to resign focus to the omnibox. | |
| 278 - (void)blurOmnibox { | |
|
marq (ping after 24h)
2017/06/02 08:25:47
Minor naming nit: when 'focus' is used to mean 'ma
gambard
2017/06/02 13:26:58
I had the same reaction as you :)
But as defocus w
| |
| 279 // TODO(crbug.com/700375): once the omnibox is part of Content Suggestions, | |
| 280 // remove the fake omnibox focus here. | |
| 281 } | |
| 282 | |
| 274 @end | 283 @end |
| OLD | NEW |