| 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 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 l10n_util::GetApplicationLocale(std::string())); | 224 l10n_util::GetApplicationLocale(std::string())); |
| 225 | 225 |
| 226 NSString* strings_path = base::mac::FilePathToNSString( | 226 NSString* strings_path = base::mac::FilePathToNSString( |
| 227 localized.Append(locale + ".strings")); | 227 localized.Append(locale + ".strings")); |
| 228 [strings_dict writeToFile:strings_path | 228 [strings_dict writeToFile:strings_path |
| 229 atomically:YES]; | 229 atomically:YES]; |
| 230 } | 230 } |
| 231 | 231 |
| 232 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { | 232 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { |
| 233 DCHECK(!app_path.empty()); | 233 DCHECK(!app_path.empty()); |
| 234 base::Delete(app_path, true); | 234 base::DeleteFile(app_path, true); |
| 235 base::FilePath apps_folder = app_path.DirName(); | 235 base::FilePath apps_folder = app_path.DirName(); |
| 236 if (file_util::IsDirectoryEmpty(apps_folder)) | 236 if (file_util::IsDirectoryEmpty(apps_folder)) |
| 237 base::Delete(apps_folder, false); | 237 base::DeleteFile(apps_folder, false); |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool IsShimForProfile(const base::FilePath& base_name, | 240 bool IsShimForProfile(const base::FilePath& base_name, |
| 241 const std::string& profile_base_name) { | 241 const std::string& profile_base_name) { |
| 242 if (!StartsWithASCII(base_name.value(), profile_base_name, true)) | 242 if (!StartsWithASCII(base_name.value(), profile_base_name, true)) |
| 243 return false; | 243 return false; |
| 244 | 244 |
| 245 if (base_name.Extension() != ".app") | 245 if (base_name.Extension() != ".app") |
| 246 return false; | 246 return false; |
| 247 | 247 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 void WebAppShortcutCreator::DeleteShortcuts() { | 421 void WebAppShortcutCreator::DeleteShortcuts() { |
| 422 // TODO(jackhou): For the first two cases, we need to check if the | 422 // TODO(jackhou): For the first two cases, we need to check if the |
| 423 // user_data_dir matches that of the current browser process. | 423 // user_data_dir matches that of the current browser process. |
| 424 base::FilePath dst_path = GetDestinationPath(); | 424 base::FilePath dst_path = GetDestinationPath(); |
| 425 if (!dst_path.empty()) | 425 if (!dst_path.empty()) |
| 426 DeletePathAndParentIfEmpty(dst_path.Append(GetShortcutName())); | 426 DeletePathAndParentIfEmpty(dst_path.Append(GetShortcutName())); |
| 427 | 427 |
| 428 // In case the user has moved/renamed/copied the app bundle. | 428 // In case the user has moved/renamed/copied the app bundle. |
| 429 base::FilePath bundle_path = GetAppBundleById(GetBundleIdentifier()); | 429 base::FilePath bundle_path = GetAppBundleById(GetBundleIdentifier()); |
| 430 if (!bundle_path.empty()) | 430 if (!bundle_path.empty()) |
| 431 base::Delete(bundle_path, true); | 431 base::DeleteFile(bundle_path, true); |
| 432 | 432 |
| 433 // Delete the internal one. | 433 // Delete the internal one. |
| 434 DeletePathAndParentIfEmpty(app_data_path_.Append(GetShortcutName())); | 434 DeletePathAndParentIfEmpty(app_data_path_.Append(GetShortcutName())); |
| 435 } | 435 } |
| 436 | 436 |
| 437 bool WebAppShortcutCreator::UpdateShortcuts() { | 437 bool WebAppShortcutCreator::UpdateShortcuts() { |
| 438 std::vector<base::FilePath> paths; | 438 std::vector<base::FilePath> paths; |
| 439 base::Delete(app_data_path_.Append(GetShortcutName()), true); | 439 base::DeleteFile(app_data_path_.Append(GetShortcutName()), true); |
| 440 paths.push_back(app_data_path_); | 440 paths.push_back(app_data_path_); |
| 441 | 441 |
| 442 base::FilePath dst_path = GetDestinationPath(); | 442 base::FilePath dst_path = GetDestinationPath(); |
| 443 base::FilePath app_path = dst_path.Append(GetShortcutName()); | 443 base::FilePath app_path = dst_path.Append(GetShortcutName()); |
| 444 | 444 |
| 445 // If the path does not exist, check if a matching bundle can be found | 445 // If the path does not exist, check if a matching bundle can be found |
| 446 // elsewhere. | 446 // elsewhere. |
| 447 if (dst_path.empty() || !base::PathExists(app_path)) | 447 if (dst_path.empty() || !base::PathExists(app_path)) |
| 448 app_path = GetAppBundleById(GetBundleIdentifier()); | 448 app_path = GetAppBundleById(GetBundleIdentifier()); |
| 449 | 449 |
| 450 if (!app_path.empty()) { | 450 if (!app_path.empty()) { |
| 451 base::Delete(app_path, true); | 451 base::DeleteFile(app_path, true); |
| 452 paths.push_back(app_path.DirName()); | 452 paths.push_back(app_path.DirName()); |
| 453 } | 453 } |
| 454 | 454 |
| 455 size_t success_count = CreateShortcutsIn(paths); | 455 size_t success_count = CreateShortcutsIn(paths); |
| 456 if (success_count == 0) | 456 if (success_count == 0) |
| 457 return false; | 457 return false; |
| 458 | 458 |
| 459 UpdateInternalBundleIdentifier(); | 459 UpdateInternalBundleIdentifier(); |
| 460 return success_count == paths.size() && !app_path.empty(); | 460 return success_count == paths.size() && !app_path.empty(); |
| 461 } | 461 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 BuildShortcutInfoFromBundle(*it); | 703 BuildShortcutInfoFromBundle(*it); |
| 704 WebAppShortcutCreator shortcut_creator( | 704 WebAppShortcutCreator shortcut_creator( |
| 705 it->DirName(), shortcut_info, base::mac::BaseBundleID()); | 705 it->DirName(), shortcut_info, base::mac::BaseBundleID()); |
| 706 shortcut_creator.DeleteShortcuts(); | 706 shortcut_creator.DeleteShortcuts(); |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 | 709 |
| 710 } // namespace internals | 710 } // namespace internals |
| 711 | 711 |
| 712 } // namespace web_app | 712 } // namespace web_app |
| OLD | NEW |