Commit 9f80fa7b authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Relax checks about NSOpenPanel's underlying type in SelectFileDialogBridge.

In Catalina, sometimes (under unclear circumstances) the NS{Open,Save}Panel
objects do not go through the remote panel view system. Instead, NSOpenPanel
returns a non-exported AppKit type NSLocalOpenPanel, which does not have any
is-a relationship to a NSSave/OpenPanel. The type checks in
SelectFileDialogBridge cause failures when this happens, so relax them.

Test: `./Chromium.app/Contents/MacOS/Chromium -NSUseRemoteSavePanel NO`
      and go to "data:text/html,<input type=file>" in the Omnibox.
      Upload a file and no crash should occur.

Bug: 995476
Change-Id: If57acb94ef7d92784cdb5f6e48f4ea908f2bbdce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860995
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705742}
parent 24daacdf
...@@ -234,7 +234,9 @@ void SelectFileDialogBridge::Show( ...@@ -234,7 +234,9 @@ void SelectFileDialogBridge::Show(
[dialog setCanSelectHiddenExtension:YES]; [dialog setCanSelectHiddenExtension:YES];
} }
} else { } else {
NSOpenPanel* open_dialog = base::mac::ObjCCastStrict<NSOpenPanel>(dialog); // This does not use ObjCCast because the underlying object could be a
// non-exported AppKit type (https://crbug.com/995476).
NSOpenPanel* open_dialog = static_cast<NSOpenPanel*>(dialog);
if (type_ == SelectFileDialogType::kOpenMultiFile) if (type_ == SelectFileDialogType::kOpenMultiFile)
[open_dialog setAllowsMultipleSelection:YES]; [open_dialog setAllowsMultipleSelection:YES];
...@@ -394,7 +396,6 @@ void SelectFileDialogBridge::OnPanelEnded(bool did_cancel) { ...@@ -394,7 +396,6 @@ void SelectFileDialogBridge::OnPanelEnded(bool did_cancel) {
index = 1; index = 1;
} }
} else { } else {
CHECK([panel_ isKindOfClass:[NSOpenPanel class]]);
NSArray* urls = [static_cast<NSOpenPanel*>(panel_) URLs]; NSArray* urls = [static_cast<NSOpenPanel*>(panel_) URLs];
for (NSURL* url in urls) for (NSURL* url in urls)
if ([url isFileURL]) if ([url isFileURL])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment