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

Unified Diff: chrome/browser/mac/install_from_dmg.mm

Issue 2393793002: Mac: Port deprecated methods to 10.8+ alternatives in install_from_dmg.mm. (Closed)
Patch Set: Print out the returned error message on trashing failure. Created 4 years, 2 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 | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/mac/install_from_dmg.mm
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm
index 8b936ed1213d9d2d7e1c43a44d55ea91b84dfc59..53448fa18737273bffcdfdaacf2a7d53f9690c05 100644
--- a/chrome/browser/mac/install_from_dmg.mm
+++ b/chrome/browser/mac/install_from_dmg.mm
@@ -30,6 +30,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_ioobject.h"
#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/mac/sdk_forward_declarations.h"
#include "base/macros.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -679,30 +680,14 @@ void EjectAndTrashDiskImage(const std::string& dmg_bsd_device_name) {
return;
}
- char* disk_image_path_in_trash_c;
- OSStatus status = FSPathMoveObjectToTrashSync(disk_image_path.c_str(),
- &disk_image_path_in_trash_c,
- kFSFileOperationDefaultOptions);
- if (status != noErr) {
- OSSTATUS_LOG(ERROR, status) << "FSPathMoveObjectToTrashSync";
+ NSURL* disk_image_path_nsurl =
+ [NSURL fileURLWithPath:base::SysUTF8ToNSString(disk_image_path)];
+ NSError* ns_error = nil;
+ if (![[NSFileManager defaultManager] trashItemAtURL:disk_image_path_nsurl
+ resultingItemURL:nil
+ error:&ns_error]) {
+ LOG(ERROR) << base::SysNSStringToUTF8([ns_error localizedDescription]);
return;
}
- // FSPathMoveObjectToTrashSync alone doesn't result in the Trash icon in the
- // Dock indicating that any garbage has been placed within it. Using the
- // trash path that FSPathMoveObjectToTrashSync claims to have used, call
- // FNNotifyByPath to fatten up the icon.
- base::FilePath disk_image_path_in_trash(disk_image_path_in_trash_c);
- free(disk_image_path_in_trash_c);
-
- base::FilePath trash_path = disk_image_path_in_trash.DirName();
- const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>(
- trash_path.value().c_str());
- status = FNNotifyByPath(trash_path_u8,
- kFNDirectoryModifiedMessage,
- kNilOptions);
- if (status != noErr) {
- OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath";
- return;
- }
}
« no previous file with comments | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698