| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 l10n_util::GetApplicationLocale(std::string())); | 222 l10n_util::GetApplicationLocale(std::string())); |
| 223 | 223 |
| 224 NSString* strings_path = base::mac::FilePathToNSString( | 224 NSString* strings_path = base::mac::FilePathToNSString( |
| 225 localized.Append(locale + ".strings")); | 225 localized.Append(locale + ".strings")); |
| 226 [strings_dict writeToFile:strings_path | 226 [strings_dict writeToFile:strings_path |
| 227 atomically:YES]; | 227 atomically:YES]; |
| 228 } | 228 } |
| 229 | 229 |
| 230 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { | 230 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { |
| 231 DCHECK(!app_path.empty()); | 231 DCHECK(!app_path.empty()); |
| 232 file_util::Delete(app_path, true); | 232 base::Delete(app_path, true); |
| 233 base::FilePath apps_folder = app_path.DirName(); | 233 base::FilePath apps_folder = app_path.DirName(); |
| 234 if (file_util::IsDirectoryEmpty(apps_folder)) | 234 if (file_util::IsDirectoryEmpty(apps_folder)) |
| 235 file_util::Delete(apps_folder, false); | 235 base::Delete(apps_folder, false); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace | 238 } // namespace |
| 239 | 239 |
| 240 namespace web_app { | 240 namespace web_app { |
| 241 | 241 |
| 242 | 242 |
| 243 WebAppShortcutCreator::WebAppShortcutCreator( | 243 WebAppShortcutCreator::WebAppShortcutCreator( |
| 244 const base::FilePath& app_data_path, | 244 const base::FilePath& app_data_path, |
| 245 const ShellIntegration::ShortcutInfo& shortcut_info, | 245 const ShellIntegration::ShortcutInfo& shortcut_info, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 | 355 |
| 356 void WebAppShortcutCreator::DeleteShortcuts() { | 356 void WebAppShortcutCreator::DeleteShortcuts() { |
| 357 base::FilePath dst_path = GetDestinationPath(); | 357 base::FilePath dst_path = GetDestinationPath(); |
| 358 if (!dst_path.empty()) | 358 if (!dst_path.empty()) |
| 359 DeletePathAndParentIfEmpty(dst_path.Append(GetShortcutName())); | 359 DeletePathAndParentIfEmpty(dst_path.Append(GetShortcutName())); |
| 360 | 360 |
| 361 // In case the user has moved/renamed/copied the app bundle. | 361 // In case the user has moved/renamed/copied the app bundle. |
| 362 base::FilePath bundle_path = GetAppBundleById(GetBundleIdentifier()); | 362 base::FilePath bundle_path = GetAppBundleById(GetBundleIdentifier()); |
| 363 if (!bundle_path.empty()) | 363 if (!bundle_path.empty()) |
| 364 file_util::Delete(bundle_path, true); | 364 base::Delete(bundle_path, true); |
| 365 | 365 |
| 366 // Delete the internal one. | 366 // Delete the internal one. |
| 367 DeletePathAndParentIfEmpty(app_data_path_.Append(GetShortcutName())); | 367 DeletePathAndParentIfEmpty(app_data_path_.Append(GetShortcutName())); |
| 368 } | 368 } |
| 369 | 369 |
| 370 bool WebAppShortcutCreator::UpdateShortcuts() { | 370 bool WebAppShortcutCreator::UpdateShortcuts() { |
| 371 std::vector<base::FilePath> paths; | 371 std::vector<base::FilePath> paths; |
| 372 file_util::Delete(app_data_path_.Append(GetShortcutName()), true); | 372 base::Delete(app_data_path_.Append(GetShortcutName()), true); |
| 373 paths.push_back(app_data_path_); | 373 paths.push_back(app_data_path_); |
| 374 | 374 |
| 375 base::FilePath dst_path = GetDestinationPath(); | 375 base::FilePath dst_path = GetDestinationPath(); |
| 376 base::FilePath app_path = dst_path.Append(GetShortcutName()); | 376 base::FilePath app_path = dst_path.Append(GetShortcutName()); |
| 377 | 377 |
| 378 // If the path does not exist, check if a matching bundle can be found | 378 // If the path does not exist, check if a matching bundle can be found |
| 379 // elsewhere. | 379 // elsewhere. |
| 380 if (dst_path.empty() || !file_util::PathExists(app_path)) | 380 if (dst_path.empty() || !file_util::PathExists(app_path)) |
| 381 app_path = GetAppBundleById(GetBundleIdentifier()); | 381 app_path = GetAppBundleById(GetBundleIdentifier()); |
| 382 | 382 |
| 383 if (!app_path.empty()) { | 383 if (!app_path.empty()) { |
| 384 file_util::Delete(app_path, true); | 384 base::Delete(app_path, true); |
| 385 paths.push_back(app_path.DirName()); | 385 paths.push_back(app_path.DirName()); |
| 386 } | 386 } |
| 387 | 387 |
| 388 size_t success_count = CreateShortcutsIn(paths); | 388 size_t success_count = CreateShortcutsIn(paths); |
| 389 if (success_count == 0) | 389 if (success_count == 0) |
| 390 return false; | 390 return false; |
| 391 | 391 |
| 392 UpdateInternalBundleIdentifier(); | 392 UpdateInternalBundleIdentifier(); |
| 393 return success_count == paths.size() && !app_path.empty(); | 393 return success_count == paths.size() && !app_path.empty(); |
| 394 } | 394 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 const ShellIntegration::ShortcutInfo& shortcut_info) { | 620 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 621 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 621 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 622 WebAppShortcutCreator shortcut_creator( | 622 WebAppShortcutCreator shortcut_creator( |
| 623 app_data_path, shortcut_info, base::mac::BaseBundleID()); | 623 app_data_path, shortcut_info, base::mac::BaseBundleID()); |
| 624 shortcut_creator.UpdateShortcuts(); | 624 shortcut_creator.UpdateShortcuts(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // namespace internals | 627 } // namespace internals |
| 628 | 628 |
| 629 } // namespace web_app | 629 } // namespace web_app |
| OLD | NEW |