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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 2605006: [Mac] Disable menu certain menu items when a modal dialog or sheet is present. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Remove confusion (or add more?) Created 10 years, 7 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
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 57f8ee87a180987315597a52c49206c131d1e8c8..84207622f81a824182d99d4384bd61a574ef678d 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -574,13 +574,15 @@ void RecordLastRunAppBundlePath() {
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 {
+// Returns true if there is not a modal window (either window- or application-
+// modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
+// sheets) will not count as blocking the browser. But things like open/save
+// dialogs that are window modal will block the browser.
+- (BOOL)keyWindowIsNotModal {
Browser* browser = BrowserList::GetLastActive();
- return browser == NULL ||
+ return [NSApp modalWindow] == nil && (browser &&
![[browser->window()->GetNativeHandle() attachedSheet]
- isKindOfClass:[NSWindow class]];
+ isKindOfClass:[NSWindow class]]);
}
// Called to validate menu items when there are no key windows. All the
@@ -602,11 +604,22 @@ void RecordLastRunAppBundlePath() {
// app_controller is only activated when there are no key windows (see
// function comment).
case IDC_RESTORE_TAB:
- enable = [self keyWindowIsMissingOrBlocked] && [self canRestoreTab];
+ enable = [self keyWindowIsNotModal] && [self canRestoreTab];
break;
+ // Browser-level items that open in new tabs should not open if there's
+ // a window- or app-modal dialog.
case IDC_OPEN_FILE:
case IDC_NEW_TAB:
- enable = [self keyWindowIsMissingOrBlocked];
+ case IDC_SHOW_HISTORY:
+ case IDC_SHOW_BOOKMARK_MANAGER:
+ enable = [self keyWindowIsNotModal];
+ break;
+ // Browser-level items that open in new windows.
+ case IDC_NEW_WINDOW:
+ case IDC_TASK_MANAGER:
+ // Allow the user to open a new window if there's a window-modal
+ // dialog.
+ enable = [self keyWindowIsNotModal] || ([NSApp modalWindow] == nil);
break;
case IDC_SYNC_BOOKMARKS: {
Profile* defaultProfile = [self defaultProfile];
@@ -621,12 +634,14 @@ void RecordLastRunAppBundlePath() {
<< "NULL defaultProfile detected -- not doing anything";
break;
}
- enable = ProfileSyncService::IsSyncEnabled();
+ enable = ProfileSyncService::IsSyncEnabled() &&
+ [self keyWindowIsNotModal];
sync_ui_util::UpdateSyncItem(item, enable, defaultProfile);
break;
}
default:
- enable = menuState_->IsCommandEnabled(tag) ? YES : NO;
+ enable = menuState_->IsCommandEnabled(tag) ?
+ [self keyWindowIsNotModal] : NO;
}
}
} else if (action == @selector(terminate:)) {
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698