Commit 7405f12a authored by gambard's avatar gambard Committed by Commit Bot

Add AccessibilityCustomAction to ContentSuggestions

In order to have the feature accessible, all the actions using gestures
(long press, swipe to dismiss) must have custom accessibility actions.
Also adds action sheet to Read Later cells.

Bug: 749131
Change-Id: I2c81f6443a49bdf0cdccc3ec747b0ffd42513ef1
Reviewed-on: https://chromium-review.googlesource.com/593652
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJean-François Geyelin <jif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490930}
parent 12af7241
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
source_set("content_suggestions") { source_set("content_suggestions") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"content_suggestions_alert_commands.h",
"content_suggestions_alert_factory.h", "content_suggestions_alert_factory.h",
"content_suggestions_alert_factory.mm", "content_suggestions_alert_factory.mm",
"content_suggestions_category_wrapper.h", "content_suggestions_category_wrapper.h",
...@@ -94,6 +93,7 @@ source_set("eg_tests") { ...@@ -94,6 +93,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/alert_coordinator", "//ios/chrome/browser/ui/alert_coordinator",
"//ios/chrome/browser/ui/alert_coordinator", "//ios/chrome/browser/ui/alert_coordinator",
"//ios/chrome/browser/ui/collection_view/cells", "//ios/chrome/browser/ui/collection_view/cells",
"//ios/chrome/browser/ui/content_suggestions/cells",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ui/strings", "//ui/strings",
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#import <EarlGrey/EarlGrey.h> #import <EarlGrey/EarlGrey.h>
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h"
#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_gesture_commands.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h" #import "ios/chrome/browser/ui/util/top_view_controller.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
onViewController:viewController onViewController:viewController
atPoint:CGPointMake(50, 50) atPoint:CGPointMake(50, 50)
atIndexPath:nil atIndexPath:nil
readLaterAction:YES
commandHandler:nil]; commandHandler:nil];
[coordinator start]; [coordinator start];
...@@ -67,11 +68,11 @@ ...@@ -67,11 +68,11 @@
UIViewController* viewController = UIViewController* viewController =
top_view_controller::TopPresentedViewController(); top_view_controller::TopPresentedViewController();
AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory
alertCoordinatorForSuggestionItem:nil alertCoordinatorForMostVisitedItem:nil
onViewController:viewController onViewController:viewController
atPoint:CGPointMake(50, 50) atPoint:CGPointMake(50, 50)
atIndexPath:nil atIndexPath:nil
commandHandler:nil]; commandHandler:nil];
[coordinator start]; [coordinator start];
[[EarlGrey [[EarlGrey
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class AlertCoordinator; @class AlertCoordinator;
@class CollectionViewItem; @class ContentSuggestionsItem;
@protocol ContentSuggestionsAlertCommands; @class ContentSuggestionsMostVisitedItem;
@protocol ContentSuggestionsGestureCommands;
// Factory for AlertCoordinators for ContentSuggestions. // Factory for AlertCoordinators for ContentSuggestions.
@interface ContentSuggestionsAlertFactory : NSObject @interface ContentSuggestionsAlertFactory : NSObject
...@@ -20,21 +21,22 @@ ...@@ -20,21 +21,22 @@
// |commandHandler| will receive callbacks when the user chooses one of the // |commandHandler| will receive callbacks when the user chooses one of the
// options displayed by the alert. // options displayed by the alert.
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForSuggestionItem:(CollectionViewItem*)item alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
readLaterAction:(BOOL)readLaterAction
commandHandler: commandHandler:
(id<ContentSuggestionsAlertCommands>)commandHandler; (id<ContentSuggestionsGestureCommands>)commandHandler;
// Same as above but for a MostVisited item. // Same as above but for a MostVisited item.
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
commandHandler: commandHandler:
(id<ContentSuggestionsAlertCommands>)commandHandler; (id<ContentSuggestionsGestureCommands>)commandHandler;
@end @end
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_gesture_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
...@@ -18,12 +19,13 @@ ...@@ -18,12 +19,13 @@
@implementation ContentSuggestionsAlertFactory @implementation ContentSuggestionsAlertFactory
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForSuggestionItem:(CollectionViewItem*)item alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
readLaterAction:(BOOL)readLaterAction
commandHandler: commandHandler:
(id<ContentSuggestionsAlertCommands>)commandHandler { (id<ContentSuggestionsGestureCommands>)commandHandler {
AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc]
initWithBaseViewController:viewController initWithBaseViewController:viewController
title:nil title:nil
...@@ -32,15 +34,15 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item ...@@ -32,15 +34,15 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item
0) 0)
view:[viewController view]]; view:[viewController view]];
__weak CollectionViewItem* weakItem = item; __weak ContentSuggestionsItem* weakItem = item;
__weak id<ContentSuggestionsAlertCommands> weakCommandHandler = __weak id<ContentSuggestionsGestureCommands> weakCommandHandler =
commandHandler; commandHandler;
NSString* openInNewTabTitle = NSString* openInNewTabTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB);
[alertCoordinator addItemWithTitle:openInNewTabTitle [alertCoordinator addItemWithTitle:openInNewTabTitle
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -54,7 +56,7 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item ...@@ -54,7 +56,7 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB); l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB);
[alertCoordinator addItemWithTitle:openInNewTabIncognitoTitle [alertCoordinator addItemWithTitle:openInNewTabIncognitoTitle
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -64,24 +66,26 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item ...@@ -64,24 +66,26 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item
} }
style:UIAlertActionStyleDefault]; style:UIAlertActionStyleDefault];
NSString* readLaterTitle = if (readLaterAction) {
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); NSString* readLaterTitle =
[alertCoordinator l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST);
addItemWithTitle:readLaterTitle [alertCoordinator
action:^{ addItemWithTitle:readLaterTitle
CollectionViewItem* strongItem = weakItem; action:^{
if (strongItem) { ContentSuggestionsItem* strongItem = weakItem;
// TODO(crbug.com/691979): Add metrics. if (strongItem) {
[weakCommandHandler addItemToReadingList:strongItem]; // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler addItemToReadingList:strongItem];
}
} }
} style:UIAlertActionStyleDefault];
style:UIAlertActionStyleDefault]; }
NSString* deleteTitle = NSString* deleteTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE); l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE);
[alertCoordinator addItemWithTitle:deleteTitle [alertCoordinator addItemWithTitle:deleteTitle
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -100,12 +104,12 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item ...@@ -100,12 +104,12 @@ alertCoordinatorForSuggestionItem:(CollectionViewItem*)item
} }
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
commandHandler: commandHandler:
(id<ContentSuggestionsAlertCommands>)commandHandler { (id<ContentSuggestionsGestureCommands>)commandHandler {
AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc]
initWithBaseViewController:viewController initWithBaseViewController:viewController
title:nil title:nil
...@@ -114,15 +118,15 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item ...@@ -114,15 +118,15 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item
0) 0)
view:[viewController view]]; view:[viewController view]];
__weak CollectionViewItem* weakItem = item; __weak ContentSuggestionsMostVisitedItem* weakItem = item;
__weak id<ContentSuggestionsAlertCommands> weakCommandHandler = __weak id<ContentSuggestionsGestureCommands> weakCommandHandler =
commandHandler; commandHandler;
[alertCoordinator [alertCoordinator
addItemWithTitle:l10n_util::GetNSStringWithFixup( addItemWithTitle:l10n_util::GetNSStringWithFixup(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsMostVisitedItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler [weakCommandHandler
openNewTabWithMostVisitedItem:strongItem openNewTabWithMostVisitedItem:strongItem
...@@ -136,7 +140,7 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item ...@@ -136,7 +140,7 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item
addItemWithTitle:l10n_util::GetNSStringWithFixup( addItemWithTitle:l10n_util::GetNSStringWithFixup(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsMostVisitedItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler [weakCommandHandler
openNewTabWithMostVisitedItem:strongItem openNewTabWithMostVisitedItem:strongItem
...@@ -150,7 +154,7 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item ...@@ -150,7 +154,7 @@ alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item
addItemWithTitle:l10n_util::GetNSStringWithFixup( addItemWithTitle:l10n_util::GetNSStringWithFixup(
IDS_IOS_CONTENT_SUGGESTIONS_REMOVE) IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)
action:^{ action:^{
CollectionViewItem* strongItem = weakItem; ContentSuggestionsMostVisitedItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler removeMostVisited:strongItem]; [weakCommandHandler removeMostVisited:strongItem];
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "components/reading_list/core/reading_list_model.h" #include "components/reading_list/core/reading_list_model.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_header_view_controller.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_header_view_controller.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_header_view_controller_delegate.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_header_view_controller_delegate.h"
...@@ -34,6 +33,7 @@ ...@@ -34,6 +33,7 @@
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h" #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h" #import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_gesture_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
...@@ -65,8 +65,8 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -65,8 +65,8 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
} // namespace } // namespace
@interface ContentSuggestionsCoordinator ()< @interface ContentSuggestionsCoordinator ()<
ContentSuggestionsAlertCommands,
ContentSuggestionsCommands, ContentSuggestionsCommands,
ContentSuggestionsGestureCommands,
ContentSuggestionsHeaderViewControllerCommandHandler, ContentSuggestionsHeaderViewControllerCommandHandler,
ContentSuggestionsViewControllerAudience, ContentSuggestionsViewControllerAudience,
ContentSuggestionsViewControllerDelegate, ContentSuggestionsViewControllerDelegate,
...@@ -211,14 +211,18 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -211,14 +211,18 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
rendererInitiated:NO]; rendererInitiated:NO];
} }
- (void)displayContextMenuForArticle:(CollectionViewItem*)item - (void)displayContextMenuForSuggestion:(CollectionViewItem*)item
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath { atIndexPath:(NSIndexPath*)indexPath
readLaterAction:(BOOL)readLaterAction {
ContentSuggestionsItem* suggestionsItem =
base::mac::ObjCCastStrict<ContentSuggestionsItem>(item);
self.alertCoordinator = [ContentSuggestionsAlertFactory self.alertCoordinator = [ContentSuggestionsAlertFactory
alertCoordinatorForSuggestionItem:item alertCoordinatorForSuggestionItem:suggestionsItem
onViewController:self.suggestionsViewController onViewController:self.suggestionsViewController
atPoint:touchLocation atPoint:touchLocation
atIndexPath:indexPath atIndexPath:indexPath
readLaterAction:readLaterAction
commandHandler:self]; commandHandler:self];
[self.alertCoordinator start]; [self.alertCoordinator start];
...@@ -227,8 +231,10 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -227,8 +231,10 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
- (void)displayContextMenuForMostVisitedItem:(CollectionViewItem*)item - (void)displayContextMenuForMostVisitedItem:(CollectionViewItem*)item
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath { atIndexPath:(NSIndexPath*)indexPath {
ContentSuggestionsMostVisitedItem* mostVisitedItem =
base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item);
self.alertCoordinator = [ContentSuggestionsAlertFactory self.alertCoordinator = [ContentSuggestionsAlertFactory
alertCoordinatorForMostVisitedItem:item alertCoordinatorForMostVisitedItem:mostVisitedItem
onViewController:self.suggestionsViewController onViewController:self.suggestionsViewController
atPoint:touchLocation atPoint:touchLocation
atIndexPath:indexPath atIndexPath:indexPath
...@@ -268,52 +274,54 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -268,52 +274,54 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
rendererInitiated:NO]; rendererInitiated:NO];
} }
#pragma mark - ContentSuggestionsAlertCommands #pragma mark - ContentSuggestionsGestureCommands
- (void)openNewTabWithSuggestionsItem:(CollectionViewItem*)item - (void)openNewTabWithSuggestionsItem:(ContentSuggestionsItem*)item
incognito:(BOOL)incognito { incognito:(BOOL)incognito {
ContentSuggestionsItem* suggestionsItem = [self openNewTabWithURL:item.URL incognito:incognito];
base::mac::ObjCCastStrict<ContentSuggestionsItem>(item);
[self openNewTabWithURL:suggestionsItem.URL incognito:incognito];
} }
- (void)addItemToReadingList:(CollectionViewItem*)item { - (void)addItemToReadingList:(ContentSuggestionsItem*)item {
ContentSuggestionsItem* suggestionsItem =
base::mac::ObjCCastStrict<ContentSuggestionsItem>(item);
base::RecordAction(base::UserMetricsAction("MobileReadingListAdd")); base::RecordAction(base::UserMetricsAction("MobileReadingListAdd"));
ReadingListModel* readingModel = ReadingListModel* readingModel =
ReadingListModelFactory::GetForBrowserState(self.browserState); ReadingListModelFactory::GetForBrowserState(self.browserState);
readingModel->AddEntry(suggestionsItem.URL, readingModel->AddEntry(item.URL, base::SysNSStringToUTF8(item.title),
base::SysNSStringToUTF8(suggestionsItem.title),
reading_list::ADDED_VIA_CURRENT_APP); reading_list::ADDED_VIA_CURRENT_APP);
} }
- (void)dismissSuggestion:(CollectionViewItem*)item - (void)dismissSuggestion:(ContentSuggestionsItem*)item
atIndexPath:(NSIndexPath*)indexPath { atIndexPath:(NSIndexPath*)indexPath {
ContentSuggestionsItem* suggestionsItem = NSIndexPath* itemIndexPath = indexPath;
base::mac::ObjCCastStrict<ContentSuggestionsItem>(item); if (!itemIndexPath) {
// If the caller uses a nil |indexPath|, find it from the model.
itemIndexPath = [self.suggestionsViewController.collectionViewModel
indexPathForItem:item];
}
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[self.contentSuggestionsMediator [self.contentSuggestionsMediator dismissSuggestion:item.suggestionIdentifier];
dismissSuggestion:suggestionsItem.suggestionIdentifier]; [self.suggestionsViewController dismissEntryAtIndexPath:itemIndexPath];
[self.suggestionsViewController dismissEntryAtIndexPath:indexPath];
} }
- (void)openNewTabWithMostVisitedItem:(CollectionViewItem*)item - (void)openNewTabWithMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
incognito:(BOOL)incognito incognito:(BOOL)incognito
atIndex:(NSInteger)index { atIndex:(NSInteger)index {
ContentSuggestionsMostVisitedItem* mostVisitedItem = [self logMostVisitedOpening:item atIndex:index];
base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item); [self openNewTabWithURL:item.URL incognito:incognito];
[self logMostVisitedOpening:mostVisitedItem atIndex:index];
[self openNewTabWithURL:mostVisitedItem.URL incognito:incognito];
} }
- (void)removeMostVisited:(CollectionViewItem*)item { - (void)openNewTabWithMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
ContentSuggestionsMostVisitedItem* mostVisitedItem = incognito:(BOOL)incognito {
base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item); NSInteger index =
[self.suggestionsViewController.collectionViewModel indexPathForItem:item]
.item;
[self openNewTabWithMostVisitedItem:item incognito:incognito atIndex:index];
}
- (void)removeMostVisited:(ContentSuggestionsMostVisitedItem*)item {
base::RecordAction(base::UserMetricsAction("MostVisited_UrlBlacklisted")); base::RecordAction(base::UserMetricsAction("MostVisited_UrlBlacklisted"));
[self.contentSuggestionsMediator blacklistMostVisitedURL:mostVisitedItem.URL]; [self.contentSuggestionsMediator blacklistMostVisitedURL:item.URL];
[self showMostVisitedUndoForURL:mostVisitedItem.URL]; [self showMostVisitedUndoForURL:item.URL];
} }
#pragma mark - ContentSuggestionsViewControllerDelegate #pragma mark - ContentSuggestionsViewControllerDelegate
......
...@@ -25,6 +25,7 @@ class MostVisitedSites; ...@@ -25,6 +25,7 @@ class MostVisitedSites;
} }
@protocol ContentSuggestionsCommands; @protocol ContentSuggestionsCommands;
@protocol ContentSuggestionsGestureCommands;
@protocol ContentSuggestionsHeaderProvider; @protocol ContentSuggestionsHeaderProvider;
@class ContentSuggestionIdentifier; @class ContentSuggestionIdentifier;
class GURL; class GURL;
...@@ -49,8 +50,9 @@ initWithContentService: ...@@ -49,8 +50,9 @@ initWithContentService:
- (nullable instancetype)init NS_UNAVAILABLE; - (nullable instancetype)init NS_UNAVAILABLE;
// Command handler for the mediator. // Command handler for the mediator.
@property(nonatomic, weak, nullable) id<ContentSuggestionsCommands> @property(nonatomic, weak, nullable)
commandHandler; id<ContentSuggestionsCommands, ContentSuggestionsGestureCommands>
commandHandler;
@property(nonatomic, weak, nullable) id<ContentSuggestionsHeaderProvider> @property(nonatomic, weak, nullable) id<ContentSuggestionsHeaderProvider>
headerProvider; headerProvider;
......
...@@ -452,6 +452,7 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService ...@@ -452,6 +452,7 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService
ContentSuggestionsItem* suggestion = ContentSuggestionsItem* suggestion =
ConvertSuggestion(contentSuggestion, sectionInfo, category); ConvertSuggestion(contentSuggestion, sectionInfo, category);
suggestion.delegate = self; suggestion.delegate = self;
suggestion.commandHandler = self.commandHandler;
[self.faviconMediator fetchFaviconForSuggestions:suggestion [self.faviconMediator fetchFaviconForSuggestions:suggestion
inCategory:category]; inCategory:category];
......
...@@ -64,6 +64,7 @@ ContentSuggestionsItem* ConvertSuggestion( ...@@ -64,6 +64,7 @@ ContentSuggestionsItem* ConvertSuggestion(
} }
if (category.IsKnownCategory(ntp_snippets::KnownCategories::ARTICLES)) { if (category.IsKnownCategory(ntp_snippets::KnownCategories::ARTICLES)) {
suggestion.hasImage = YES; suggestion.hasImage = YES;
suggestion.readLaterAction = YES;
} }
return suggestion; return suggestion;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
source_set("cells") { source_set("cells") {
sources = [ sources = [
"content_suggestions_gesture_commands.h",
"content_suggestions_item.h", "content_suggestions_item.h",
"content_suggestions_item.mm", "content_suggestions_item.mm",
"content_suggestions_most_visited_item.h", "content_suggestions_most_visited_item.h",
......
...@@ -2,38 +2,49 @@ ...@@ -2,38 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_ #ifndef IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_
#define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_ #define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class CollectionViewItem; @class ContentSuggestionsItem;
@class ContentSuggestionsMostVisitedItem;
// Command protocol for the ContentSuggestionsAlertFactory, handling the // Command protocol for the interactions based on a gesture, handling the
// callbacks from the alerts. // callbacks from the alerts and the accessibility custom actions.
@protocol ContentSuggestionsAlertCommands @protocol ContentSuggestionsGestureCommands
// Opens the URL corresponding to the |item| in a new tab, |incognito| or not. // Opens the URL corresponding to the |item| in a new tab, |incognito| or not.
// The item has to be a suggestion item. // The item has to be a suggestion item.
- (void)openNewTabWithSuggestionsItem:(nonnull CollectionViewItem*)item - (void)openNewTabWithSuggestionsItem:(nonnull ContentSuggestionsItem*)item
incognito:(BOOL)incognito; incognito:(BOOL)incognito;
// Adds the |item| to the reading list. The item has to be a suggestion item. // Adds the |item| to the reading list. The item has to be a suggestion item.
- (void)addItemToReadingList:(nonnull CollectionViewItem*)item; - (void)addItemToReadingList:(nonnull ContentSuggestionsItem*)item;
// Dismiss the |item| at |indexPath|. The item has to be a suggestion item. // Dismiss the |item| at |indexPath|. The item has to be a suggestion item.
- (void)dismissSuggestion:(nonnull CollectionViewItem*)item // If |indexPath| is nil, the commands handler will find the index path
atIndexPath:(nonnull NSIndexPath*)indexPath; // associated with the |item|.
- (void)dismissSuggestion:(nonnull ContentSuggestionsItem*)item
atIndexPath:(nullable NSIndexPath*)indexPath;
// Open the URL corresponding to the |item| in a new tab, |incognito| or not. // Open the URL corresponding to the |item| in a new tab, |incognito| or not.
// The item has to be a Most Visited item. // The item has to be a Most Visited item.
- (void)openNewTabWithMostVisitedItem:(nonnull CollectionViewItem*)item - (void)openNewTabWithMostVisitedItem:
(nonnull ContentSuggestionsMostVisitedItem*)item
incognito:(BOOL)incognito incognito:(BOOL)incognito
atIndex:(NSInteger)mostVisitedIndex; atIndex:(NSInteger)mostVisitedIndex;
// Open the URL corresponding to the |item| in a new tab, |incognito| or not.
// The index of the item will be find by the command handler. The item has to
// be a Most Visited item.
- (void)openNewTabWithMostVisitedItem:
(nonnull ContentSuggestionsMostVisitedItem*)item
incognito:(BOOL)incognito;
// Removes the most visited |item|. // Removes the most visited |item|.
- (void)removeMostVisited:(nonnull CollectionViewItem*)item; - (void)removeMostVisited:(nonnull ContentSuggestionsMostVisitedItem*)item;
@end @end
#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_ #endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_
...@@ -16,6 +16,8 @@ class Time; ...@@ -16,6 +16,8 @@ class Time;
@class FaviconAttributes; @class FaviconAttributes;
class GURL; class GURL;
@protocol ContentSuggestionsGestureCommands;
// Delegate for SuggestedContent. // Delegate for SuggestedContent.
@protocol ContentSuggestionsItemDelegate @protocol ContentSuggestionsItemDelegate
...@@ -48,6 +50,10 @@ class GURL; ...@@ -48,6 +50,10 @@ class GURL;
@property(nonatomic, strong) FaviconAttributes* attributes; @property(nonatomic, strong) FaviconAttributes* attributes;
// URL for the favicon, if different of |URL|. // URL for the favicon, if different of |URL|.
@property(nonatomic, assign) GURL faviconURL; @property(nonatomic, assign) GURL faviconURL;
// Whether this item should have an option to be read later.
@property(nonatomic, assign) BOOL readLaterAction;
// Command handler for the accessibility custom actions.
@property(nonatomic, weak) id<ContentSuggestionsGestureCommands> commandHandler;
@end @end
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_gesture_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h" #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h"
#import "ios/chrome/browser/ui/favicon/favicon_attributes.h" #import "ios/chrome/browser/ui/favicon/favicon_attributes.h"
#import "ios/chrome/browser/ui/favicon/favicon_view.h" #import "ios/chrome/browser/ui/favicon/favicon_view.h"
...@@ -46,6 +47,8 @@ ...@@ -46,6 +47,8 @@
@synthesize faviconURL = _faviconURL; @synthesize faviconURL = _faviconURL;
@synthesize hasImage = _hasImage; @synthesize hasImage = _hasImage;
@synthesize firstTimeWithImage = _firstTimeWithImage; @synthesize firstTimeWithImage = _firstTimeWithImage;
@synthesize readLaterAction = _readLaterAction;
@synthesize commandHandler = _commandHandler;
- (instancetype)initWithType:(NSInteger)type - (instancetype)initWithType:(NSInteger)type
title:(NSString*)title title:(NSString*)title
...@@ -75,6 +78,7 @@ ...@@ -75,6 +78,7 @@
date:[self relativeDate]]; date:[self relativeDate]];
cell.isAccessibilityElement = YES; cell.isAccessibilityElement = YES;
cell.accessibilityLabel = [self accessibilityLabel]; cell.accessibilityLabel = [self accessibilityLabel];
cell.accessibilityCustomActions = [self customActions];
} }
- (void)setImage:(UIImage*)image { - (void)setImage:(UIImage*)image {
...@@ -121,4 +125,67 @@ ...@@ -121,4 +125,67 @@
base::SysNSStringToUTF16([self relativeDate])); base::SysNSStringToUTF16([self relativeDate]));
} }
#pragma mark - AccessibilityCustomAction
// Custom action for a cell configured with this item.
- (NSArray<UIAccessibilityCustomAction*>*)customActions {
UIAccessibilityCustomAction* openInNewTab =
[[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
target:self
selector:@selector(openInNewTab)];
UIAccessibilityCustomAction* openInNewIncognitoTab =
[[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
target:self
selector:@selector(openInNewIncognitoTab)];
NSMutableArray* customActions = [NSMutableArray
arrayWithObjects:openInNewTab, openInNewIncognitoTab, nil];
if (self.readLaterAction) {
UIAccessibilityCustomAction* readLater =
[[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST)
target:self
selector:@selector(readLater)];
[customActions addObject:readLater];
}
UIAccessibilityCustomAction* removeSuggestion = [
[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)
target:self
selector:@selector(removeSuggestion)];
[customActions addObject:removeSuggestion];
return customActions;
}
// Target for custom action.
- (BOOL)openInNewTab {
[self.commandHandler openNewTabWithSuggestionsItem:self incognito:NO];
return YES;
}
// Target for custom action.
- (BOOL)openInNewIncognitoTab {
[self.commandHandler openNewTabWithSuggestionsItem:self incognito:YES];
return YES;
}
// Target for custom action.
- (BOOL)readLater {
[self.commandHandler addItemToReadingList:self];
return YES;
}
// Target for custom action.
- (BOOL)removeSuggestion {
[self.commandHandler dismissSuggestion:self atIndexPath:nil];
return YES;
}
@end @end
...@@ -37,6 +37,7 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { ...@@ -37,6 +37,7 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) {
item.hasImage = YES; item.hasImage = YES;
item.publisher = publisher; item.publisher = publisher;
item.publishDate = publishTime; item.publishDate = publishTime;
item.readLaterAction = YES;
OCMExpect([delegateMock loadImageForSuggestedItem:item]); OCMExpect([delegateMock loadImageForSuggestedItem:item]);
ContentSuggestionsCell* cell = [[[item cellClass] alloc] init]; ContentSuggestionsCell* cell = [[[item cellClass] alloc] init];
ASSERT_EQ([ContentSuggestionsCell class], [cell class]); ASSERT_EQ([ContentSuggestionsCell class], [cell class]);
...@@ -54,6 +55,7 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { ...@@ -54,6 +55,7 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) {
EXPECT_OCMOCK_VERIFY(cellMock); EXPECT_OCMOCK_VERIFY(cellMock);
EXPECT_EQ(title, cell.titleLabel.text); EXPECT_EQ(title, cell.titleLabel.text);
EXPECT_OCMOCK_VERIFY(delegateMock); EXPECT_OCMOCK_VERIFY(delegateMock);
EXPECT_EQ(4U, [cell.accessibilityCustomActions count]);
} }
// Tests that configureCell: does not call the delegate if it fetched the image // Tests that configureCell: does not call the delegate if it fetched the image
...@@ -139,4 +141,24 @@ TEST(ContentSuggestionsItemTest, ImageAnimatedOnlyTheFirstTime) { ...@@ -139,4 +141,24 @@ TEST(ContentSuggestionsItemTest, ImageAnimatedOnlyTheFirstTime) {
EXPECT_OCMOCK_VERIFY(cell1); EXPECT_OCMOCK_VERIFY(cell1);
EXPECT_OCMOCK_VERIFY(cell2); EXPECT_OCMOCK_VERIFY(cell2);
} }
// Tests the custom actions when there is no read later actions.
TEST(ContentSuggestionsItemTest, NoReadLaterAction) {
// Setup.
NSString* title = @"testTitle";
GURL url = GURL("http://chromium.org");
ContentSuggestionsItem* item =
[[ContentSuggestionsItem alloc] initWithType:0 title:title url:url];
item.readLaterAction = NO;
item.image = [[UIImage alloc] init];
ContentSuggestionsCell* cell = [[[item cellClass] alloc] init];
// Action.
[item configureCell:cell];
// Tests.
EXPECT_EQ(3U, [cell.accessibilityCustomActions count]);
}
} // namespace } // namespace
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/suggested_content.h" #import "ios/chrome/browser/ui/content_suggestions/cells/suggested_content.h"
@protocol ContentSuggestionsGestureCommands;
@class FaviconAttributes; @class FaviconAttributes;
class GURL; class GURL;
...@@ -26,6 +27,9 @@ class GURL; ...@@ -26,6 +27,9 @@ class GURL;
@property(nonatomic, assign) ntp_tiles::TileSource source; @property(nonatomic, assign) ntp_tiles::TileSource source;
// Attributes for favicon. // Attributes for favicon.
@property(nonatomic, strong, nullable) FaviconAttributes* attributes; @property(nonatomic, strong, nullable) FaviconAttributes* attributes;
// Command handler for the accessibility custom actions.
@property(nonatomic, weak, nullable) id<ContentSuggestionsGestureCommands>
commandHandler;
- (ntp_tiles::TileVisualType)tileType; - (ntp_tiles::TileVisualType)tileType;
......
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_gesture_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_cell.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_cell.h"
#import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h" #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h"
#import "ios/chrome/browser/ui/favicon/favicon_attributes.h" #import "ios/chrome/browser/ui/favicon/favicon_attributes.h"
#import "ios/chrome/browser/ui/favicon/favicon_view.h" #import "ios/chrome/browser/ui/favicon/favicon_view.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -21,6 +24,7 @@ ...@@ -21,6 +24,7 @@
@synthesize title = _title; @synthesize title = _title;
@synthesize URL = _URL; @synthesize URL = _URL;
@synthesize source = _source; @synthesize source = _source;
@synthesize commandHandler = _commandHandler;
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type]; self = [super initWithType:type];
...@@ -35,6 +39,7 @@ ...@@ -35,6 +39,7 @@
cell.titleLabel.text = self.title; cell.titleLabel.text = self.title;
cell.accessibilityLabel = self.title; cell.accessibilityLabel = self.title;
[cell.faviconView configureWithAttributes:self.attributes]; [cell.faviconView configureWithAttributes:self.attributes];
cell.accessibilityCustomActions = [self customActions];
} }
- (ntp_tiles::TileVisualType)tileType { - (ntp_tiles::TileVisualType)tileType {
...@@ -52,4 +57,51 @@ ...@@ -52,4 +57,51 @@
return [ContentSuggestionsMostVisitedCell defaultSize].height; return [ContentSuggestionsMostVisitedCell defaultSize].height;
} }
#pragma mark - AccessibilityCustomAction
// Custom action for a cell configured with this item.
- (NSArray<UIAccessibilityCustomAction*>*)customActions {
UIAccessibilityCustomAction* openInNewTab =
[[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
target:self
selector:@selector(openInNewTab)];
UIAccessibilityCustomAction* openInNewIncognitoTab =
[[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
target:self
selector:@selector(openInNewIncognitoTab)];
UIAccessibilityCustomAction* removeMostVisited = [
[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)
target:self
selector:@selector(removeMostVisited)];
NSArray* customActions =
[NSArray arrayWithObjects:openInNewTab, openInNewIncognitoTab,
removeMostVisited, nil];
return customActions;
}
// Target for custom action.
- (BOOL)openInNewTab {
[self.commandHandler openNewTabWithMostVisitedItem:self incognito:NO];
return YES;
}
// Target for custom action.
- (BOOL)openInNewIncognitoTab {
[self.commandHandler openNewTabWithMostVisitedItem:self incognito:YES];
return YES;
}
// Target for custom action.
- (BOOL)removeMostVisited {
[self.commandHandler removeMostVisited:self];
return YES;
}
@end @end
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
// Opens the Most Visited associated with this |item| at the |mostVisitedItem|. // Opens the Most Visited associated with this |item| at the |mostVisitedItem|.
- (void)openMostVisitedItem:(nonnull CollectionViewItem*)item - (void)openMostVisitedItem:(nonnull CollectionViewItem*)item
atIndex:(NSInteger)mostVisitedIndex; atIndex:(NSInteger)mostVisitedIndex;
// Displays a context menu for the |articleItem|. // Displays a context menu for the |suggestionItem|.
- (void)displayContextMenuForArticle:(nonnull CollectionViewItem*)articleItem - (void)displayContextMenuForSuggestion:
atPoint:(CGPoint)touchLocation (nonnull CollectionViewItem*)suggestionItem
atIndexPath:(nonnull NSIndexPath*)indexPath; atPoint:(CGPoint)touchLocation
atIndexPath:(nonnull NSIndexPath*)indexPath
readLaterAction:(BOOL)readLaterAction;
// Displays a context menu for the |mostVisitedItem|. // Displays a context menu for the |mostVisitedItem|.
- (void)displayContextMenuForMostVisitedItem: - (void)displayContextMenuForMostVisitedItem:
(nonnull CollectionViewItem*)mostVisitedItem (nonnull CollectionViewItem*)mostVisitedItem
......
...@@ -471,9 +471,17 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) { ...@@ -471,9 +471,17 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
switch (type) { switch (type) {
case ContentSuggestionTypeArticle: case ContentSuggestionTypeArticle:
[self.suggestionCommandHandler [self.suggestionCommandHandler
displayContextMenuForArticle:touchedItem displayContextMenuForSuggestion:touchedItem
atPoint:touchLocation atPoint:touchLocation
atIndexPath:touchedItemIndexPath]; atIndexPath:touchedItemIndexPath
readLaterAction:YES];
break;
case ContentSuggestionTypeReadingList:
[self.suggestionCommandHandler
displayContextMenuForSuggestion:touchedItem
atPoint:touchLocation
atIndexPath:touchedItemIndexPath
readLaterAction:NO];
break; break;
case ContentSuggestionTypeMostVisited: case ContentSuggestionTypeMostVisited:
[self.suggestionCommandHandler [self.suggestionCommandHandler
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment