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

WebApps: Fixes file handler registration in the Cinnamon DE.

The Cinnamon Desktop Environment requires file handlers to specify a %F
argument to specify where file arguments should be placed. Other DEs
(such as Plasma) don't have this restriction.

The fix is to (conditionally) append a '%F' argument to the command line
of web apps with file handlers. If the argument is added unconditionally
all web apps will show up as options in the 'Choose Another App' dialog,
which is undesirable.

Bug: 1027994
Change-Id: I89f882c0854b3ee313fce6eea1845052a884c173
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933683
Commit-Queue: Jay Harris <harrisjay@google.com>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718892}
parent 36451543
...@@ -540,8 +540,25 @@ std::string GetDesktopFileContentsForCommand( ...@@ -540,8 +540,25 @@ std::string GetDesktopFileContentsForCommand(
} }
g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str());
base::CommandLine modified_command_line(command_line);
// 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());
// Some Linux Desktop Environments don't show file handlers unless they
// specify where to place file arguments.
// Note: We only include this parameter if the application is actually able
// to handle files, to prevent it showing up in the list of all applications
// which can handle files.
modified_command_line.AppendArg("%F");
}
// Set the "Exec" key. // Set the "Exec" key.
std::string final_path = QuoteCommandLineForDesktopFileExec(command_line); std::string final_path =
QuoteCommandLineForDesktopFileExec(modified_command_line);
g_key_file_set_string(key_file, kDesktopEntry, "Exec", final_path.c_str()); g_key_file_set_string(key_file, kDesktopEntry, "Exec", final_path.c_str());
// Set the "Icon" key. // Set the "Icon" key.
...@@ -558,13 +575,6 @@ std::string GetDesktopFileContentsForCommand( ...@@ -558,13 +575,6 @@ std::string GetDesktopFileContentsForCommand(
key_file, kDesktopEntry, "Categories", categories.c_str()); 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. // Set the "NoDisplay" key.
if (no_display) if (no_display)
g_key_file_set_string(key_file, kDesktopEntry, "NoDisplay", "true"); g_key_file_set_string(key_file, kDesktopEntry, "NoDisplay", "true");
......
...@@ -437,10 +437,10 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { ...@@ -437,10 +437,10 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) {
"Terminal=false\n" "Terminal=false\n"
"Type=Application\n" "Type=Application\n"
"Name=Paint\n" "Name=Paint\n"
"Exec=/opt/google/chrome/google-chrome --app=https://paint.app/\n" "MimeType=image/png;image/jpg\n"
"Exec=/opt/google/chrome/google-chrome --app=https://paint.app/ %F\n"
"Icon=chrome-https__paint.app\n" "Icon=chrome-https__paint.app\n"
"Categories=Image\n" "Categories=Image\n"
"MimeType=image/png;image/jpg\n"
"StartupWMClass=paint.app\n"}, "StartupWMClass=paint.app\n"},
// Test evil mime type. // Test evil mime type.
......
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