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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 app_mode::kCFBundleTypeMIMETypesKey : mime_types, | 545 app_mode::kCFBundleTypeMIMETypesKey : mime_types, |
546 app_mode::kCFBundleTypeRoleKey : app_mode::kBundleTypeRoleViewer | 546 app_mode::kCFBundleTypeRoleKey : app_mode::kBundleTypeRoleViewer |
547 }; | 547 }; |
548 [document_types addObject:type_dictionary]; | 548 [document_types addObject:type_dictionary]; |
549 } | 549 } |
550 | 550 |
551 [plist setObject:document_types | 551 [plist setObject:document_types |
552 forKey:app_mode::kCFBundleDocumentTypesKey]; | 552 forKey:app_mode::kCFBundleDocumentTypesKey]; |
553 } | 553 } |
554 | 554 |
| 555 void RevealAppShimInFinderForAppOnFileThread( |
| 556 const web_app::ShortcutInfo& shortcut_info, |
| 557 const base::FilePath& app_path) { |
| 558 web_app::WebAppShortcutCreator shortcut_creator( |
| 559 app_path, shortcut_info, extensions::FileHandlersInfo()); |
| 560 shortcut_creator.RevealAppShimInFinder(); |
| 561 } |
| 562 |
555 } // namespace | 563 } // namespace |
556 | 564 |
557 @interface CrCreateAppShortcutCheckboxObserver : NSObject { | 565 @interface CrCreateAppShortcutCheckboxObserver : NSObject { |
558 @private | 566 @private |
559 NSButton* checkbox_; | 567 NSButton* checkbox_; |
560 NSButton* continueButton_; | 568 NSButton* continueButton_; |
561 } | 569 } |
562 | 570 |
563 - (id)initWithCheckbox:(NSButton*)checkbox | 571 - (id)initWithCheckbox:(NSButton*)checkbox |
564 continueButton:(NSButton*)continueButton; | 572 continueButton:(NSButton*)continueButton; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 967 |
960 std::string WebAppShortcutCreator::GetInternalBundleIdentifier() const { | 968 std::string WebAppShortcutCreator::GetInternalBundleIdentifier() const { |
961 return GetBundleIdentifier() + "-internal"; | 969 return GetBundleIdentifier() + "-internal"; |
962 } | 970 } |
963 | 971 |
964 void WebAppShortcutCreator::RevealAppShimInFinder() const { | 972 void WebAppShortcutCreator::RevealAppShimInFinder() const { |
965 base::FilePath app_path = GetApplicationsShortcutPath(); | 973 base::FilePath app_path = GetApplicationsShortcutPath(); |
966 if (app_path.empty()) | 974 if (app_path.empty()) |
967 return; | 975 return; |
968 | 976 |
| 977 if (!base::PathExists(app_path)) |
| 978 app_path = app_path.DirName(); |
| 979 |
969 [[NSWorkspace sharedWorkspace] | 980 [[NSWorkspace sharedWorkspace] |
970 selectFile:base::mac::FilePathToNSString(app_path) | 981 selectFile:base::mac::FilePathToNSString(app_path) |
971 inFileViewerRootedAtPath:nil]; | 982 inFileViewerRootedAtPath:nil]; |
972 } | 983 } |
973 | 984 |
974 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { | 985 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { |
975 WebAppShortcutCreator shortcut_creator( | 986 WebAppShortcutCreator shortcut_creator( |
976 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); | 987 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); |
977 return shortcut_creator.GetApplicationsShortcutPath(); | 988 return shortcut_creator.GetApplicationsShortcutPath(); |
978 } | 989 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 registry->GenerateInstalledExtensionsSet(); | 1089 registry->GenerateInstalledExtensionsSet(); |
1079 for (extensions::ExtensionSet::const_iterator it = everything->begin(); | 1090 for (extensions::ExtensionSet::const_iterator it = everything->begin(); |
1080 it != everything->end(); ++it) { | 1091 it != everything->end(); ++it) { |
1081 if (web_app::ShouldCreateShortcutFor(profile, it->get())) | 1092 if (web_app::ShouldCreateShortcutFor(profile, it->get())) |
1082 web_app::UpdateAllShortcuts(base::string16(), profile, it->get()); | 1093 web_app::UpdateAllShortcuts(base::string16(), profile, it->get()); |
1083 } | 1094 } |
1084 | 1095 |
1085 callback.Run(); | 1096 callback.Run(); |
1086 } | 1097 } |
1087 | 1098 |
| 1099 void RevealAppShimInFinderForApp(Profile* profile, |
| 1100 const extensions::Extension* app) { |
| 1101 const web_app::ShortcutInfo shortcut_info = |
| 1102 ShortcutInfoForExtensionAndProfile(app, profile); |
| 1103 content::BrowserThread::PostTask( |
| 1104 content::BrowserThread::FILE, FROM_HERE, |
| 1105 base::Bind(&RevealAppShimInFinderForAppOnFileThread, shortcut_info, |
| 1106 app->path())); |
| 1107 } |
| 1108 |
1088 namespace internals { | 1109 namespace internals { |
1089 | 1110 |
1090 bool CreatePlatformShortcuts( | 1111 bool CreatePlatformShortcuts( |
1091 const base::FilePath& app_data_path, | 1112 const base::FilePath& app_data_path, |
1092 const ShortcutInfo& shortcut_info, | 1113 const ShortcutInfo& shortcut_info, |
1093 const extensions::FileHandlersInfo& file_handlers_info, | 1114 const extensions::FileHandlersInfo& file_handlers_info, |
1094 const ShortcutLocations& creation_locations, | 1115 const ShortcutLocations& creation_locations, |
1095 ShortcutCreationReason creation_reason) { | 1116 ShortcutCreationReason creation_reason) { |
1096 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 1117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
1097 if (AppShimsDisabledForTest()) | 1118 if (AppShimsDisabledForTest()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 web_app::GetShortcutInfoForApp( | 1176 web_app::GetShortcutInfoForApp( |
1156 app, | 1177 app, |
1157 profile, | 1178 profile, |
1158 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1179 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
1159 profile, | 1180 profile, |
1160 app, | 1181 app, |
1161 close_callback)); | 1182 close_callback)); |
1162 } | 1183 } |
1163 | 1184 |
1164 } // namespace chrome | 1185 } // namespace chrome |
OLD | NEW |