diff options
author | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 01:14:16 +0000 |
---|---|---|
committer | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 01:14:16 +0000 |
commit | a362bf2d885fce654a7d88f6184e99d5325c1690 (patch) | |
tree | 67fb60fb189ac0cad7016127c79cf55b3666d99e /chrome/browser/web_applications | |
parent | 530a19beaf9bbbff8222b49b7df7fd58ec6cc235 (diff) | |
download | chromium_src-a362bf2d885fce654a7d88f6184e99d5325c1690.zip chromium_src-a362bf2d885fce654a7d88f6184e99d5325c1690.tar.gz chromium_src-a362bf2d885fce654a7d88f6184e99d5325c1690.tar.bz2 |
[mac] Delete app shortcuts on app uninstall.
When an app is uninstalled, find the .app bundle it's associated with using
Launch Services, and delete it.
Review URL: https://codereview.chromium.org/12178030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.mm | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 3e0e41e..ce6f208 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" @@ -256,6 +258,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; + base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( + base::SysUTF8ToCFStringRef(bundle_id)); + CFURLRef url_ref = NULL; + 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 = [base::mac::CFToNSCast(url.get()) path]; + return FilePath([path_string fileSystemRepresentation]); +} + bool CreatePlatformShortcuts( const base::FilePath& web_app_path, const ShellIntegration::ShortcutInfo& shortcut_info) { @@ -268,9 +289,11 @@ bool CreatePlatformShortcuts( void DeletePlatformShortcuts( const base::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( |