summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 17:41:06 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 17:41:06 +0000
commit6a281339e3a8d4eff65d18046850b7dc81a55f10 (patch)
tree0afe0481b2b45d87eddf93b9a7afba681c61dfaf /chrome
parentb00ea183194c6af56878bab4ebd443fe43f46280 (diff)
downloadchromium_src-6a281339e3a8d4eff65d18046850b7dc81a55f10.zip
chromium_src-6a281339e3a8d4eff65d18046850b7dc81a55f10.tar.gz
chromium_src-6a281339e3a8d4eff65d18046850b7dc81a55f10.tar.bz2
The file menu was enabled even when a browser window was obscured by a modal dialog. This fix disables these menu items while the dialog window is up.
BUG= http://crbug.com/23864 TEST= Open the "open file" file chooser window with cmd-o (or from the menu). Attempt to open a new tab, window, or file. Note that you cannot. Close the file chooser window, and note that these menu items are now enabled again. Review URL: http://codereview.chromium.org/269035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/app_controller_mac.mm22
1 files changed, 21 insertions, 1 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 9690a81..bf35e93 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -422,6 +422,15 @@
return service && !service->entries().empty();
}
+// Returns true if there is no browser window, or if the active window is
+// blocked by a modal dialog.
+- (BOOL)keyWindowIsMissingOrBlocked {
+ Browser* browser = BrowserList::GetLastActive();
+ return browser == NULL ||
+ ![[browser->window()->GetNativeHandle() attachedSheet]
+ isKindOfClass:[NSWindow class]];
+}
+
// Called to validate menu items when there are no key windows. 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
@@ -436,7 +445,18 @@
if (menuState_->SupportsCommand(tag)) {
switch (tag) {
case IDC_RESTORE_TAB:
- enable = [self canRestoreTab];
+ enable = [self keyWindowIsMissingOrBlocked] && [self canRestoreTab];
+ break;
+ // The File Menu commands are not automatically disabled by Cocoa when
+ // a dialog sheet obscures the browser window, so we disable them here.
+ // We don't need to include IDC_CLOSE_WINDOW, because app_controller
+ // is only activated when there are no key windows (see function
+ // comment).
+ case IDC_OPEN_FILE:
+ case IDC_NEW_WINDOW:
+ case IDC_NEW_TAB:
+ case IDC_NEW_INCOGNITO_WINDOW:
+ enable = [self keyWindowIsMissingOrBlocked];
break;
default:
enable = menuState_->IsCommandEnabled(tag) ? YES : NO;