Mac: Fix positioning of default open/save dialog (issue #1740)

This commit is contained in:
Marshall Greenblatt
2015-10-22 10:02:04 -04:00
parent 211c81cb14
commit 018f9b0f9a

View File

@@ -440,8 +440,12 @@ void RunOpenFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
[openPanel setShowsHiddenFiles:!params.hidereadonly]; [openPanel setShowsHiddenFiles:!params.hidereadonly];
// Show panel. // Show panel.
[openPanel beginSheetModalForWindow:[view window] completionHandler:nil]; [openPanel beginSheetModalForWindow:[view window]
if ([openPanel runModal] == NSFileHandlingPanelOKButton) { completionHandler:^(NSInteger returnCode) {
[NSApp stopModalWithCode:returnCode];
}];
NSInteger result = [NSApp runModalForWindow:[view window]];
if (result == NSFileHandlingPanelOKButton) {
NSArray *urls = [openPanel URLs]; NSArray *urls = [openPanel URLs];
int i, count = [urls count]; int i, count = [urls count];
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
@@ -453,8 +457,6 @@ void RunOpenFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
if (filter_delegate != nil) if (filter_delegate != nil)
*filter_index = [filter_delegate filter]; *filter_index = [filter_delegate filter];
[NSApp endSheet:openPanel];
} }
bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params, bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
@@ -503,9 +505,14 @@ bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
bool success = false; bool success = false;
[savePanel beginSheetModalForWindow:[view window] completionHandler:nil]; // Show panel.
if ([savePanel runModal] == NSFileHandlingPanelOKButton) { [savePanel beginSheetModalForWindow:[view window]
NSURL * url = [savePanel URL]; completionHandler:^(NSInteger resultCode) {
[NSApp stopModalWithCode:resultCode];
}];
NSInteger result = [NSApp runModalForWindow:[view window]];
if (result == NSFileHandlingPanelOKButton) {
NSURL* url = [savePanel URL];
NSString* path = [url path]; NSString* path = [url path];
*file = base::FilePath([path UTF8String]); *file = base::FilePath([path UTF8String]);
success = true; success = true;
@@ -514,8 +521,6 @@ bool RunSaveFileDialog(const CefBrowserHostImpl::FileChooserParams& params,
if (filter_delegate != nil) if (filter_delegate != nil)
*filter_index = [filter_delegate filter]; *filter_index = [filter_delegate filter];
[NSApp endSheet:savePanel];
return success; return success;
} }