summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.mm
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 22:33:05 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 22:33:05 +0000
commit947fc0d47d45a01dc8608b3043254db66ae2a9da (patch)
treec1ec741201722ed9f4ad2d1e92ec4703ee57d8ea /chrome/browser/app_controller_mac.mm
parentcc3b22f0e594edd70742ddb79dd9dd5c59cf0186 (diff)
downloadchromium_src-947fc0d47d45a01dc8608b3043254db66ae2a9da.zip
chromium_src-947fc0d47d45a01dc8608b3043254db66ae2a9da.tar.gz
chromium_src-947fc0d47d45a01dc8608b3043254db66ae2a9da.tar.bz2
Fix command-click on buttons in background windows to perform their action in the context of the background window's controller, not the one associated with the foreground window. Command-click on back/fwd button in a background window doesn't have any special open disposition like it does in fg window.
BUG=16191 TEST=menus, key commands, button command dispatching should all still work for foreground and background windows. Test cmd-clicking buttons in a browser when a non-browser is the foreground window. Review URL: http://codereview.chromium.org/543044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r--chrome/browser/app_controller_mac.mm35
1 files changed, 31 insertions, 4 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 08d61b8..4ad4d9f 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -523,13 +523,25 @@ static bool g_is_opening_new_window = false;
return enable;
}
-// Called when the user picks a menu item when there are no key windows. Calls
-// through to the browser object to execute the command. This assumes that the
-// command is supported and doesn't check, otherwise it would have been disabled
-// in the UI in validateUserInterfaceItem:.
+// Called when the user picks a menu item when there are no key windows, or when
+// there is no foreground browser window. Calls through to the browser object to
+// execute the command. This assumes that the command is supported and doesn't
+// check, otherwise it would have been disabled in the UI in
+// validateUserInterfaceItem:.
- (void)commandDispatch:(id)sender {
Profile* defaultProfile = [self defaultProfile];
+ // Handle the case where we're dispatching a command from a sender that's in a
+ // browser window. This means that the command came from a background window
+ // and is getting here because the foreground window is not a browser window.
+ if ([sender respondsToSelector:@selector(window)]) {
+ id delegate = [[sender window] windowController];
+ if ([delegate isKindOfClass:[BrowserWindowController class]]) {
+ [delegate commandDispatch:sender];
+ return;
+ }
+ }
+
NSInteger tag = [sender tag];
switch (tag) {
case IDC_NEW_TAB:
@@ -604,6 +616,21 @@ static bool g_is_opening_new_window = false;
};
}
+// Same as |-commandDispatch:|, but executes commands using a disposition
+// determined by the key flags. This will get called in the case where the
+// frontmost window is not a browser window, and the user has command-clicked
+// a button in a background browser window whose action is
+// |-commandDispatchUsingKeyModifiers:|
+- (void)commandDispatchUsingKeyModifiers:(id)sender {
+ DCHECK(sender);
+ if ([sender respondsToSelector:@selector(window)]) {
+ id delegate = [[sender window] windowController];
+ if ([delegate isKindOfClass:[BrowserWindowController class]]) {
+ [delegate commandDispatchUsingKeyModifiers:sender];
+ }
+ }
+}
+
// NSApplication delegate method called when someone clicks on the
// dock icon and there are no open windows. To match standard mac
// behavior, we should open a new window.