Commit b05b183c authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Mac: fix PWA drag crash

content::GetContentClient()->browser() is null in the app shim, so we
currently crash when trying to fetch a default download file name.

A while ago, we discussed pumping the default name through Mojo, but
my thinking is that this is a lot of complexity for little gain.

This change uses a blank string as the default instead of trying to
fetch one from the browser if the browser is null. Empirically, in an
us/en locale on macOS 10.15.6, we end up with "download.png", which
is (IMO) better than the default "download" anyway. If this ends up
being a problem, we can always pipe through the default later, but
let's fix the crash for now.


Bug: 1019128
Change-Id: I5e941511b3c479841e172a30b72bf69c2c8782f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431546
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Leonard Grey <lgrey@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810634}
parent 506bf33e
......@@ -298,8 +298,11 @@ using content::DropData;
&_downloadURL)) {
// Generate the file name based on both mime type and proposed file
// name.
std::string defaultName =
content::GetContentClient()->browser()->GetDefaultDownloadName();
std::string defaultName = content::GetContentClient()->browser()
? content::GetContentClient()
->browser()
->GetDefaultDownloadName()
: std::string();
mimeType = base::UTF16ToUTF8(mimeType16);
_downloadFileName =
net::GenerateFileName(_downloadURL,
......
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