| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/clean/chrome/browser/ui/context_menu/context_menu_mediator.h" | 5 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_mediator.h" |
| 6 | 6 |
| 7 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" | 7 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" |
| 8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_consumer.h" | 8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_consumer.h" |
| 9 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" | 9 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
| 10 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 10 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 [items addObjectsFromArray:[self linkItems]]; | 50 [items addObjectsFromArray:[self linkItems]]; |
| 51 BOOL showImageOptions = context.imageURL.is_valid(); | 51 BOOL showImageOptions = context.imageURL.is_valid(); |
| 52 if (showImageOptions) | 52 if (showImageOptions) |
| 53 [items addObjectsFromArray:[self imageItems]]; | 53 [items addObjectsFromArray:[self imageItems]]; |
| 54 [consumer setContextMenuItems:[items copy] cancelItem:[self cancelItem]]; | 54 [consumer setContextMenuItems:[items copy] cancelItem:[self cancelItem]]; |
| 55 } | 55 } |
| 56 | 56 |
| 57 #pragma mark - | 57 #pragma mark - |
| 58 | 58 |
| 59 + (ContextMenuItem*)scriptItem { | 59 + (ContextMenuItem*)scriptItem { |
| 60 std::vector<SEL> commands(2U); | 60 return [ContextMenuItem itemWithTitle:@"Execute Script" |
| 61 commands[0] = @selector(executeContextMenuScript:); | 61 command:@selector(executeContextMenuScript:) |
| 62 commands[1] = @selector(hideContextMenu:); | 62 commandOpensTab:NO]; |
| 63 return [ContextMenuItem itemWithTitle:@"Execute Script" commands:commands]; | |
| 64 } | 63 } |
| 65 | 64 |
| 66 + (NSArray<ContextMenuItem*>*)linkItems { | 65 + (NSArray<ContextMenuItem*>*)linkItems { |
| 67 // Opening the link in a new Tab will stop this context menu's coordinator, so | 66 // TODO: Supply commands and update |commandOpensTab| accordingly once |
| 68 // there's no need to hide it. | 67 // incognito and link copying are implemented. |
| 69 std::vector<SEL> newTabCommands(1U); | |
| 70 newTabCommands[0] = @selector(openContextMenuLinkInNewTab:); | |
| 71 // TODO: Add |-openContextMenuLinkInNewIncognitoTab:| as the first command for | |
| 72 // "Open In New Incognito Tab" once the incognito tab grid is implemented. | |
| 73 std::vector<SEL> newIncognitoTabCommands(1U); | |
| 74 newIncognitoTabCommands[0] = @selector(hideContextMenu:); | |
| 75 // TODO: Add |-copyContextMenuLink:| as the first command for "Copy Link" once | |
| 76 // copying to pasteboard is implemented. | |
| 77 std::vector<SEL> copyLinkCommands(1U); | |
| 78 newIncognitoTabCommands[0] = @selector(hideContextMenu:); | |
| 79 return @[ | 68 return @[ |
| 80 [ContextMenuItem itemWithTitle:@"Open In New Tab" commands:newTabCommands], | 69 [ContextMenuItem itemWithTitle:@"Open In New Tab" |
| 70 command:@selector(openContextMenuLinkInNewTab:) |
| 71 commandOpensTab:YES], |
| 81 [ContextMenuItem itemWithTitle:@"Open In New Incognito Tab" | 72 [ContextMenuItem itemWithTitle:@"Open In New Incognito Tab" |
| 82 commands:newIncognitoTabCommands], | 73 command:nil |
| 83 [ContextMenuItem itemWithTitle:@"Copy Link" commands:copyLinkCommands], | 74 commandOpensTab:NO], |
| 75 [ContextMenuItem itemWithTitle:@"Copy Link" command:nil commandOpensTab:NO], |
| 84 ]; | 76 ]; |
| 85 } | 77 } |
| 86 | 78 |
| 87 + (NSArray<ContextMenuItem*>*)imageItems { | 79 + (NSArray<ContextMenuItem*>*)imageItems { |
| 88 // TODO: Add |-saveContextMenuImage:| as the first command for "Save Image" | 80 // TODO: Supply commands and update |commandOpensTab| accordingly once image |
| 89 // once camera roll access has been implemented. | 81 // saving is implemented. |
| 90 std::vector<SEL> saveImageCommands(1U); | |
| 91 saveImageCommands[0] = @selector(hideContextMenu:); | |
| 92 std::vector<SEL> openImageCommands(2U); | |
| 93 openImageCommands[0] = @selector(openContextMenuImage:); | |
| 94 openImageCommands[1] = @selector(hideContextMenu:); | |
| 95 // Opening the image in a new Tab will stop this context menu's coordinator, | |
| 96 // so there's no need to hide it. | |
| 97 std::vector<SEL> openImageInNewTabCommands(1U); | |
| 98 openImageInNewTabCommands[0] = @selector(openContextMenuImageInNewTab:); | |
| 99 return @[ | 82 return @[ |
| 100 [ContextMenuItem itemWithTitle:@"Save Image" commands:saveImageCommands], | 83 [ContextMenuItem itemWithTitle:@"Save Image" |
| 101 [ContextMenuItem itemWithTitle:@"Open Image" commands:openImageCommands], | 84 command:nil |
| 85 commandOpensTab:NO], |
| 86 [ContextMenuItem itemWithTitle:@"Open Image" |
| 87 command:@selector(openContextMenuImage:) |
| 88 commandOpensTab:NO], |
| 102 [ContextMenuItem itemWithTitle:@"Open Image In New Tab" | 89 [ContextMenuItem itemWithTitle:@"Open Image In New Tab" |
| 103 commands:openImageInNewTabCommands], | 90 command:@selector(openContextMenuImageInNewTab:) |
| 91 commandOpensTab:YES], |
| 104 ]; | 92 ]; |
| 105 } | 93 } |
| 106 | 94 |
| 107 + (ContextMenuItem*)cancelItem { | 95 + (ContextMenuItem*)cancelItem { |
| 108 std::vector<SEL> cancelCommands(1U); | 96 return |
| 109 cancelCommands[0] = @selector(hideContextMenu:); | 97 [ContextMenuItem itemWithTitle:@"Cancel" command:nil commandOpensTab:NO]; |
| 110 return [ContextMenuItem itemWithTitle:@"Cancel" commands:cancelCommands]; | |
| 111 } | 98 } |
| 112 | 99 |
| 113 @end | 100 @end |
| OLD | NEW |