diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 18:02:41 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 18:02:41 +0000 |
commit | a0b60cfd11d0bcccb80c703a1030e083b9e0a3ca (patch) | |
tree | 756890f4dbf9aeac0963ea64fd15dd98b25ec167 /chrome/browser/shell_integration_linux.cc | |
parent | 862829ebd7c09e5fb888996eead25b86325eaa67 (diff) | |
download | chromium_src-a0b60cfd11d0bcccb80c703a1030e083b9e0a3ca.zip chromium_src-a0b60cfd11d0bcccb80c703a1030e083b9e0a3ca.tar.gz chromium_src-a0b60cfd11d0bcccb80c703a1030e083b9e0a3ca.tar.bz2 |
Add the calculated WMClass to generated .desktop files.
(Also modifies it so that we only modify the wmclass_name, and not the
wmclass_class because the internal application names aren't meant for display
and are very ugly.)
BUG=20587
TEST=Verify with xprop that the WM_CLASS of application desktop links mmatches the StartupWMClass key in the desktop file.
Review URL: http://codereview.chromium.org/6759076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration_linux.cc')
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index b6bd6a6..1c67825 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -29,6 +29,7 @@ #include "base/task.h" #include "base/threading/thread.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "content/browser/browser_thread.h" @@ -360,8 +361,11 @@ FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { // static std::string ShellIntegration::GetDesktopFileContents( - const std::string& template_contents, const GURL& url, - const std::string& extension_id, const string16& title, + const std::string& template_contents, + const std::string& app_name, + const GURL& url, + const std::string& extension_id, + const string16& title, const std::string& icon_name) { // See http://standards.freedesktop.org/desktop-entry-spec/latest/ // Although not required by the spec, Nautilus on Ubuntu Karmic creates its @@ -410,6 +414,9 @@ std::string ShellIntegration::GetDesktopFileContents( } else if (tokenizer.token().substr(0, 9) == "MimeType=") { // Skip MimeType lines, they are only relevant for a web browser // shortcut, not a web application shortcut. + } else if (tokenizer.token().substr(0, 15) == "StartupWMClass=") { + // Skip StartupWMClass; it will certainly be wrong since we emit a + // different one based on the app name below. } else if (tokenizer.token().substr(0, 5) == "Icon=" && !icon_name.empty()) { output_buffer += StringPrintf("Icon=%s\n", icon_name.c_str()); @@ -417,6 +424,12 @@ std::string ShellIntegration::GetDesktopFileContents( output_buffer += tokenizer.token() + "\n"; } } + + std::string wmclass = web_app::GetWMClassFromAppName(app_name); + if (!wmclass.empty()) { + output_buffer += StringPrintf("StartupWMClass=%s\n", wmclass.c_str()); + } + return output_buffer; } @@ -433,9 +446,15 @@ void ShellIntegration::CreateDesktopShortcut( std::string icon_name = CreateShortcutIcon(shortcut_info, shortcut_filename); + std::string app_name = + web_app::GenerateApplicationNameFromInfo(shortcut_info); std::string contents = GetDesktopFileContents( - shortcut_template, shortcut_info.url, shortcut_info.extension_id, - shortcut_info.title, icon_name); + shortcut_template, + app_name, + shortcut_info.url, + shortcut_info.extension_id, + shortcut_info.title, + icon_name); if (shortcut_info.create_on_desktop) CreateShortcutOnDesktop(shortcut_filename, contents); |