| OLD | NEW |
| 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 #include "chrome/browser/mac/install_from_dmg.h" | 5 #include "chrome/browser/mac/install_from_dmg.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
| 9 #include <CoreFoundation/CoreFoundation.h> | 9 #include <CoreFoundation/CoreFoundation.h> |
| 10 #include <CoreServices/CoreServices.h> | 10 #include <CoreServices/CoreServices.h> |
| 11 #include <DiskArbitration/DiskArbitration.h> | 11 #include <DiskArbitration/DiskArbitration.h> |
| 12 #include <IOKit/IOKitLib.h> | 12 #include <IOKit/IOKitLib.h> |
| 13 #include <signal.h> | 13 #include <signal.h> |
| 14 #include <stdlib.h> | 14 #include <stdlib.h> |
| 15 #include <string.h> | 15 #include <string.h> |
| 16 #include <sys/param.h> | 16 #include <sys/param.h> |
| 17 #include <sys/mount.h> | 17 #include <sys/mount.h> |
| 18 | 18 |
| 19 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/file_path.h" | 22 #include "base/file_path.h" |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/mac/bundle_locations.h" | 24 #include "base/mac/bundle_locations.h" |
| 25 #include "base/mac/mac_logging.h" |
| 25 #import "base/mac/mac_util.h" | 26 #import "base/mac/mac_util.h" |
| 26 #include "base/mac/scoped_cftyperef.h" | 27 #include "base/mac/scoped_cftyperef.h" |
| 27 #include "base/mac/scoped_nsautorelease_pool.h" | 28 #include "base/mac/scoped_nsautorelease_pool.h" |
| 28 #include "base/string_util.h" | 29 #include "base/string_util.h" |
| 29 #include "base/sys_string_conversions.h" | 30 #include "base/sys_string_conversions.h" |
| 30 #include "chrome/browser/mac/authorization_util.h" | 31 #include "chrome/browser/mac/authorization_util.h" |
| 31 #include "chrome/browser/mac/dock.h" | 32 #include "chrome/browser/mac/dock.h" |
| 32 #include "chrome/browser/mac/scoped_authorizationref.h" | 33 #include "chrome/browser/mac/scoped_authorizationref.h" |
| 33 #include "chrome/browser/mac/scoped_ioobject.h" | 34 #include "chrome/browser/mac/scoped_ioobject.h" |
| 34 #import "chrome/browser/mac/keystone_glue.h" | 35 #import "chrome/browser/mac/keystone_glue.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 const char* arguments[] = {source_path_c, target_path_c, NULL}; | 302 const char* arguments[] = {source_path_c, target_path_c, NULL}; |
| 302 | 303 |
| 303 OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( | 304 OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( |
| 304 authorization, | 305 authorization, |
| 305 installer_path_c, | 306 installer_path_c, |
| 306 kAuthorizationFlagDefaults, | 307 kAuthorizationFlagDefaults, |
| 307 arguments, | 308 arguments, |
| 308 NULL, // pipe | 309 NULL, // pipe |
| 309 &exit_status); | 310 &exit_status); |
| 310 if (status != errAuthorizationSuccess) { | 311 if (status != errAuthorizationSuccess) { |
| 311 LOG(ERROR) << "AuthorizationExecuteWithPrivileges install: " << status; | 312 OSSTATUS_LOG(ERROR, status) |
| 313 << "AuthorizationExecuteWithPrivileges install"; |
| 312 return false; | 314 return false; |
| 313 } | 315 } |
| 314 } else { | 316 } else { |
| 315 NSArray* arguments = [NSArray arrayWithObjects:source_path, | 317 NSArray* arguments = [NSArray arrayWithObjects:source_path, |
| 316 target_path, | 318 target_path, |
| 317 nil]; | 319 nil]; |
| 318 | 320 |
| 319 NSTask* task; | 321 NSTask* task; |
| 320 @try { | 322 @try { |
| 321 task = [NSTask launchedTaskWithLaunchPath:installer_path | 323 task = [NSTask launchedTaskWithLaunchPath:installer_path |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 if (!SynchronousDADiskEject(disk, kDADiskEjectOptionDefault)) { | 654 if (!SynchronousDADiskEject(disk, kDADiskEjectOptionDefault)) { |
| 653 LOG(ERROR) << "SynchronousDADiskEject"; | 655 LOG(ERROR) << "SynchronousDADiskEject"; |
| 654 return; | 656 return; |
| 655 } | 657 } |
| 656 | 658 |
| 657 char* disk_image_path_in_trash_c; | 659 char* disk_image_path_in_trash_c; |
| 658 OSStatus status = FSPathMoveObjectToTrashSync(disk_image_path.c_str(), | 660 OSStatus status = FSPathMoveObjectToTrashSync(disk_image_path.c_str(), |
| 659 &disk_image_path_in_trash_c, | 661 &disk_image_path_in_trash_c, |
| 660 kFSFileOperationDefaultOptions); | 662 kFSFileOperationDefaultOptions); |
| 661 if (status != noErr) { | 663 if (status != noErr) { |
| 662 LOG(ERROR) << "FSPathMoveObjectToTrashSync: " << status; | 664 OSSTATUS_LOG(ERROR, status) << "FSPathMoveObjectToTrashSync"; |
| 663 return; | 665 return; |
| 664 } | 666 } |
| 665 | 667 |
| 666 // FSPathMoveObjectToTrashSync alone doesn't result in the Trash icon in the | 668 // FSPathMoveObjectToTrashSync alone doesn't result in the Trash icon in the |
| 667 // Dock indicating that any garbage has been placed within it. Using the | 669 // Dock indicating that any garbage has been placed within it. Using the |
| 668 // trash path that FSPathMoveObjectToTrashSync claims to have used, call | 670 // trash path that FSPathMoveObjectToTrashSync claims to have used, call |
| 669 // FNNotifyByPath to fatten up the icon. | 671 // FNNotifyByPath to fatten up the icon. |
| 670 FilePath disk_image_path_in_trash(disk_image_path_in_trash_c); | 672 FilePath disk_image_path_in_trash(disk_image_path_in_trash_c); |
| 671 free(disk_image_path_in_trash_c); | 673 free(disk_image_path_in_trash_c); |
| 672 | 674 |
| 673 FilePath trash_path = disk_image_path_in_trash.DirName(); | 675 FilePath trash_path = disk_image_path_in_trash.DirName(); |
| 674 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( | 676 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( |
| 675 trash_path.value().c_str()); | 677 trash_path.value().c_str()); |
| 676 status = FNNotifyByPath(trash_path_u8, | 678 status = FNNotifyByPath(trash_path_u8, |
| 677 kFNDirectoryModifiedMessage, | 679 kFNDirectoryModifiedMessage, |
| 678 kNilOptions); | 680 kNilOptions); |
| 679 if (status != noErr) { | 681 if (status != noErr) { |
| 680 LOG(ERROR) << "FNNotifyByPath: " << status; | 682 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath"; |
| 681 return; | 683 return; |
| 682 } | 684 } |
| 683 } | 685 } |
| OLD | NEW |