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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 959 |
960 std::string WebAppShortcutCreator::GetInternalBundleIdentifier() const { | 960 std::string WebAppShortcutCreator::GetInternalBundleIdentifier() const { |
961 return GetBundleIdentifier() + "-internal"; | 961 return GetBundleIdentifier() + "-internal"; |
962 } | 962 } |
963 | 963 |
964 void WebAppShortcutCreator::RevealAppShimInFinder() const { | 964 void WebAppShortcutCreator::RevealAppShimInFinder() const { |
965 base::FilePath app_path = GetApplicationsShortcutPath(); | 965 base::FilePath app_path = GetApplicationsShortcutPath(); |
966 if (app_path.empty()) | 966 if (app_path.empty()) |
967 return; | 967 return; |
968 | 968 |
| 969 if (!base::PathExists(app_path)) { |
| 970 app_path = app_path.DirName(); |
| 971 } |
| 972 |
969 [[NSWorkspace sharedWorkspace] | 973 [[NSWorkspace sharedWorkspace] |
970 selectFile:base::mac::FilePathToNSString(app_path) | 974 selectFile:base::mac::FilePathToNSString(app_path) |
971 inFileViewerRootedAtPath:nil]; | 975 inFileViewerRootedAtPath:nil]; |
972 } | 976 } |
973 | 977 |
| 978 void WebAppShortcutCreator::RevealAppShimInFinderForApp( |
| 979 Profile* profile, |
| 980 const extensions::Extension* app) { |
| 981 const web_app::ShortcutInfo shortcut_info = |
| 982 ShortcutInfoForExtensionAndProfile(app, profile); |
| 983 content::BrowserThread::PostTask( |
| 984 content::BrowserThread::FILE, FROM_HERE, |
| 985 base::Bind(&RevealAppShimInFinderForAppOnFileThread, shortcut_info, |
| 986 app->path())); |
| 987 } |
| 988 |
| 989 void WebAppShortcutCreator::RevealAppShimInFinderForAppOnFileThread( |
| 990 const ShortcutInfo& shortcut_info, |
| 991 const base::FilePath& app_path) { |
| 992 web_app::WebAppShortcutCreator shortcut_creator( |
| 993 app_path, shortcut_info, extensions::FileHandlersInfo()); |
| 994 shortcut_creator.RevealAppShimInFinder(); |
| 995 } |
| 996 |
974 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { | 997 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { |
975 WebAppShortcutCreator shortcut_creator( | 998 WebAppShortcutCreator shortcut_creator( |
976 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); | 999 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); |
977 return shortcut_creator.GetApplicationsShortcutPath(); | 1000 return shortcut_creator.GetApplicationsShortcutPath(); |
978 } | 1001 } |
979 | 1002 |
980 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { | 1003 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { |
981 if (AppShimsDisabledForTest() && | 1004 if (AppShimsDisabledForTest() && |
982 !g_app_shims_allow_update_and_launch_in_tests) { | 1005 !g_app_shims_allow_update_and_launch_in_tests) { |
983 return; | 1006 return; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 web_app::GetShortcutInfoForApp( | 1178 web_app::GetShortcutInfoForApp( |
1156 app, | 1179 app, |
1157 profile, | 1180 profile, |
1158 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1181 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
1159 profile, | 1182 profile, |
1160 app, | 1183 app, |
1161 close_callback)); | 1184 close_callback)); |
1162 } | 1185 } |
1163 | 1186 |
1164 } // namespace chrome | 1187 } // namespace chrome |
OLD | NEW |