Chromium Code Reviews| Index: chrome/browser/web_applications/web_app_mac.mm |
| diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm |
| index be02bc52af382199effa6cfb1d79ab4e380be2e1..471a29b3fb2add93fcc4e6f73e0f4d14dfc30795 100644 |
| --- a/chrome/browser/web_applications/web_app_mac.mm |
| +++ b/chrome/browser/web_applications/web_app_mac.mm |
| @@ -10,7 +10,9 @@ |
| #include "base/files/scoped_temp_dir.h" |
| #include "base/mac/bundle_locations.h" |
| #include "base/mac/foundation_util.h" |
| +#include "base/mac/mac_logging.h" |
| #include "base/mac/mac_util.h" |
| +#include "base/mac/scoped_cftyperef.h" |
| #include "base/memory/scoped_nsobject.h" |
| #include "base/sys_string_conversions.h" |
| #include "base/utf_string_conversions.h" |
| @@ -255,6 +257,25 @@ namespace web_app { |
| namespace internals { |
| +FilePath GetAppBundleByExtensionId(std::string extension_id) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| + // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. |
| + std::string bundle_id = |
| + base::mac::BaseBundleID() + std::string(".app.") + extension_id; |
|
Avi (use Gerrit)
2013/02/05 04:01:40
BTW, do we use this bundle id elsewhere? Surely we
jeremya
2013/02/05 04:28:52
We load up a string with a @PLACEHOLDER@ from a pl
Avi (use Gerrit)
2013/02/05 05:15:49
Huh. Eventually we should unify things, but not in
|
| + base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( |
| + base::SysUTF8ToCFStringRef(bundle_id.c_str())); |
|
Avi (use Gerrit)
2013/02/05 04:01:40
Why c_str()? SysUTF8ToCFStringRef takes a std::str
jeremya
2013/02/05 04:28:52
Fixed
|
| + CFURLRef url_ref; |
| + OSStatus status = LSFindApplicationForInfo( |
| + kLSUnknownCreator, bundle_id_cf.get(), NULL, NULL, &url_ref); |
| + base::mac::ScopedCFTypeRef<CFURLRef> url(url_ref); |
| + |
| + if (status != noErr) |
| + return FilePath(); |
| + |
| + NSString *path_string = [(NSURL *)url.get() path]; |
|
Avi (use Gerrit)
2013/02/05 04:01:40
CFToNSCast. And spaces go after the *s.
jeremya
2013/02/05 04:28:52
Done.
|
| + return FilePath([path_string fileSystemRepresentation]); |
| +} |
| + |
| bool CreatePlatformShortcuts( |
| const FilePath& web_app_path, |
| const ShellIntegration::ShortcutInfo& shortcut_info) { |
| @@ -267,9 +288,11 @@ bool CreatePlatformShortcuts( |
| void DeletePlatformShortcuts( |
| const FilePath& web_app_path, |
| - const ShellIntegration::ShortcutInfo& shortcut_info) { |
| - // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
| - // mac. |
| + const ShellIntegration::ShortcutInfo& info) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| + |
| + FilePath bundle_path = GetAppBundleByExtensionId(info.extension_id); |
| + file_util::Delete(bundle_path, true); |
| } |
| void UpdatePlatformShortcuts( |