Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Unified Diff: ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm

Issue 2965963002: [ios] Remove IDC_STOP and IDC_RELOAD
Patch Set: Rebased. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
diff --git a/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm b/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
index 8f0e860a9cfaf242d9741c79d40bc6c56d561366..3928cfaaeef81e1aa96e549d6a4b1edf3b9ed995 100644
--- a/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
+++ b/ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm
@@ -14,6 +14,7 @@
#include "ios/chrome/browser/experimental_flags.h"
#import "ios/chrome/browser/ui/animation_util.h"
#import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
+#import "ios/chrome/browser/ui/commands/browser_commands.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_menu_notification_delegate.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h"
@@ -133,6 +134,7 @@ NS_INLINE void AnimateInViews(NSArray* views,
@synthesize toolbarType = _toolbarType;
@synthesize menuItems = _menuItems;
@synthesize delegate = _delegate;
+@synthesize dispatcher = _dispatcher;
@synthesize requestStartTime = _requestStartTime;
#pragma mark Public methods
@@ -459,16 +461,23 @@ NS_INLINE void AnimateInViews(NSArray* views,
[toolsButton removeTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
- for (UIButton* button in [[self toolsCell] allButtons]) {
+ ToolsMenuViewToolsCell* toolsCell = [self toolsCell];
+ for (UIButton* button in [toolsCell allButtons]) {
[button removeTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
}
+ [toolsCell.stopButton removeTarget:self.dispatcher
+ action:@selector(stopLoading)
+ forControlEvents:UIControlEventTouchUpInside];
+ [toolsCell.reloadButton removeTarget:self.dispatcher
+ action:@selector(reload)
+ forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - Button event handling
-- (IBAction)buttonPressed:(id)sender {
+- (void)buttonPressed:(id)sender {
int commandId = [sender tag];
DCHECK(commandId);
// The bookmark command workaround is only needed for metrics; remap it
@@ -478,12 +487,15 @@ NS_INLINE void AnimateInViews(NSArray* views,
if (commandId == IDC_TEMP_EDIT_BOOKMARK)
[sender setTag:IDC_BOOKMARK_PAGE];
// Do nothing when tapping the tools menu a second time.
- if (commandId != IDC_SHOW_TOOLS_MENU) {
+ // Do not use -chromeExecuteCommand: for tags < 0 -- that is, items that have
+ // been refactored to use the dispatcher.
+ if (commandId != IDC_SHOW_TOOLS_MENU && commandId > 0) {
[self chromeExecuteCommand:sender];
}
if (commandId == IDC_TEMP_EDIT_BOOKMARK)
[sender setTag:IDC_TEMP_EDIT_BOOKMARK];
+ // Do any metrics logging for the command, and then close the menu.
[_delegate commandWasSelected:commandId];
}
@@ -576,11 +588,22 @@ NS_INLINE void AnimateInViews(NSArray* views,
ToolsMenuViewToolsCell* cell =
[view dequeueReusableCellWithReuseIdentifier:kToolsItemCellID
forIndexPath:path];
+ // Add specific target/action dispatch for buttons refactored away from
+ // ChromeExecuteCommand. These need to be added *before* -buttonPressed:,
+ // because -buttonPressed: closes the popup menu, which will usually
+ // destroy the buttons before any other actions can be called.
+ [cell.stopButton addTarget:self.dispatcher
+ action:@selector(stopLoading)
+ forControlEvents:UIControlEventTouchUpInside];
+ [cell.reloadButton addTarget:self.dispatcher
+ action:@selector(reload)
+ forControlEvents:UIControlEventTouchUpInside];
for (UIButton* button in [cell allButtons]) {
[button addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
}
+
return cell;
}

Powered by Google App Engine
This is Rietveld 408576698