Chromium Code Reviews| Index: chrome/browser/shell_integration_linux.cc |
| diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc |
| index 104cc31a23555af37afe6249b929ceff66ee1ae7..33ee0170c52e323ebe8cc7cc2bf597c713b1deb2 100644 |
| --- a/chrome/browser/shell_integration_linux.cc |
| +++ b/chrome/browser/shell_integration_linux.cc |
| @@ -40,6 +40,8 @@ |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_version_info.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "grit/chromium_strings.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/image/image_family.h" |
| #include "url/gurl.h" |
| @@ -277,6 +279,17 @@ std::string QuoteArgForDesktopFileExec(const std::string& arg) { |
| return quoted; |
| } |
| +// TODO(calamity): replace with |
| +// BrowserDistribution::GetStartMenuShortcutSubfolder() once |
| +// BrowserDistribution is cross-platform. |
| +// Gets the name of the Chrome Apps menu folder in which to place app shortcuts. |
| +string16 GetAppShortcutsSubdirName() { |
|
gab
2013/10/03 17:22:49
I would prefer having only a single copy of this m
calamity
2013/10/14 02:24:25
Done.
|
| + chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| + if (channel == chrome::VersionInfo::CHANNEL_CANARY) |
| + return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY); |
| + return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); |
| +} |
| + |
| const char kDesktopEntry[] = "Desktop Entry"; |
| const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open"; |
| @@ -595,7 +608,7 @@ ShellIntegration::ShortcutLocations GetExistingShortcutLocations( |
| // If Get returns false, just leave desktop_path empty. |
| PathService::Get(base::DIR_USER_DESKTOP, &desktop_path); |
| return GetExistingShortcutLocations(env, profile_path, extension_id, |
| - desktop_path); |
| + desktop_path); |
| } |
| ShellIntegration::ShortcutLocations GetExistingShortcutLocations( |
| @@ -619,12 +632,14 @@ ShellIntegration::ShortcutLocations GetExistingShortcutLocations( |
| // Determine whether there is a shortcut in the applications directory. |
| std::string shortcut_contents; |
| if (GetExistingShortcutContents(env, shortcut_filename, &shortcut_contents)) { |
| - // Whether this counts as "hidden" or "in_applications_menu" depends on |
| - // whether it contains NoDisplay=true. |
| + // Whether this counts as "hidden" or |
| + // "in_applications_menu_chrome_apps_subdir" depends on whether it contains |
| + // NoDisplay=true. Since these shortcuts are for apps, they are always in |
| + // the "Chrome Apps" directory. |
| if (GetNoDisplayFromDesktopFile(shortcut_contents)) |
| locations.hidden = true; |
| else |
| - locations.in_applications_menu = true; |
| + locations.in_applications_menu_chrome_apps_subdir = true; |
| } |
| return locations; |
| @@ -851,7 +866,9 @@ bool CreateDesktopShortcut( |
| // already exist and replace them. |
| if (creation_locations.on_desktop) |
| DeleteShortcutOnDesktop(shortcut_filename); |
| - if (creation_locations.in_applications_menu || creation_locations.hidden) |
| + // The 'InApplicationsMenu()' and 'hidden' locations are actually the same |
| + // place ('applications'). |
| + if (creation_locations.InApplicationsMenu() || creation_locations.hidden) |
| DeleteShortcutInApplicationsMenu(shortcut_filename, base::FilePath()); |
| } else { |
| shortcut_filename = GetWebShortcutFilename(shortcut_info.url); |
| @@ -886,17 +903,15 @@ bool CreateDesktopShortcut( |
| success = CreateShortcutOnDesktop(shortcut_filename, contents); |
| } |
| - // The 'in_applications_menu' and 'hidden' locations are actually the same |
| - // place ('applications'). |
| - if (creation_locations.in_applications_menu || creation_locations.hidden) { |
| + if (creation_locations.InApplicationsMenu() || creation_locations.hidden) { |
| base::FilePath directory_filename; |
| std::string directory_contents; |
| - if (!creation_locations.applications_menu_subdir.empty()) { |
| + if (creation_locations.in_applications_menu_chrome_apps_subdir) { |
| directory_filename = base::FilePath(kDirectoryFilename); |
| directory_contents = ShellIntegrationLinux::GetDirectoryFileContents( |
| - creation_locations.applications_menu_subdir, ""); |
| + GetAppShortcutsSubdirName(), ""); |
| } |
| - // Set NoDisplay=true if hidden but not in_applications_menu. This will hide |
| + // Set NoDisplay=true if hidden but not InApplicationsMenu(). This will hide |
| // the application from user-facing menus. |
| std::string contents = ShellIntegrationLinux::GetDesktopFileContents( |
| chrome_exe_path, |
| @@ -907,7 +922,7 @@ bool CreateDesktopShortcut( |
| shortcut_info.title, |
| icon_name, |
| shortcut_info.profile_path, |
| - !creation_locations.in_applications_menu); |
| + !creation_locations.InApplicationsMenu()); |
| success = CreateShortcutInApplicationsMenu( |
| shortcut_filename, contents, directory_filename, directory_contents) && |
| success; |
| @@ -927,9 +942,8 @@ void DeleteDesktopShortcuts(const base::FilePath& profile_path, |
| DeleteShortcutOnDesktop(shortcut_filename); |
| // Delete shortcuts from |kDirectoryFilename|. |
| // Note that it is possible that shortcuts were not created in the Chrome Apps |
| - // directory (depending on the value of |applications_menu_subdir| when they |
| - // were created). It doesn't matter: this will still delete the shortcut even |
| - // if it isn't in the directory. |
| + // directory. It doesn't matter: this will still delete the shortcut even if |
| + // it isn't in the directory. |
| DeleteShortcutInApplicationsMenu(shortcut_filename, |
| base::FilePath(kDirectoryFilename)); |
| } |