Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Unified Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 12178030: [mac] Delete app shortcuts on app uninstall. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/app_shortcut_manager.cc ('k') | chrome/service/chrome_service_application_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3e0e41e3898e707f829b89e33389c392170cbee6..ce6f20830d530724f181881b1cb056f6d36df75f 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(
« no previous file with comments | « chrome/browser/extensions/app_shortcut_manager.cc ('k') | chrome/service/chrome_service_application_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698