diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 16:13:39 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 16:13:39 +0000 |
commit | 5a2388a2c13aa47b42357f16e336fbe7fcb3f407 (patch) | |
tree | 7d5b4caaec28b7c0e5f7ad41f9051c1b07bac92d /chrome/browser/web_applications | |
parent | ea05398d96221f8cc20939bad5fe52d4b11d3bd4 (diff) | |
download | chromium_src-5a2388a2c13aa47b42357f16e336fbe7fcb3f407.zip chromium_src-5a2388a2c13aa47b42357f16e336fbe7fcb3f407.tar.gz chromium_src-5a2388a2c13aa47b42357f16e336fbe7fcb3f407.tar.bz2 |
Append a number to make app shortcut name unique.
- Move DownloadManager's unique path helpers into download utils;
- Use those functions to make shortcut file name unqiue.
BUG=642
TEST=Verify fixes for issue 642.
Review URL: http://codereview.chromium.org/1276003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 9eebef4..b5714b2 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -21,6 +21,7 @@ #include "base/scoped_ptr.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_constants.h" @@ -378,10 +379,21 @@ bool CreateShortcutTask::CreateShortcut() { web_app::GenerateApplicationNameFromURL(shortcut_info_.url).c_str(), profile_path_); + FilePath shortcut_to_pin; + bool success = true; for (size_t i = 0; i < shortcut_paths.size(); ++i) { FilePath shortcut_file = shortcut_paths[i].Append(file_name). ReplaceExtension(FILE_PATH_LITERAL(".lnk")); + + int unique_number = download_util::GetUniquePathNumber(shortcut_file); + if (unique_number == -1) { + success = false; + continue; + } else if (unique_number > 0) { + download_util::AppendNumberToPath(&shortcut_file, unique_number); + } + success &= file_util::CreateShortcutLink(chrome_exe.c_str(), shortcut_file.value().c_str(), chrome_folder.c_str(), @@ -390,13 +402,20 @@ bool CreateShortcutTask::CreateShortcut() { icon_file.value().c_str(), 0, app_id.c_str()); + + // Any shortcut would work for the pinning. We use the first one. + if (success && pin_to_taskbar && shortcut_to_pin.empty()) + shortcut_to_pin = shortcut_file; } if (success && pin_to_taskbar) { - // Any shortcut would work for the pinning. We use the first one. - FilePath shortcut_file = shortcut_paths[0].Append(file_name). - ReplaceExtension(FILE_PATH_LITERAL(".lnk")); - success &= file_util::TaskbarPinShortcutLink(shortcut_file.value().c_str()); + if (!shortcut_to_pin.empty()) { + success &= file_util::TaskbarPinShortcutLink( + shortcut_to_pin.value().c_str()); + } else { + NOTREACHED(); + success = false; + } } return success; |