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

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: 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
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"
14 #include "base/memory/scoped_nsobject.h" 15 #include "base/memory/scoped_nsobject.h"
15 #include "base/sys_string_conversions.h" 16 #include "base/sys_string_conversions.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/web_applications/web_app.h" 18 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_paths_internal.h" 19 #include "chrome/common/chrome_paths_internal.h"
19 #include "chrome/common/mac/app_mode_common.h" 20 #include "chrome/common/mac/app_mode_common.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
22 #include "skia/ext/skia_utils_mac.h" 23 #include "skia/ext/skia_utils_mac.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 selectFile:base::mac::FilePathToNSString(generated_bundle) 249 selectFile:base::mac::FilePathToNSString(generated_bundle)
249 inFileViewerRootedAtPath:nil]; 250 inFileViewerRootedAtPath:nil];
250 } 251 }
251 252
252 } // namespace 253 } // namespace
253 254
254 namespace web_app { 255 namespace web_app {
255 256
256 namespace internals { 257 namespace internals {
257 258
259 FilePath GetAppBundleByExtensionId(std::string extension_id) {
260 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
261 FSRef ref;
262 CFURLRef* kDontWantURL = NULL;
Avi (use Gerrit) 2013/02/05 00:19:25 This isn't a constant so don't name it as such.
263 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp.
264 std::string bundleID =
265 base::mac::BaseBundleID() + std::string(".app.") + extension_id;
Avi (use Gerrit) 2013/02/05 00:19:25 This isn't Objective-C code. This (and other varia
jeremya 2013/02/05 02:38:14 Done.
266 CFStringRef bundleIDCF =
267 CFStringCreateWithCString(NULL, bundleID.c_str(), kCFStringEncodingUTF8);
Avi (use Gerrit) 2013/02/05 00:19:25 SysUTF8ToCFStringRef. Also, don't leak this string
jeremya 2013/02/05 02:38:14 Done.
268 OSStatus status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF,
269 NULL, &ref, kDontWantURL);
Avi (use Gerrit) 2013/02/05 00:19:25 I don't understand. Why do you pass NULL for the i
jeremya 2013/02/05 02:38:14 I cargo-culted from chrome_service_application_mac
Avi (use Gerrit) 2013/02/05 04:01:40 Would you be so kind as to fix it there too? :)
jeremya 2013/02/05 04:28:52 I fixed some things there, but it needs an FSRef f
Avi (use Gerrit) 2013/02/05 05:15:49 Yeah, that falls under the "no non-deprecated way
270
271 if (status != noErr)
272 return FilePath();
273 return FilePath(base::mac::PathFromFSRef(ref));
Avi (use Gerrit) 2013/02/05 00:19:25 PathFromFSRef... ew. If we have to deal with APIs
jeremya 2013/02/05 02:38:14 Done.
274 }
275
258 bool CreatePlatformShortcuts( 276 bool CreatePlatformShortcuts(
259 const FilePath& web_app_path, 277 const FilePath& web_app_path,
260 const ShellIntegration::ShortcutInfo& shortcut_info) { 278 const ShellIntegration::ShortcutInfo& shortcut_info) {
261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 279 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
262 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID()); 280 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID());
263 WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info, 281 WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info,
264 bundle_id); 282 bundle_id);
265 return shortcut_creator.CreateShortcut(); 283 return shortcut_creator.CreateShortcut();
266 } 284 }
267 285
268 void DeletePlatformShortcuts( 286 void DeletePlatformShortcuts(
269 const FilePath& web_app_path, 287 const FilePath& web_app_path,
270 const ShellIntegration::ShortcutInfo& shortcut_info) { 288 const ShellIntegration::ShortcutInfo& info) {
271 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 289 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
272 // mac. 290
291 FilePath bundle_path = GetAppBundleByExtensionId(info.extension_id);
292 file_util::Delete(bundle_path, true);
273 } 293 }
274 294
275 void UpdatePlatformShortcuts( 295 void UpdatePlatformShortcuts(
276 const FilePath& web_app_path, 296 const FilePath& web_app_path,
277 const ShellIntegration::ShortcutInfo& shortcut_info) { 297 const ShellIntegration::ShortcutInfo& shortcut_info) {
278 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 298 // TODO(benwells): Implement this when shortcuts / weblings are enabled on
279 // mac. 299 // mac.
280 } 300 }
281 301
282 } // namespace internals 302 } // namespace internals
283 303
284 } // namespace web_app 304 } // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698