Commit 28cefc4b authored by Menglu Huang's avatar Menglu Huang Committed by Commit Bot

Revert "Add AccessibilityCustomAction to ContentSuggestions"

This reverts commit 7405f12a.

Reason for revert: <INSERT REASONING HERE>
This CL breaks ios_showcase_tests.
https://build.chromium.org/p/chromium.fyi/builders/EarlGreyiOS/builds/30194

Original change's description:
> 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: Jean-François Geyelin <jif@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#490930}

TBR=jif@chromium.org,gambard@chromium.org

Change-Id: I805e907403106623dc9c67cc89ccbbc5546d0ee1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 749131
Reviewed-on: https://chromium-review.googlesource.com/596591Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Commit-Queue: Menglu Huang <huangml@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491088}
parent dba6bbe4
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
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",
...@@ -93,7 +94,6 @@ source_set("eg_tests") { ...@@ -93,7 +94,6 @@ 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",
......
...@@ -2,49 +2,38 @@ ...@@ -2,49 +2,38 @@
// 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_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_ #ifndef IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_ #define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class ContentSuggestionsItem; @class CollectionViewItem;
@class ContentSuggestionsMostVisitedItem;
// Command protocol for the interactions based on a gesture, handling the // Command protocol for the ContentSuggestionsAlertFactory, handling the
// callbacks from the alerts and the accessibility custom actions. // callbacks from the alerts.
@protocol ContentSuggestionsGestureCommands @protocol ContentSuggestionsAlertCommands
// 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 ContentSuggestionsItem*)item - (void)openNewTabWithSuggestionsItem:(nonnull CollectionViewItem*)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 ContentSuggestionsItem*)item; - (void)addItemToReadingList:(nonnull CollectionViewItem*)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.
// If |indexPath| is nil, the commands handler will find the index path - (void)dismissSuggestion:(nonnull CollectionViewItem*)item
// associated with the |item|. atIndexPath:(nonnull NSIndexPath*)indexPath;
- (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: - (void)openNewTabWithMostVisitedItem:(nonnull CollectionViewItem*)item
(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 ContentSuggestionsMostVisitedItem*)item; - (void)removeMostVisited:(nonnull CollectionViewItem*)item;
@end @end
#endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CELLS_CONTENT_SUGGESTIONS_GESTURE_COMMANDS_H_ #endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_
...@@ -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,7 +35,6 @@ ...@@ -35,7 +35,6 @@
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];
...@@ -68,11 +67,11 @@ ...@@ -68,11 +67,11 @@
UIViewController* viewController = UIViewController* viewController =
top_view_controller::TopPresentedViewController(); top_view_controller::TopPresentedViewController();
AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory
alertCoordinatorForMostVisitedItem:nil alertCoordinatorForSuggestionItem: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,9 +8,8 @@ ...@@ -8,9 +8,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class AlertCoordinator; @class AlertCoordinator;
@class ContentSuggestionsItem; @class CollectionViewItem;
@class ContentSuggestionsMostVisitedItem; @protocol ContentSuggestionsAlertCommands;
@protocol ContentSuggestionsGestureCommands;
// Factory for AlertCoordinators for ContentSuggestions. // Factory for AlertCoordinators for ContentSuggestions.
@interface ContentSuggestionsAlertFactory : NSObject @interface ContentSuggestionsAlertFactory : NSObject
...@@ -21,22 +20,21 @@ ...@@ -21,22 +20,21 @@
// |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:(ContentSuggestionsItem*)item alertCoordinatorForSuggestionItem:(CollectionViewItem*)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<ContentSuggestionsGestureCommands>)commandHandler; (id<ContentSuggestionsAlertCommands>)commandHandler;
// Same as above but for a MostVisited item. // Same as above but for a MostVisited item.
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
commandHandler: commandHandler:
(id<ContentSuggestionsGestureCommands>)commandHandler; (id<ContentSuggestionsAlertCommands>)commandHandler;
@end @end
......
...@@ -4,10 +4,9 @@ ...@@ -4,10 +4,9 @@
#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/content_suggestions/cells/content_suggestions_gesture_commands.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_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"
#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"
...@@ -19,13 +18,12 @@ ...@@ -19,13 +18,12 @@
@implementation ContentSuggestionsAlertFactory @implementation ContentSuggestionsAlertFactory
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item alertCoordinatorForSuggestionItem:(CollectionViewItem*)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<ContentSuggestionsGestureCommands>)commandHandler { (id<ContentSuggestionsAlertCommands>)commandHandler {
AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc]
initWithBaseViewController:viewController initWithBaseViewController:viewController
title:nil title:nil
...@@ -34,15 +32,15 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item ...@@ -34,15 +32,15 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item
0) 0)
view:[viewController view]]; view:[viewController view]];
__weak ContentSuggestionsItem* weakItem = item; __weak CollectionViewItem* weakItem = item;
__weak id<ContentSuggestionsGestureCommands> weakCommandHandler = __weak id<ContentSuggestionsAlertCommands> 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:^{
ContentSuggestionsItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -56,7 +54,7 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item ...@@ -56,7 +54,7 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)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:^{
ContentSuggestionsItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -66,26 +64,24 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item ...@@ -66,26 +64,24 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item
} }
style:UIAlertActionStyleDefault]; style:UIAlertActionStyleDefault];
if (readLaterAction) { NSString* readLaterTitle =
NSString* readLaterTitle = l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST);
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); [alertCoordinator
[alertCoordinator addItemWithTitle:readLaterTitle
addItemWithTitle:readLaterTitle 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 addItemToReadingList:strongItem];
[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:^{
ContentSuggestionsItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
// TODO(crbug.com/691979): Add metrics. // TODO(crbug.com/691979): Add metrics.
[weakCommandHandler [weakCommandHandler
...@@ -104,12 +100,12 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item ...@@ -104,12 +100,12 @@ alertCoordinatorForSuggestionItem:(ContentSuggestionsItem*)item
} }
+ (AlertCoordinator*) + (AlertCoordinator*)
alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item
onViewController:(UIViewController*)viewController onViewController:(UIViewController*)viewController
atPoint:(CGPoint)touchLocation atPoint:(CGPoint)touchLocation
atIndexPath:(NSIndexPath*)indexPath atIndexPath:(NSIndexPath*)indexPath
commandHandler: commandHandler:
(id<ContentSuggestionsGestureCommands>)commandHandler { (id<ContentSuggestionsAlertCommands>)commandHandler {
AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc]
initWithBaseViewController:viewController initWithBaseViewController:viewController
title:nil title:nil
...@@ -118,15 +114,15 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item ...@@ -118,15 +114,15 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
0) 0)
view:[viewController view]]; view:[viewController view]];
__weak ContentSuggestionsMostVisitedItem* weakItem = item; __weak CollectionViewItem* weakItem = item;
__weak id<ContentSuggestionsGestureCommands> weakCommandHandler = __weak id<ContentSuggestionsAlertCommands> 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:^{
ContentSuggestionsMostVisitedItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler [weakCommandHandler
openNewTabWithMostVisitedItem:strongItem openNewTabWithMostVisitedItem:strongItem
...@@ -140,7 +136,7 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item ...@@ -140,7 +136,7 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
addItemWithTitle:l10n_util::GetNSStringWithFixup( addItemWithTitle:l10n_util::GetNSStringWithFixup(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
action:^{ action:^{
ContentSuggestionsMostVisitedItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler [weakCommandHandler
openNewTabWithMostVisitedItem:strongItem openNewTabWithMostVisitedItem:strongItem
...@@ -154,7 +150,7 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item ...@@ -154,7 +150,7 @@ alertCoordinatorForMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
addItemWithTitle:l10n_util::GetNSStringWithFixup( addItemWithTitle:l10n_util::GetNSStringWithFixup(
IDS_IOS_CONTENT_SUGGESTIONS_REMOVE) IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)
action:^{ action:^{
ContentSuggestionsMostVisitedItem* strongItem = weakItem; CollectionViewItem* strongItem = weakItem;
if (strongItem) { if (strongItem) {
[weakCommandHandler removeMostVisited:strongItem]; [weakCommandHandler removeMostVisited:strongItem];
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#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,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#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"
...@@ -66,8 +66,8 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -66,8 +66,8 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
} // namespace } // namespace
@interface ContentSuggestionsCoordinator ()< @interface ContentSuggestionsCoordinator ()<
ContentSuggestionsAlertCommands,
ContentSuggestionsCommands, ContentSuggestionsCommands,
ContentSuggestionsGestureCommands,
ContentSuggestionsHeaderViewControllerCommandHandler, ContentSuggestionsHeaderViewControllerCommandHandler,
ContentSuggestionsHeaderViewControllerDelegate, ContentSuggestionsHeaderViewControllerDelegate,
ContentSuggestionsViewControllerAudience, ContentSuggestionsViewControllerAudience,
...@@ -219,18 +219,14 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -219,18 +219,14 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
rendererInitiated:NO]; rendererInitiated:NO];
} }
- (void)displayContextMenuForSuggestion:(CollectionViewItem*)item - (void)displayContextMenuForArticle:(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:suggestionsItem alertCoordinatorForSuggestionItem:item
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];
...@@ -239,10 +235,8 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -239,10 +235,8 @@ 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:mostVisitedItem alertCoordinatorForMostVisitedItem:item
onViewController:self.suggestionsViewController onViewController:self.suggestionsViewController
atPoint:touchLocation atPoint:touchLocation
atIndexPath:indexPath atIndexPath:indexPath
...@@ -282,54 +276,52 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab"; ...@@ -282,54 +276,52 @@ const char kNTPHelpURL[] = "https://support.google.com/chrome/?p=new_tab";
rendererInitiated:NO]; rendererInitiated:NO];
} }
#pragma mark - ContentSuggestionsGestureCommands #pragma mark - ContentSuggestionsAlertCommands
- (void)openNewTabWithSuggestionsItem:(ContentSuggestionsItem*)item - (void)openNewTabWithSuggestionsItem:(CollectionViewItem*)item
incognito:(BOOL)incognito { incognito:(BOOL)incognito {
[self openNewTabWithURL:item.URL incognito:incognito]; ContentSuggestionsItem* suggestionsItem =
base::mac::ObjCCastStrict<ContentSuggestionsItem>(item);
[self openNewTabWithURL:suggestionsItem.URL incognito:incognito];
} }
- (void)addItemToReadingList:(ContentSuggestionsItem*)item { - (void)addItemToReadingList:(CollectionViewItem*)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(item.URL, base::SysNSStringToUTF8(item.title), readingModel->AddEntry(suggestionsItem.URL,
base::SysNSStringToUTF8(suggestionsItem.title),
reading_list::ADDED_VIA_CURRENT_APP); reading_list::ADDED_VIA_CURRENT_APP);
} }
- (void)dismissSuggestion:(ContentSuggestionsItem*)item - (void)dismissSuggestion:(CollectionViewItem*)item
atIndexPath:(NSIndexPath*)indexPath { atIndexPath:(NSIndexPath*)indexPath {
NSIndexPath* itemIndexPath = indexPath; ContentSuggestionsItem* suggestionsItem =
if (!itemIndexPath) { base::mac::ObjCCastStrict<ContentSuggestionsItem>(item);
// 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 dismissSuggestion:item.suggestionIdentifier]; [self.contentSuggestionsMediator
[self.suggestionsViewController dismissEntryAtIndexPath:itemIndexPath]; dismissSuggestion:suggestionsItem.suggestionIdentifier];
[self.suggestionsViewController dismissEntryAtIndexPath:indexPath];
} }
- (void)openNewTabWithMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item - (void)openNewTabWithMostVisitedItem:(CollectionViewItem*)item
incognito:(BOOL)incognito incognito:(BOOL)incognito
atIndex:(NSInteger)index { atIndex:(NSInteger)index {
[self logMostVisitedOpening:item atIndex:index]; ContentSuggestionsMostVisitedItem* mostVisitedItem =
[self openNewTabWithURL:item.URL incognito:incognito]; base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item);
} [self logMostVisitedOpening:mostVisitedItem atIndex:index];
[self openNewTabWithURL:mostVisitedItem.URL incognito:incognito];
- (void)openNewTabWithMostVisitedItem:(ContentSuggestionsMostVisitedItem*)item
incognito:(BOOL)incognito {
NSInteger index =
[self.suggestionsViewController.collectionViewModel indexPathForItem:item]
.item;
[self openNewTabWithMostVisitedItem:item incognito:incognito atIndex:index];
} }
- (void)removeMostVisited:(ContentSuggestionsMostVisitedItem*)item { - (void)removeMostVisited:(CollectionViewItem*)item {
ContentSuggestionsMostVisitedItem* mostVisitedItem =
base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item);
base::RecordAction(base::UserMetricsAction("MostVisited_UrlBlacklisted")); base::RecordAction(base::UserMetricsAction("MostVisited_UrlBlacklisted"));
[self.contentSuggestionsMediator blacklistMostVisitedURL:item.URL]; [self.contentSuggestionsMediator blacklistMostVisitedURL:mostVisitedItem.URL];
[self showMostVisitedUndoForURL:item.URL]; [self showMostVisitedUndoForURL:mostVisitedItem.URL];
} }
#pragma mark - ContentSuggestionsHeaderViewControllerDelegate #pragma mark - ContentSuggestionsHeaderViewControllerDelegate
......
...@@ -25,7 +25,6 @@ class MostVisitedSites; ...@@ -25,7 +25,6 @@ class MostVisitedSites;
} }
@protocol ContentSuggestionsCommands; @protocol ContentSuggestionsCommands;
@protocol ContentSuggestionsGestureCommands;
@protocol ContentSuggestionsHeaderProvider; @protocol ContentSuggestionsHeaderProvider;
@class ContentSuggestionIdentifier; @class ContentSuggestionIdentifier;
class GURL; class GURL;
...@@ -50,9 +49,8 @@ initWithContentService: ...@@ -50,9 +49,8 @@ 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) @property(nonatomic, weak, nullable) id<ContentSuggestionsCommands>
id<ContentSuggestionsCommands, ContentSuggestionsGestureCommands> commandHandler;
commandHandler;
@property(nonatomic, weak, nullable) id<ContentSuggestionsHeaderProvider> @property(nonatomic, weak, nullable) id<ContentSuggestionsHeaderProvider>
headerProvider; headerProvider;
......
...@@ -452,7 +452,6 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService ...@@ -452,7 +452,6 @@ 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,7 +64,6 @@ ContentSuggestionsItem* ConvertSuggestion( ...@@ -64,7 +64,6 @@ 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,7 +4,6 @@ ...@@ -4,7 +4,6 @@
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",
......
...@@ -16,8 +16,6 @@ class Time; ...@@ -16,8 +16,6 @@ class Time;
@class FaviconAttributes; @class FaviconAttributes;
class GURL; class GURL;
@protocol ContentSuggestionsGestureCommands;
// Delegate for SuggestedContent. // Delegate for SuggestedContent.
@protocol ContentSuggestionsItemDelegate @protocol ContentSuggestionsItemDelegate
...@@ -50,10 +48,6 @@ class GURL; ...@@ -50,10 +48,6 @@ 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,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#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"
...@@ -47,8 +46,6 @@ ...@@ -47,8 +46,6 @@
@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
...@@ -78,7 +75,6 @@ ...@@ -78,7 +75,6 @@
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 {
...@@ -125,67 +121,4 @@ ...@@ -125,67 +121,4 @@
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,7 +37,6 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { ...@@ -37,7 +37,6 @@ 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]);
...@@ -55,7 +54,6 @@ TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { ...@@ -55,7 +54,6 @@ 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
...@@ -141,24 +139,4 @@ TEST(ContentSuggestionsItemTest, ImageAnimatedOnlyTheFirstTime) { ...@@ -141,24 +139,4 @@ 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,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#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;
...@@ -27,9 +26,6 @@ class GURL; ...@@ -27,9 +26,6 @@ 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,13 +4,10 @@ ...@@ -4,13 +4,10 @@
#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)
...@@ -24,7 +21,6 @@ ...@@ -24,7 +21,6 @@
@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];
...@@ -39,7 +35,6 @@ ...@@ -39,7 +35,6 @@
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 {
...@@ -57,51 +52,4 @@ ...@@ -57,51 +52,4 @@
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,12 +18,10 @@ ...@@ -18,12 +18,10 @@
// 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 |suggestionItem|. // Displays a context menu for the |articleItem|.
- (void)displayContextMenuForSuggestion: - (void)displayContextMenuForArticle:(nonnull CollectionViewItem*)articleItem
(nonnull CollectionViewItem*)suggestionItem atPoint:(CGPoint)touchLocation
atPoint:(CGPoint)touchLocation atIndexPath:(nonnull NSIndexPath*)indexPath;
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
......
...@@ -476,17 +476,9 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) { ...@@ -476,17 +476,9 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
switch (type) { switch (type) {
case ContentSuggestionTypeArticle: case ContentSuggestionTypeArticle:
[self.suggestionCommandHandler [self.suggestionCommandHandler
displayContextMenuForSuggestion:touchedItem displayContextMenuForArticle: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