WebApps: Adds support for handling mimetypes in WebApps on Linux.
This lets web apps that can handle files show up in the
open-with menu on Linux.
Note: This is still experimental and hidden behind the
NativeFileSystemAPI and FileHandlingAPI flags.
In addition, some work needs to be done to register custom mimetypes
with the operating system as in:
https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html
Bug: 829689
Change-Id: I92bcc07cb5dffaa715c409bc6cf07c8410db34ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833027
Commit-Queue: Jay Harris <[email protected]>
Reviewed-by: Thomas Anderson <[email protected]>
Reviewed-by: Alexey Baskakov <[email protected]>
Reviewed-by: Alan Cutter <[email protected]>
Cr-Commit-Position: refs/heads/master@{#710593}
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index e000c6c..688a4ad6 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -497,21 +497,22 @@
return shortcut_paths;
}
-std::string GetDesktopFileContents(
- const base::FilePath& chrome_exe_path,
- const std::string& app_name,
- const GURL& url,
- const std::string& extension_id,
- const base::string16& title,
- const std::string& icon_name,
- const base::FilePath& profile_path,
- const std::string& categories,
- bool no_display) {
+std::string GetDesktopFileContents(const base::FilePath& chrome_exe_path,
+ const std::string& app_name,
+ const GURL& url,
+ const std::string& extension_id,
+ const base::string16& title,
+ const std::string& icon_name,
+ const base::FilePath& profile_path,
+ const std::string& categories,
+ const std::string& mime_type,
+ bool no_display) {
base::CommandLine cmd_line = shell_integration::CommandLineArgsForLauncher(
url, extension_id, profile_path);
cmd_line.SetProgram(chrome_exe_path);
return GetDesktopFileContentsForCommand(cmd_line, app_name, url, title,
- icon_name, categories, no_display);
+ icon_name, categories, mime_type,
+ no_display);
}
std::string GetDesktopFileContentsForCommand(
@@ -521,6 +522,7 @@
const base::string16& title,
const std::string& icon_name,
const std::string& categories,
+ const std::string& mime_type,
bool no_display) {
#if defined(USE_GLIB)
// Although not required by the spec, Nautilus on Ubuntu Karmic creates its
@@ -565,6 +567,13 @@
key_file, kDesktopEntry, "Categories", categories.c_str());
}
+ // Set the "MimeType" key.
+ if (!mime_type.empty() && mime_type.find("\n") == std::string::npos &&
+ mime_type.find("\r") == std::string::npos) {
+ g_key_file_set_string(key_file, kDesktopEntry, "MimeType",
+ mime_type.c_str());
+ }
+
// Set the "NoDisplay" key.
if (no_display)
g_key_file_set_string(key_file, kDesktopEntry, "NoDisplay", "true");