Commit f49defcf authored by Jay Harris's avatar Jay Harris Committed by Commit Bot

WebApps: Make file handlers show up in Nautilus and Nemo file managers.

Previously, Nautilus and Nemo would know that file handling web apps
could handle files, but not what types of files. This meant that web
apps would not show up in the "Open With" menus of these file handlers.

The cause of this issue was two fold:
1. xdg-desktop-menu install my-file.desktop only runs update-desktop-database
   when installing a system wide desktop file (in Chrome, we only ever install
   in user mode).
2. update-desktop-database doesn't run on ~/.local/share/applications unless
   explicitly requested to.

This meant that the mimeinfo.cache file in ~/.local/share/applications (which
these file managers use to determine what apps can open different mime types)
was not being updated.

The fix is to run update-desktop-database $XDG_DATA_HOME/applications after
installing a new entry in the desktop menu, to ensure mimeinfo.cache is updated.

Bug: 1027994
Change-Id: Ia71fa4d49030ecec6622a5b0ab8e18facc303274
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002043
Commit-Queue: Jay Harris <harrisjay@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732212}
parent 40db5521
...@@ -170,7 +170,31 @@ bool CreateShortcutInApplicationsMenu(const base::FilePath& shortcut_filename, ...@@ -170,7 +170,31 @@ bool CreateShortcutInApplicationsMenu(const base::FilePath& shortcut_filename,
argv.push_back(temp_file_path.value()); argv.push_back(temp_file_path.value());
int exit_code; int exit_code;
shell_integration_linux::LaunchXdgUtility(argv, &exit_code); shell_integration_linux::LaunchXdgUtility(argv, &exit_code);
return exit_code == 0;
if (exit_code != 0)
return false;
// Some Linux file managers (Nautilus and Nemo) depend on an up to date
// mimeinfo.cache file to detect whether applications can open files, so
// manually run update-desktop-database on the user applications folder.
// See this bug on xdg desktop-file-utils
// https://gitlab.freedesktop.org/xdg/desktop-file-utils/issues/54
std::unique_ptr<base::Environment> env(base::Environment::Create());
base::FilePath user_applications_dir =
shell_integration_linux::GetDataWriteLocation(env.get()).Append(
"applications");
argv.clear();
argv.push_back("update-desktop-database");
argv.push_back(user_applications_dir.value());
// Ignore the exit code of update-desktop-database, if it fails it isn't
// important (the shortcut is created and usable when xdg-desktop-menu install
// completes). Failure means the file type associations for this desktop entry
// may not show up in some file managers, but this is non-critical.
int ignored_exit_code = 0;
shell_integration_linux::LaunchXdgUtility(argv, &ignored_exit_code);
return true;
} }
} // namespace } // namespace
......
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