Index: chrome/browser/web_applications/web_app_win.cc |
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc |
index 1cf48002624b3cc6c5c7e390b71f94e65e31f88e..56321f3598e48b8a343562368e9f9972260af4d0 100644 |
--- a/chrome/browser/web_applications/web_app_win.cc |
+++ b/chrome/browser/web_applications/web_app_win.cc |
@@ -32,8 +32,6 @@ namespace { |
const base::FilePath::CharType kIconChecksumFileExt[] = |
FILE_PATH_LITERAL(".ico.md5"); |
-// Width and height of icons exported to .ico files. |
- |
// Calculates checksum of an icon family using MD5. |
// The checksum is derived from all of the icons in the family. |
void GetImageCheckSum(const gfx::ImageFamily& image, base::MD5Digest* digest) { |
@@ -173,12 +171,8 @@ bool CreateShortcutsInPaths( |
} |
// Generates file name to use with persisted ico and shortcut file. |
- base::FilePath file_name = |
- web_app::internals::GetSanitizedFileName(shortcut_info.title); |
- |
- // Creates an ico file to use with shortcut. |
- base::FilePath icon_file = web_app_path.Append(file_name).AddExtension( |
- FILE_PATH_LITERAL(".ico")); |
+ base::FilePath icon_file = |
+ web_app::internals::GetIconFilePath(web_app_path, shortcut_info.title); |
if (!web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon)) { |
return false; |
} |
@@ -214,8 +208,11 @@ bool CreateShortcutsInPaths( |
bool success = true; |
for (size_t i = 0; i < shortcut_paths.size(); ++i) { |
- base::FilePath shortcut_file = shortcut_paths[i].Append(file_name). |
- AddExtension(installer::kLnkExt); |
+ base::FilePath shortcut_file = |
+ shortcut_paths[i] |
+ .Append( |
+ web_app::internals::GetSanitizedFileName(shortcut_info.title)) |
+ .AddExtension(installer::kLnkExt); |
if (creation_reason == web_app::SHORTCUT_CREATION_AUTOMATED) { |
// Check whether there is an existing shortcut to this app. |
std::vector<base::FilePath> shortcut_files = |
@@ -335,10 +332,24 @@ base::FilePath CreateShortcutInWebAppDir( |
std::vector<base::FilePath> paths; |
paths.push_back(web_app_dir); |
std::vector<base::FilePath> out_filenames; |
- CreateShortcutsInPaths(web_app_dir, shortcut_info, paths, |
- SHORTCUT_CREATION_BY_USER, &out_filenames); |
- DCHECK_EQ(out_filenames.size(), 1u); |
- return out_filenames[0]; |
+ base::FilePath web_app_dir_shortcut = |
+ web_app_dir.Append(web_app::internals::GetSanitizedFileName( |
+ shortcut_info.title)) |
+ .AddExtension(installer::kLnkExt); |
+ if (!PathExists(web_app_dir_shortcut)) { |
+ CreateShortcutsInPaths(web_app_dir, |
+ shortcut_info, |
+ paths, |
+ SHORTCUT_CREATION_BY_USER, |
+ &out_filenames); |
+ DCHECK_EQ(out_filenames.size(), 1u); |
+ DCHECK_EQ(out_filenames[0].value(), web_app_dir_shortcut.value()); |
+ } else { |
+ web_app::internals::CheckAndSaveIcon( |
benwells
2014/03/27 01:53:22
Nit: you don't need web_app:: here.
|
+ web_app::internals::GetIconFilePath(web_app_dir, shortcut_info.title), |
+ shortcut_info.favicon); |
+ } |
+ return web_app_dir_shortcut; |
} |
namespace internals { |
@@ -442,8 +453,8 @@ void UpdatePlatformShortcuts( |
// If an icon file exists, and is out of date, replace it with the new icon |
// and let the shell know the icon has been modified. |
- base::FilePath icon_file = web_app_path.Append(file_name).AddExtension( |
- FILE_PATH_LITERAL(".ico")); |
+ base::FilePath icon_file = |
+ web_app::internals::GetIconFilePath(web_app_path, shortcut_info.title); |
benwells
2014/03/27 01:53:22
Nit: you don't need the namespace here as you're i
|
if (base::PathExists(icon_file)) { |
web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); |
} |
@@ -535,6 +546,12 @@ std::vector<base::FilePath> GetShortcutPaths( |
return shortcut_paths; |
} |
+base::FilePath GetIconFilePath(const base::FilePath& web_app_path, |
+ const base::string16& title) { |
+ return web_app_path.Append(web_app::internals::GetSanitizedFileName(title)) |
+ .AddExtension(FILE_PATH_LITERAL(".ico")); |
+} |
+ |
} // namespace internals |
} // namespace web_app |