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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/app_shortcut_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/mac/bundle_locations.h" 11 #include "base/mac/bundle_locations.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/mac_logging.h"
13 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
15 #include "base/mac/scoped_cftyperef.h"
14 #include "base/memory/scoped_nsobject.h" 16 #include "base/memory/scoped_nsobject.h"
15 #include "base/sys_string_conversions.h" 17 #include "base/sys_string_conversions.h"
16 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/web_applications/web_app.h" 19 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_paths_internal.h" 20 #include "chrome/common/chrome_paths_internal.h"
19 #include "chrome/common/mac/app_mode_common.h" 21 #include "chrome/common/mac/app_mode_common.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
21 #include "grit/chromium_strings.h" 23 #include "grit/chromium_strings.h"
22 #include "skia/ext/skia_utils_mac.h" 24 #include "skia/ext/skia_utils_mac.h"
23 #include "third_party/icon_family/IconFamily.h" 25 #include "third_party/icon_family/IconFamily.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 selectFile:base::mac::FilePathToNSString(generated_bundle) 250 selectFile:base::mac::FilePathToNSString(generated_bundle)
249 inFileViewerRootedAtPath:nil]; 251 inFileViewerRootedAtPath:nil];
250 } 252 }
251 253
252 } // namespace 254 } // namespace
253 255
254 namespace web_app { 256 namespace web_app {
255 257
256 namespace internals { 258 namespace internals {
257 259
260 FilePath GetAppBundleByExtensionId(std::string extension_id) {
261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
262 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp.
263 std::string bundle_id =
264 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
265 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf(
266 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
267 CFURLRef url_ref;
268 OSStatus status = LSFindApplicationForInfo(
269 kLSUnknownCreator, bundle_id_cf.get(), NULL, NULL, &url_ref);
270 base::mac::ScopedCFTypeRef<CFURLRef> url(url_ref);
271
272 if (status != noErr)
273 return FilePath();
274
275 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.
276 return FilePath([path_string fileSystemRepresentation]);
277 }
278
258 bool CreatePlatformShortcuts( 279 bool CreatePlatformShortcuts(
259 const FilePath& web_app_path, 280 const FilePath& web_app_path,
260 const ShellIntegration::ShortcutInfo& shortcut_info) { 281 const ShellIntegration::ShortcutInfo& shortcut_info) {
261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 282 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
262 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID()); 283 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID());
263 WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info, 284 WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info,
264 bundle_id); 285 bundle_id);
265 return shortcut_creator.CreateShortcut(); 286 return shortcut_creator.CreateShortcut();
266 } 287 }
267 288
268 void DeletePlatformShortcuts( 289 void DeletePlatformShortcuts(
269 const FilePath& web_app_path, 290 const FilePath& web_app_path,
270 const ShellIntegration::ShortcutInfo& shortcut_info) { 291 const ShellIntegration::ShortcutInfo& info) {
271 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 292 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
272 // mac. 293
294 FilePath bundle_path = GetAppBundleByExtensionId(info.extension_id);
295 file_util::Delete(bundle_path, true);
273 } 296 }
274 297
275 void UpdatePlatformShortcuts( 298 void UpdatePlatformShortcuts(
276 const FilePath& web_app_path, 299 const FilePath& web_app_path,
277 const ShellIntegration::ShortcutInfo& shortcut_info) { 300 const ShellIntegration::ShortcutInfo& shortcut_info) {
278 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 301 // TODO(benwells): Implement this when shortcuts / weblings are enabled on
279 // mac. 302 // mac.
280 } 303 }
281 304
282 } // namespace internals 305 } // namespace internals
283 306
284 } // namespace web_app 307 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_shortcut_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698