| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #endif // defined(OS_WIN) | 9 #endif // defined(OS_WIN) |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/i18n/file_util_icu.h" | 14 #include "base/i18n/file_util_icu.h" |
| 15 #include "base/md5.h" | 15 #include "base/md5.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/stringprintf.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 21 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 24 #include "content/browser/download/download_file.h" | 25 #include "content/browser/download/download_file.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 | 27 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 std::wstring app_id = ShellIntegration::GetAppId( | 284 std::wstring app_id = ShellIntegration::GetAppId( |
| 284 UTF8ToWide(app_name), profile_path); | 285 UTF8ToWide(app_name), profile_path); |
| 285 | 286 |
| 286 FilePath shortcut_to_pin; | 287 FilePath shortcut_to_pin; |
| 287 | 288 |
| 288 bool success = true; | 289 bool success = true; |
| 289 for (size_t i = 0; i < shortcut_paths.size(); ++i) { | 290 for (size_t i = 0; i < shortcut_paths.size(); ++i) { |
| 290 FilePath shortcut_file = shortcut_paths[i].Append(file_name). | 291 FilePath shortcut_file = shortcut_paths[i].Append(file_name). |
| 291 ReplaceExtension(FILE_PATH_LITERAL(".lnk")); | 292 ReplaceExtension(FILE_PATH_LITERAL(".lnk")); |
| 292 | 293 |
| 293 int unique_number = DownloadFile::GetUniquePathNumber(shortcut_file); | 294 int unique_number = |
| 295 file_util::GetUniquePathNumber(shortcut_file, FILE_PATH_LITERAL("")); |
| 294 if (unique_number == -1) { | 296 if (unique_number == -1) { |
| 295 success = false; | 297 success = false; |
| 296 continue; | 298 continue; |
| 297 } else if (unique_number > 0) { | 299 } else if (unique_number > 0) { |
| 298 DownloadFile::AppendNumberToPath(&shortcut_file, unique_number); | 300 shortcut_file = shortcut_file.InsertBeforeExtensionASCII( |
| 301 StringPrintf(" (%d)", unique_number)); |
| 299 } | 302 } |
| 300 | 303 |
| 301 success &= file_util::CreateShortcutLink(chrome_exe.value().c_str(), | 304 success &= file_util::CreateShortcutLink(chrome_exe.value().c_str(), |
| 302 shortcut_file.value().c_str(), | 305 shortcut_file.value().c_str(), |
| 303 chrome_folder.value().c_str(), | 306 chrome_folder.value().c_str(), |
| 304 wide_switches.c_str(), | 307 wide_switches.c_str(), |
| 305 description.c_str(), | 308 description.c_str(), |
| 306 icon_file.value().c_str(), | 309 icon_file.value().c_str(), |
| 307 0, | 310 0, |
| 308 app_id.c_str()); | 311 app_id.c_str()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 476 |
| 474 #if defined(TOOLKIT_USES_GTK) | 477 #if defined(TOOLKIT_USES_GTK) |
| 475 std::string GetWMClassFromAppName(std::string app_name) { | 478 std::string GetWMClassFromAppName(std::string app_name) { |
| 476 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); | 479 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 477 TrimString(app_name, "_", &app_name); | 480 TrimString(app_name, "_", &app_name); |
| 478 return app_name; | 481 return app_name; |
| 479 } | 482 } |
| 480 #endif | 483 #endif |
| 481 | 484 |
| 482 } // namespace web_app | 485 } // namespace web_app |
| OLD | NEW |