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/web_applications | |
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/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 31 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.h | 11 |
2 files changed, 34 insertions, 8 deletions
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index c4046c8..90e4071 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -10,8 +10,10 @@ #include "base/command_line.h" #include "base/file_util.h" +#include "base/i18n/file_util_icu.h" #include "base/md5.h" #include "base/path_service.h" +#include "base/string_util.h" #include "base/threading/thread.h" #include "base/utf_string_conversions.h" #include "base/win/windows_version.h" @@ -339,14 +341,8 @@ bool CreateShortcutTask::CreateShortcut() { shortcut_info_.description.resize(MAX_PATH - 1); // Generates app id from web app url and profile path. - std::string app_name; - if (!shortcut_info_.extension_id.empty()) { - app_name = web_app::GenerateApplicationNameFromExtensionId( - shortcut_info_.extension_id); - } else { - app_name = web_app::GenerateApplicationNameFromURL( - shortcut_info_.url); - } + std::string app_name = + web_app::GenerateApplicationNameFromInfo(shortcut_info_); std::wstring app_id = ShellIntegration::GetAppId( UTF8ToWide(app_name), profile_path_); @@ -454,6 +450,17 @@ FilePath GetWebAppDataDirectory(const FilePath& root_dir, } // namespace internals +std::string GenerateApplicationNameFromInfo( + const ShellIntegration::ShortcutInfo& shortcut_info) { + if (!shortcut_info.extension_id.empty()) { + return web_app::GenerateApplicationNameFromExtensionId( + shortcut_info.extension_id); + } else { + return web_app::GenerateApplicationNameFromURL( + shortcut_info.url); + } +} + std::string GenerateApplicationNameFromURL(const GURL& url) { std::string t; t.append(url.host()); @@ -514,4 +521,12 @@ void GetIconsInfo(const WebApplicationInfo& app_info, } #endif +#if defined(TOOLKIT_GTK) +std::string GetWMClassFromAppName(std::string app_name) { + file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); + TrimString(app_name, "_", &app_name); + return app_name; +} +#endif + } // namespace web_app diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index 7ccb33f..a0727e9 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -18,6 +18,10 @@ class Profile; namespace web_app { +// Compute a deterministic name based on data in the shortcut_info. +std::string GenerateApplicationNameFromInfo( + const ShellIntegration::ShortcutInfo& shortcut_info); + // Compute a deterministic name based on the URL. We use this pseudo name // as a key to store window location per application URLs in Browser and // as app id for BrowserWindow, shortcut and jump list. @@ -54,6 +58,13 @@ void GetIconsInfo(const WebApplicationInfo& app_info, IconInfoList* icons); #endif +#if defined(TOOLKIT_GTK) +// GTK+ windows that correspond to web apps need to have a deterministic (and +// different) WMClass than normal chrome windows so the window manager groups +// them as a separate application. +std::string GetWMClassFromAppName(std::string app_name); +#endif + namespace internals { #if defined(OS_WIN) |