| Index: ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm
|
| diff --git a/ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm b/ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm
|
| index c0f282e11961bd320d93c3a32e8e781c9d004b11..7e1d6443ee3905972bc98bc47b66c558eff266ab 100644
|
| --- a/ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm
|
| +++ b/ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm
|
| @@ -5,6 +5,7 @@
|
| #import "ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.h"
|
|
|
| #include "base/logging.h"
|
| +#import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h"
|
| #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context.h"
|
|
|
| #if !defined(__has_feature) || !__has_feature(objc_arc)
|
| @@ -14,19 +15,6 @@
|
| namespace {
|
| // Typedef the block parameter for UIAlertAction for readability.
|
| typedef void (^AlertActionHandler)(UIAlertAction*);
|
| -// Sends |commands| to |dispatcher| using |context| as the menu context.
|
| -void DispatchContextMenuCommands(const std::vector<SEL>& commands,
|
| - id dispatcher,
|
| - ContextMenuContext* context) {
|
| - DCHECK(dispatcher);
|
| - DCHECK(context);
|
| -#pragma clang diagnostic push
|
| -#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
| - for (SEL command : commands) {
|
| - [dispatcher performSelector:command withObject:context];
|
| - }
|
| -#pragma clang diagnostic pop
|
| -}
|
| }
|
|
|
| @interface ContextMenuViewController ()
|
| @@ -87,7 +75,18 @@ - (UIAlertAction*)alertActionForItem:(ContextMenuItem*)item
|
| DCHECK(item);
|
| // Create a block that dispatches |item|'s ContextMenuCommands.
|
| AlertActionHandler handler = ^(UIAlertAction* action) {
|
| - DispatchContextMenuCommands(item.commands, self.dispatcher, self.context);
|
| +#pragma clang diagnostic push
|
| +#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
| + // TODO: Convert to DCHECK once all commands are implemented.
|
| + if (item.command)
|
| + [self.dispatcher performSelector:item.command withObject:self.context];
|
| + // If the command opens a new tab, the context menu will be hidden
|
| + // automatically. If not, dispatch |-hideMenuContext:| to stop the menu UI.
|
| + if (!item.commandOpensTab) {
|
| + [self.dispatcher performSelector:@selector(hideContextMenu:)
|
| + withObject:self.context];
|
| + }
|
| +#pragma clang diagnostic pop
|
| };
|
| return [UIAlertAction actionWithTitle:item.title style:style handler:handler];
|
| }
|
|
|