| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "base/mac/mac_util.h" | 25 #import "base/mac/mac_util.h" |
| 25 #include "base/mac/scoped_cftyperef.h" | 26 #include "base/mac/scoped_cftyperef.h" |
| 26 #include "base/mac/scoped_nsautorelease_pool.h" | 27 #include "base/mac/scoped_nsautorelease_pool.h" |
| 27 #include "base/string_util.h" | 28 #include "base/string_util.h" |
| 28 #include "base/sys_string_conversions.h" | 29 #include "base/sys_string_conversions.h" |
| 29 #include "chrome/browser/mac/authorization_util.h" | 30 #include "chrome/browser/mac/authorization_util.h" |
| 30 #include "chrome/browser/mac/dock.h" | 31 #include "chrome/browser/mac/dock.h" |
| 31 #include "chrome/browser/mac/scoped_authorizationref.h" | 32 #include "chrome/browser/mac/scoped_authorizationref.h" |
| 32 #include "chrome/browser/mac/scoped_ioobject.h" | 33 #include "chrome/browser/mac/scoped_ioobject.h" |
| 33 #import "chrome/browser/mac/keystone_glue.h" | 34 #import "chrome/browser/mac/keystone_glue.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 228 |
| 228 return MediaResidesOnDiskImage(media, NULL); | 229 return MediaResidesOnDiskImage(media, NULL); |
| 229 } | 230 } |
| 230 | 231 |
| 231 // Returns true if the application is located on a read-only filesystem of a | 232 // Returns true if the application is located on a read-only filesystem of a |
| 232 // disk image. Returns false if not, or in the event of an error. If | 233 // disk image. Returns false if not, or in the event of an error. If |
| 233 // dmg_bsd_device_name is present, it will be set to the BSD device name for | 234 // dmg_bsd_device_name is present, it will be set to the BSD device name for |
| 234 // the disk image's device, in "diskNsM" form. | 235 // the disk image's device, in "diskNsM" form. |
| 235 bool IsAppRunningFromReadOnlyDiskImage(std::string* dmg_bsd_device_name) { | 236 bool IsAppRunningFromReadOnlyDiskImage(std::string* dmg_bsd_device_name) { |
| 236 return IsPathOnReadOnlyDiskImage( | 237 return IsPathOnReadOnlyDiskImage( |
| 237 [[[NSBundle mainBundle] bundlePath] fileSystemRepresentation], | 238 [[base::mac::OuterBundle() bundlePath] fileSystemRepresentation], |
| 238 dmg_bsd_device_name); | 239 dmg_bsd_device_name); |
| 239 } | 240 } |
| 240 | 241 |
| 241 // Shows a dialog asking the user whether or not to install from the disk | 242 // Shows a dialog asking the user whether or not to install from the disk |
| 242 // image. Returns true if the user approves installation. | 243 // image. Returns true if the user approves installation. |
| 243 bool ShouldInstallDialog() { | 244 bool ShouldInstallDialog() { |
| 244 NSString* title = l10n_util::GetNSStringFWithFixup( | 245 NSString* title = l10n_util::GetNSStringFWithFixup( |
| 245 IDS_INSTALL_FROM_DMG_TITLE, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 246 IDS_INSTALL_FROM_DMG_TITLE, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 246 NSString* prompt = l10n_util::GetNSStringFWithFixup( | 247 NSString* prompt = l10n_util::GetNSStringFWithFixup( |
| 247 IDS_INSTALL_FROM_DMG_PROMPT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 248 IDS_INSTALL_FROM_DMG_PROMPT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 418 |
| 418 BOOL is_directory; | 419 BOOL is_directory; |
| 419 if (![file_manager fileExistsAtPath:application_directory | 420 if (![file_manager fileExistsAtPath:application_directory |
| 420 isDirectory:&is_directory] || | 421 isDirectory:&is_directory] || |
| 421 !is_directory) { | 422 !is_directory) { |
| 422 VLOG(1) << "No application directory at " | 423 VLOG(1) << "No application directory at " |
| 423 << [application_directory UTF8String]; | 424 << [application_directory UTF8String]; |
| 424 return false; | 425 return false; |
| 425 } | 426 } |
| 426 | 427 |
| 427 NSString* source_path = [[NSBundle mainBundle] bundlePath]; | 428 NSString* source_path = [base::mac::OuterBundle() bundlePath]; |
| 428 NSString* application_name = [source_path lastPathComponent]; | 429 NSString* application_name = [source_path lastPathComponent]; |
| 429 NSString* target_path = | 430 NSString* target_path = |
| 430 [application_directory stringByAppendingPathComponent:application_name]; | 431 [application_directory stringByAppendingPathComponent:application_name]; |
| 431 | 432 |
| 432 if ([file_manager fileExistsAtPath:target_path]) { | 433 if ([file_manager fileExistsAtPath:target_path]) { |
| 433 VLOG(1) << "Something already exists at " << [target_path UTF8String]; | 434 VLOG(1) << "Something already exists at " << [target_path UTF8String]; |
| 434 return false; | 435 return false; |
| 435 } | 436 } |
| 436 | 437 |
| 437 NSString* installer_path = | 438 NSString* installer_path = |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( | 674 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( |
| 674 trash_path.value().c_str()); | 675 trash_path.value().c_str()); |
| 675 status = FNNotifyByPath(trash_path_u8, | 676 status = FNNotifyByPath(trash_path_u8, |
| 676 kFNDirectoryModifiedMessage, | 677 kFNDirectoryModifiedMessage, |
| 677 kNilOptions); | 678 kNilOptions); |
| 678 if (status != noErr) { | 679 if (status != noErr) { |
| 679 LOG(ERROR) << "FNNotifyByPath: " << status; | 680 LOG(ERROR) << "FNNotifyByPath: " << status; |
| 680 return; | 681 return; |
| 681 } | 682 } |
| 682 } | 683 } |
| OLD | NEW |