Chromium Code Reviews| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 return 0; | 693 return 0; |
| 694 | 694 |
| 695 for (std::vector<base::FilePath>::const_iterator it = folders.begin(); | 695 for (std::vector<base::FilePath>::const_iterator it = folders.begin(); |
| 696 it != folders.end(); ++it) { | 696 it != folders.end(); ++it) { |
| 697 const base::FilePath& dst_path = *it; | 697 const base::FilePath& dst_path = *it; |
| 698 if (!base::CreateDirectory(dst_path)) { | 698 if (!base::CreateDirectory(dst_path)) { |
| 699 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; | 699 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; |
| 700 return succeeded; | 700 return succeeded; |
| 701 } | 701 } |
| 702 | 702 |
| 703 if (!base::CopyDirectory(staging_path, dst_path, true)) { | 703 if (!base::CopyDirectory(staging_path, dst_path, true)) { |
|
tapted
2015/05/15 02:02:49
What about before this, something like
// Ensur
jackhou1
2015/05/15 02:44:56
Done.
| |
| 704 LOG(ERROR) << "Copying app to dst path: " << dst_path.value() | 704 LOG(ERROR) << "Copying app to dst path: " << dst_path.value() |
| 705 << " failed"; | 705 << " failed"; |
| 706 return succeeded; | 706 return succeeded; |
| 707 } | 707 } |
| 708 | 708 |
| 709 // Remove the quarantine attribute from both the bundle and the executable. | 709 // Remove the quarantine attribute from both the bundle and the executable. |
| 710 base::mac::RemoveQuarantineAttribute(dst_path.Append(app_name)); | 710 base::mac::RemoveQuarantineAttribute(dst_path.Append(app_name)); |
| 711 base::mac::RemoveQuarantineAttribute( | 711 base::mac::RemoveQuarantineAttribute( |
| 712 dst_path.Append(app_name) | 712 dst_path.Append(app_name) |
| 713 .Append("Contents").Append("MacOS").Append("app_mode_loader")); | 713 .Append("Contents").Append("MacOS").Append("app_mode_loader")); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 736 | 736 |
| 737 // The app list shim is not tied to a particular profile, so omit the copy | 737 // The app list shim is not tied to a particular profile, so omit the copy |
| 738 // placed under the profile path. For shims, this copy is used when the | 738 // placed under the profile path. For shims, this copy is used when the |
| 739 // version under Applications is removed, and not needed for app list because | 739 // version under Applications is removed, and not needed for app list because |
| 740 // setting LSUIElement means there is no Dock "running" status to show. | 740 // setting LSUIElement means there is no Dock "running" status to show. |
| 741 const bool is_app_list = info_->extension_id == app_mode::kAppListModeId; | 741 const bool is_app_list = info_->extension_id == app_mode::kAppListModeId; |
| 742 if (is_app_list) { | 742 if (is_app_list) { |
| 743 path_to_add_to_dock = base::SysUTF8ToNSString( | 743 path_to_add_to_dock = base::SysUTF8ToNSString( |
| 744 applications_dir.Append(GetShortcutBasename()).AsUTF8Unsafe()); | 744 applications_dir.Append(GetShortcutBasename()).AsUTF8Unsafe()); |
| 745 } else { | 745 } else { |
| 746 base::DeleteFile(GetInternalShortcutPath(), true); | |
| 746 paths.push_back(app_data_dir_); | 747 paths.push_back(app_data_dir_); |
| 747 } | 748 } |
| 748 | 749 |
| 749 bool shortcut_visible = | 750 bool shortcut_visible = |
| 750 creation_locations.applications_menu_location != APP_MENU_LOCATION_HIDDEN; | 751 creation_locations.applications_menu_location != APP_MENU_LOCATION_HIDDEN; |
| 751 if (shortcut_visible) | 752 if (shortcut_visible) { |
| 753 base::DeleteFile(GetApplicationsShortcutPath(), true); | |
| 752 paths.push_back(applications_dir); | 754 paths.push_back(applications_dir); |
| 755 } | |
| 753 | 756 |
| 754 DCHECK(!paths.empty()); | 757 DCHECK(!paths.empty()); |
| 755 size_t success_count = CreateShortcutsIn(paths); | 758 size_t success_count = CreateShortcutsIn(paths); |
| 756 if (success_count == 0) | 759 if (success_count == 0) |
| 757 return false; | 760 return false; |
| 758 | 761 |
| 759 if (!is_app_list) | 762 if (!is_app_list) |
| 760 UpdateInternalBundleIdentifier(); | 763 UpdateInternalBundleIdentifier(); |
| 761 | 764 |
| 762 if (success_count != paths.size()) | 765 if (success_count != paths.size()) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 switches::kEnableAppsFileAssociations)) { | 893 switches::kEnableAppsFileAssociations)) { |
| 891 UpdateFileTypes(plist, file_handlers_info_); | 894 UpdateFileTypes(plist, file_handlers_info_); |
| 892 } | 895 } |
| 893 | 896 |
| 894 return [plist writeToFile:plist_path | 897 return [plist writeToFile:plist_path |
| 895 atomically:YES]; | 898 atomically:YES]; |
| 896 } | 899 } |
| 897 | 900 |
| 898 bool WebAppShortcutCreator::UpdateDisplayName( | 901 bool WebAppShortcutCreator::UpdateDisplayName( |
| 899 const base::FilePath& app_path) const { | 902 const base::FilePath& app_path) const { |
| 900 // OSX searches for the best language in the order of preferred languages. | 903 // Localization is used to display the app name (rather than the bundle |
| 901 // Since we only have one localization directory, it will choose this one. | 904 // filename). OSX searches for the best language in the order of preferred |
| 902 base::FilePath localized_dir = GetResourcesPath(app_path).Append("en.lproj"); | 905 // languages, but one of them must be found otherwise it will default to |
| 906 // the filename. | |
| 907 NSString* language = [[NSLocale preferredLanguages] objectAtIndex:0]; | |
| 908 base::FilePath localized_dir = GetResourcesPath(app_path).Append( | |
| 909 base::SysNSStringToUTF8(language) + ".lproj"); | |
| 903 if (!base::CreateDirectory(localized_dir)) | 910 if (!base::CreateDirectory(localized_dir)) |
| 904 return false; | 911 return false; |
| 905 | 912 |
| 906 NSString* bundle_name = base::SysUTF16ToNSString(info_->title); | 913 NSString* bundle_name = base::SysUTF16ToNSString(info_->title); |
| 907 NSString* display_name = base::SysUTF16ToNSString(info_->title); | 914 NSString* display_name = base::SysUTF16ToNSString(info_->title); |
| 908 if (HasExistingExtensionShim(GetApplicationsDirname(), info_->extension_id, | 915 if (HasExistingExtensionShim(GetApplicationsDirname(), info_->extension_id, |
| 909 app_path.BaseName())) { | 916 app_path.BaseName())) { |
| 910 display_name = [bundle_name | 917 display_name = [bundle_name |
| 911 stringByAppendingString:base::SysUTF8ToNSString( | 918 stringByAppendingString:base::SysUTF8ToNSString( |
| 912 " (" + info_->profile_name + ")")]; | 919 " (" + info_->profile_name + ")")]; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 web_app::GetShortcutInfoForApp( | 1215 web_app::GetShortcutInfoForApp( |
| 1209 app, | 1216 app, |
| 1210 profile, | 1217 profile, |
| 1211 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1218 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
| 1212 profile, | 1219 profile, |
| 1213 app, | 1220 app, |
| 1214 close_callback)); | 1221 close_callback)); |
| 1215 } | 1222 } |
| 1216 | 1223 |
| 1217 } // namespace chrome | 1224 } // namespace chrome |
| OLD | NEW |