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

Unified Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 164547: Mac: make save/open dialogs operate as tab-modal sheets.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Painfully (but hopefully correctly) merged ToT. Created 11 years, 2 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/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/constrained_window_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/browser_window_controller.mm
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 3951e4c1dc2356393e1214fdf61de7d474ea96e4..d7c145c69da25f7bea28defdff48400cc5747761 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -197,7 +197,8 @@ willPositionSheet:(NSWindow*)sheet
initialWidth:NSWidth([[[self window] contentView] frame])
compressDelegate:toolbarController_.get()
resizeDelegate:self
- urlDelegate:self]);
+ urlDelegate:self
+ commands:browser->command_updater()]);
// Add bookmark bar to the view hierarchy. This also triggers the
// nib load. The bookmark bar is defined (in the nib) to be
@@ -509,7 +510,7 @@ willPositionSheet:(NSWindow*)sheet
}
// Update a toggle state for an NSMenuItem if modified.
-// Take care to insure |item| looks like a NSMenuItem.
+// Take care to ensure |item| looks like a NSMenuItem.
// Called by validateUserInterfaceItem:.
- (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item {
if (![item respondsToSelector:@selector(state)] ||
@@ -526,6 +527,7 @@ willPositionSheet:(NSWindow*)sheet
NSInteger newState = toggled ? NSOnState : NSOffState;
if (oldState != newState)
[item setState:newState];
+ return;
}
// Update the checked/Unchecked state of items in the encoding menu.
@@ -537,11 +539,10 @@ willPositionSheet:(NSWindow*)sheet
Profile *profile = browser_->profile();
DCHECK(profile);
TabContents* current_tab = browser_->GetSelectedTabContents();
- if (!current_tab) {
+ if (!current_tab)
return;
- }
- const std::string encoding = current_tab->encoding();
+ const std::string encoding = current_tab->encoding();
bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag);
NSInteger oldState = [item state];
NSInteger newState = toggled ? NSOnState : NSOffState;
@@ -571,8 +572,8 @@ willPositionSheet:(NSWindow*)sheet
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
SEL action = [item action];
BOOL enable = NO;
+ NSInteger tag = [item tag];
if (action == @selector(commandDispatch:)) {
- NSInteger tag = [item tag];
if (browser_->command_updater()->SupportsCommand(tag)) {
// Generate return value (enabled state)
enable = browser_->command_updater()->IsCommandEnabled(tag) ? YES : NO;
@@ -585,11 +586,19 @@ willPositionSheet:(NSWindow*)sheet
case IDC_RESTORE_TAB:
// We have to ask the Browser manually if we can restore. The
// command updater doesn't know.
- enable &= browser_->CanRestoreTab();
+ enable &= browser_->CanRestoreTab() ? YES : NO;
break;
case IDC_FULLSCREEN:
enable &= [self supportsFullscreen];
break;
+ default:
+ // Special handling for the contents of the encoding menu; we
+ // enable/disable them en masse.
+ EncodingMenuController encoding_controller;
+ if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
+ enable &= browser_->command_updater()->IsCommandEnabled(
+ IDC_ENCODING_MENU_CONTENTS) ? YES : NO;
+ }
}
// If the item is toggleable, find its toggle state and
@@ -597,6 +606,18 @@ willPositionSheet:(NSWindow*)sheet
// to check after a commandDispatch, which seems worse.
[self updateToggleStateWithTag:tag forItem:item];
}
+ } else {
+ // Use the command updater for enabled state anyway.
+ switch (tag) {
+ case IDC_EMAIL_PAGE_LOCATION:
+ case IDC_PRINT_PAGE_SETUP:
+ case IDC_PRINT:
+ enable = browser_->command_updater()->IsCommandEnabled(tag) ? YES : NO;
+ break;
+ default:
+ // This line intentionally left blank.
+ break;
+ }
}
return enable;
}
@@ -639,6 +660,14 @@ willPositionSheet:(NSWindow*)sheet
return verticalOffsetForStatusBubble_;
}
+- (ToolbarController*)toolbarController {
+ return toolbarController_.get();
+}
+
+- (InfoBarContainerController*)infoBarContainerController {
+ return infoBarContainerController_.get();
+}
+
- (GTMWindowSheetController*)sheetController {
return [tabStripController_ sheetController];
}
@@ -1170,11 +1199,25 @@ willPositionSheet:(NSWindow*)sheet
- (NSRect)window:(NSWindow*)window
willPositionSheet:(NSWindow*)sheet
usingRect:(NSRect)defaultSheetRect {
+#if 1
// Any sheet should come from right above the visible content area.
NSRect toolbarFrame = [[toolbarController_ view] frame];
NSRect infobarFrame = [[infoBarContainerController_ view] frame];
defaultSheetRect.origin.y = toolbarFrame.origin.y - infobarFrame.size.height;
-
+#elif 0
+ // FIXME(viettrungluu): I had this, which I think is better than the above.
+ // This hangs them below the toolbar (incl. bookmark bar), which is illogical
+ // but a bit more normal-looking (not quite, since the shading doesn't match).
+ NSView* tabContentView = [self tabContentArea];
+ NSRect tabContentFrame = [tabContentView frame];
+ defaultSheetRect.origin.y = tabContentFrame.origin.y +
+ tabContentFrame.size.height;
+#else
+ // This was the original, hanging window-modal sheets off the title bar, which
+ // was logical but weird-looking.
+ NSRect windowFrame = [window frame];
+ defaultSheetRect.origin.y = windowFrame.size.height - 10;
+#endif
return defaultSheetRect;
}
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/constrained_window_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698