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

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: comments 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
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..f51d0d7d9f8690183edfd22585930162ad80e390 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;
+ 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 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(

Powered by Google App Engine
This is Rietveld 408576698