summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/browser_window_controller.mm
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 17:18:31 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 17:18:31 +0000
commitfc256f3c6e4b3d0d20e449f112bf4ab900ac36a3 (patch)
tree2a4e15e2de0e856fafba16d674d8ac9184a62dd2 /chrome/browser/cocoa/browser_window_controller.mm
parent98c45033eb243d49211df0697fd7b2a699621c24 (diff)
downloadchromium_src-fc256f3c6e4b3d0d20e449f112bf4ab900ac36a3.zip
chromium_src-fc256f3c6e4b3d0d20e449f112bf4ab900ac36a3.tar.gz
chromium_src-fc256f3c6e4b3d0d20e449f112bf4ab900ac36a3.tar.bz2
Mac: Make Cmd-[ and Cmd-] work properly again.
I had accidentally made them open new tabs. I added a |-commandDispatchUsingKeyModifiers:| method to the browser window controller and made the back/forward buttons send this selector instead (this is how Toolbar.xib was changed). [N.B.: As of this writing, Cmd+Shift-back/forwards is broken, but that's a separate, non-Mac-specific, issue.] BUG=25810 TEST=Make sure Cmd-[ and Cmd-] work as expected (not opening history items in new tabs). Make sure back and forward buttons work properly (including while holding down Cmd and Cmd+Shift). Review URL: http://codereview.chromium.org/333026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller.mm')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm29
1 files changed, 15 insertions, 14 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index b6cc915..7edf5b4 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -549,11 +549,11 @@ willPositionSheet:(NSWindow*)sheet
}
// Called to validate menu and toolbar items when this window is key. All the
-// items we care about have been set with the |commandDispatch:| action and
-// a target of FirstResponder in IB. If it's not one of those, let it
-// continue up the responder chain to be handled elsewhere. We pull out the
-// tag as the cross-platform constant to differentiate and dispatch the
-// various commands.
+// items we care about have been set with the |-commandDispatch:| or
+// |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder
+// in IB. If it's not one of those, let it continue up the responder chain to be
+// handled elsewhere. We pull out the tag as the cross-platform constant to
+// differentiate and dispatch the various commands.
// NOTE: we might have to handle state for app-wide menu items,
// although we could cheat and directly ask the app controller if our
// command_updater doesn't support the command. This may or may not be an issue,
@@ -561,7 +561,8 @@ willPositionSheet:(NSWindow*)sheet
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
SEL action = [item action];
BOOL enable = NO;
- if (action == @selector(commandDispatch:)) {
+ if (action == @selector(commandDispatch:) ||
+ action == @selector(commandDispatchUsingKeyModifiers:)) {
NSInteger tag = [item tag];
if (browser_->command_updater()->SupportsCommand(tag)) {
// Generate return value (enabled state)
@@ -598,14 +599,6 @@ willPositionSheet:(NSWindow*)sheet
- (void)commandDispatch:(id)sender {
NSInteger tag = [sender tag];
switch (tag) {
- case IDC_FORWARD:
- case IDC_BACK:
- // For this, we need to check the key flags to figure out where to open
- // the history item. Note that |Revert()| isn't needed, since any
- // navigation in the current tab will reset the location bar's contents.
- browser_->ExecuteCommandWithDisposition(tag,
- event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]));
- return;
case IDC_RELOAD:
if ([sender isKindOfClass:[NSButton class]]) {
// We revert the bar when the reload button is pressed, but don't when
@@ -620,6 +613,14 @@ willPositionSheet:(NSWindow*)sheet
browser_->ExecuteCommand(tag);
}
+// Same as |-commandDispatch:|, but executes commands using a disposition
+// determined by the key flags.
+- (void)commandDispatchUsingKeyModifiers:(id)sender {
+ NSInteger tag = [sender tag];
+ browser_->ExecuteCommandWithDisposition(tag,
+ event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]));
+}
+
// Called when another part of the internal codebase needs to execute a
// command.
- (void)executeCommand:(int)command {