| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_win.h" | 5 #include "chrome/browser/web_applications/web_app_win.h" |
| 6 | 6 |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 std::vector<base::FilePath> shortcut_files = | 313 std::vector<base::FilePath> shortcut_files = |
| 314 FindAppShortcutsByProfileAndTitle(*i, profile_path, title); | 314 FindAppShortcutsByProfileAndTitle(*i, profile_path, title); |
| 315 if (shortcut_paths && !shortcut_files.empty()) { | 315 if (shortcut_paths && !shortcut_files.empty()) { |
| 316 shortcut_paths->push_back(*i); | 316 shortcut_paths->push_back(*i); |
| 317 } | 317 } |
| 318 for (std::vector<base::FilePath>::const_iterator j = shortcut_files.begin(); | 318 for (std::vector<base::FilePath>::const_iterator j = shortcut_files.begin(); |
| 319 j != shortcut_files.end(); ++j) { | 319 j != shortcut_files.end(); ++j) { |
| 320 // Any shortcut could have been pinned, either by chrome or the user, so | 320 // Any shortcut could have been pinned, either by chrome or the user, so |
| 321 // they are all unpinned. | 321 // they are all unpinned. |
| 322 base::win::TaskbarUnpinShortcutLink(j->value().c_str()); | 322 base::win::TaskbarUnpinShortcutLink(j->value().c_str()); |
| 323 base::Delete(*j, false); | 323 base::DeleteFile(*j, false); |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace | 328 } // namespace |
| 329 | 329 |
| 330 namespace web_app { | 330 namespace web_app { |
| 331 | 331 |
| 332 base::FilePath CreateShortcutInWebAppDir( | 332 base::FilePath CreateShortcutInWebAppDir( |
| 333 const base::FilePath& web_app_dir, | 333 const base::FilePath& web_app_dir, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 const ShellIntegration::ShortcutInfo& shortcut_info) { | 454 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 455 GetShortcutLocationsAndDeleteShortcuts( | 455 GetShortcutLocationsAndDeleteShortcuts( |
| 456 web_app_path, shortcut_info.profile_path, shortcut_info.title, NULL, | 456 web_app_path, shortcut_info.profile_path, shortcut_info.title, NULL, |
| 457 NULL); | 457 NULL); |
| 458 | 458 |
| 459 // If there are no more shortcuts in the Chrome Apps subdirectory, remove it. | 459 // If there are no more shortcuts in the Chrome Apps subdirectory, remove it. |
| 460 base::FilePath chrome_apps_dir; | 460 base::FilePath chrome_apps_dir; |
| 461 if (PathService::Get(base::DIR_START_MENU, &chrome_apps_dir)) { | 461 if (PathService::Get(base::DIR_START_MENU, &chrome_apps_dir)) { |
| 462 chrome_apps_dir = chrome_apps_dir.Append(GetAppShortcutsSubdirName()); | 462 chrome_apps_dir = chrome_apps_dir.Append(GetAppShortcutsSubdirName()); |
| 463 if (file_util::IsDirectoryEmpty(chrome_apps_dir)) | 463 if (file_util::IsDirectoryEmpty(chrome_apps_dir)) |
| 464 base::Delete(chrome_apps_dir, false); | 464 base::DeleteFile(chrome_apps_dir, false); |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 | 467 |
| 468 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { | 468 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { |
| 469 GetShortcutLocationsAndDeleteShortcuts(base::FilePath(), profile_path, L"", | 469 GetShortcutLocationsAndDeleteShortcuts(base::FilePath(), profile_path, L"", |
| 470 NULL, NULL); | 470 NULL, NULL); |
| 471 | 471 |
| 472 // If there are no more shortcuts in the Chrome Apps subdirectory, remove it. | 472 // If there are no more shortcuts in the Chrome Apps subdirectory, remove it. |
| 473 base::FilePath chrome_apps_dir; | 473 base::FilePath chrome_apps_dir; |
| 474 if (PathService::Get(base::DIR_START_MENU, &chrome_apps_dir)) { | 474 if (PathService::Get(base::DIR_START_MENU, &chrome_apps_dir)) { |
| 475 chrome_apps_dir = chrome_apps_dir.Append(GetAppShortcutsSubdirName()); | 475 chrome_apps_dir = chrome_apps_dir.Append(GetAppShortcutsSubdirName()); |
| 476 if (file_util::IsDirectoryEmpty(chrome_apps_dir)) | 476 if (file_util::IsDirectoryEmpty(chrome_apps_dir)) |
| 477 base::Delete(chrome_apps_dir, false); | 477 base::DeleteFile(chrome_apps_dir, false); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 std::vector<base::FilePath> GetShortcutPaths( | 481 std::vector<base::FilePath> GetShortcutPaths( |
| 482 const ShellIntegration::ShortcutLocations& creation_locations) { | 482 const ShellIntegration::ShortcutLocations& creation_locations) { |
| 483 // Shortcut paths under which to create shortcuts. | 483 // Shortcut paths under which to create shortcuts. |
| 484 std::vector<base::FilePath> shortcut_paths; | 484 std::vector<base::FilePath> shortcut_paths; |
| 485 // Locations to add to shortcut_paths. | 485 // Locations to add to shortcut_paths. |
| 486 struct { | 486 struct { |
| 487 bool use_this_location; | 487 bool use_this_location; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 path = path.Append(locations[i].subdir); | 524 path = path.Append(locations[i].subdir); |
| 525 shortcut_paths.push_back(path); | 525 shortcut_paths.push_back(path); |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 return shortcut_paths; | 528 return shortcut_paths; |
| 529 } | 529 } |
| 530 | 530 |
| 531 } // namespace internals | 531 } // namespace internals |
| 532 | 532 |
| 533 } // namespace web_app | 533 } // namespace web_app |
| OLD | NEW |