Browser-laptop: File extensions not auto added to some downloads

Created on 30 May 2016  路  18Comments  路  Source: brave/browser-laptop

Test plan

https://github.com/brave/browser-laptop/pull/11906#issue-273121960


I have a user report from support that file extensions are not being added for downloaded files. The user says they have to guess the file extension so the file gets saved.

OWindows Qchecked-Win64 Qtest-plan-specified bug featurdownload muon prioritP3 release-noteinclude

All 18 comments

Actually extensions are added automatically when downloading, but they are cleared if you change the file name of it.

STR:

  1. On Windows, download a file without changing the default file name
  2. Make sure the file extension is added automatically and retained
  3. Download a file, with changing the file name
  4. Make sure the default extension is cleared and you need to fill it by yourself, guessing which one it is.

I think this is a windows-only issue.

+1

This issue is indeed limited to Windows, and also affects the _Save As鈥 options.

I suspect the issue here is with the prompt receiving little more than a filename (source).

void WebContents::DownloadURL(const GURL& url, bool prompt_for_location) {
  auto browser_context = web_contents()->GetBrowserContext();
  auto download_manager = content::BrowserContext::GetDownloadManager(browser_context);
  auto params = content::DownloadUrlParameters::CreateForWebContentsMainFrame(web_contents(), url);
  if (prompt_for_location)
    params->set_prompt(prompt_for_location);
  download_manager->DownloadUrl(std::move(params));
}

In Brave, this results in a _All Files_ dialog, whereas Chrome filters on the extension. Note the different values for _Save as type_ in both of the screenshots below.

image

image

If you replace the filename in Brave, you have no way of telling what the proper extension ought to be. In Chrome, the extension will be enforced by the _Save as type_ option, even if the new filename lacks an extension.

macOS pre-selects the filename up to, but not including, the extension. This reduces the likelihood that the user will unintentionally mess up the extension.

image

A showSaveDialog method is defined in Electron, and preserved in Muon, that we might prefer. This method accepts a filters argument, allowing the _Save As_ dialog to focus exclusively on particular file types. Presumably, this is more than just a way to filter what is shown, but to enforce what can be saved.

Adding this to 0.20.x under the assumption that it's fairly straight-forward to use an alternative approach that supports explicit filter lists. If this isn't as straight-forward, please feel free to bump to another milestone.

When investigating this, it might be good to check this out: https://github.com/electron/electron/issues/10121 (fixed with https://github.com/electron/electron/pull/10469/files)

@zentagonist Is this not a proper STR? https://github.com/brave/browser-laptop/issues/1985#issuecomment-250883580

@bsclifton , the long term solution will be this https://github.com/brave/muon/issues/242
And I made some progress on it.

+1 from Twitter: https://twitter.com/meta_gear/status/945817220944363522:

_@brave Why does the browser not save files with their proper extensions? When I save an image it's just a generic file, not a .jpg or .png or whatever_

@darkdh I was just checking out that PR :) Any idea when that will be merged?

It requires https://github.com/brave/muon/pull/385 to be merged first. Muon PR is currently under reviewed

Blocked on #13230 #13228

Moving to 0.22.x; we're going to have 0.21.x-C65 only contain the Chromium upgrade 馃槃 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luixxiul picture luixxiul  路  3Comments

mykkymk picture mykkymk  路  3Comments

antiroyalty picture antiroyalty  路  3Comments

jonathansampson picture jonathansampson  路  3Comments

jonathansampson picture jonathansampson  路  3Comments