| Index: chrome/browser/shell_integration_linux.cc
|
| diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
|
| index c74d7fe7eb9e18950bac5ea42ac8f38838e86a2f..0dadb576212a822a5205f67003ad7e7c3e5b704a 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() {
|
| + 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";
|
| @@ -591,7 +604,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(
|
| @@ -615,12 +628,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;
|
| @@ -847,7 +862,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);
|
| @@ -882,17 +899,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,
|
| @@ -903,7 +918,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;
|
| @@ -923,9 +938,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));
|
| }
|
|
|