| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/install_from_dmg.h" | 5 #include "chrome/browser/cocoa/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> |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 AuthorizationRef MaybeShowAuthorizationDialog(NSString* application_directory) { | 232 AuthorizationRef MaybeShowAuthorizationDialog(NSString* application_directory) { |
| 233 NSFileManager* file_manager = [NSFileManager defaultManager]; | 233 NSFileManager* file_manager = [NSFileManager defaultManager]; |
| 234 if ([file_manager isWritableFileAtPath:application_directory]) { | 234 if ([file_manager isWritableFileAtPath:application_directory]) { |
| 235 return NULL; | 235 return NULL; |
| 236 } | 236 } |
| 237 | 237 |
| 238 NSString* prompt = l10n_util::GetNSStringFWithFixup( | 238 NSString* prompt = l10n_util::GetNSStringFWithFixup( |
| 239 IDS_INSTALL_FROM_DMG_AUTHENTICATION_PROMPT, | 239 IDS_INSTALL_FROM_DMG_AUTHENTICATION_PROMPT, |
| 240 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 240 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 241 return authorization_util::AuthorizationCreateToRunAsRoot( | 241 return authorization_util::AuthorizationCreateToRunAsRoot( |
| 242 reinterpret_cast<CFStringRef>(prompt)); | 242 base::mac::NSToCFCast(prompt)); |
| 243 } | 243 } |
| 244 | 244 |
| 245 // Invokes the installer program at installer_path to copy source_path to | 245 // Invokes the installer program at installer_path to copy source_path to |
| 246 // target_path and perform any additional on-disk bookkeeping needed to be | 246 // target_path and perform any additional on-disk bookkeeping needed to be |
| 247 // able to launch target_path properly. If authorization_arg is non-NULL, | 247 // able to launch target_path properly. If authorization_arg is non-NULL, |
| 248 // function will assume ownership of it, will invoke the installer with that | 248 // function will assume ownership of it, will invoke the installer with that |
| 249 // authorization reference, and will attempt Keystone ticket promotion. | 249 // authorization reference, and will attempt Keystone ticket promotion. |
| 250 bool InstallFromDiskImage(AuthorizationRef authorization_arg, | 250 bool InstallFromDiskImage(AuthorizationRef authorization_arg, |
| 251 NSString* installer_path, | 251 NSString* installer_path, |
| 252 NSString* source_path, | 252 NSString* source_path, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 const int psn_flag_length = arraysize(psn_flag) - 1; | 332 const int psn_flag_length = arraysize(psn_flag) - 1; |
| 333 if (argument.compare(0, psn_flag_length, psn_flag) != 0) { | 333 if (argument.compare(0, psn_flag_length, psn_flag) != 0) { |
| 334 // Strip any -psn_ arguments, as they apply to a specific process. | 334 // Strip any -psn_ arguments, as they apply to a specific process. |
| 335 [arguments addObject:[NSString stringWithUTF8String:argument.c_str()]]; | 335 [arguments addObject:[NSString stringWithUTF8String:argument.c_str()]]; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 struct LSApplicationParameters parameters = {0}; | 339 struct LSApplicationParameters parameters = {0}; |
| 340 parameters.flags = kLSLaunchDefaults; | 340 parameters.flags = kLSLaunchDefaults; |
| 341 parameters.application = &app_fsref; | 341 parameters.application = &app_fsref; |
| 342 parameters.argv = reinterpret_cast<CFArrayRef>(arguments); | 342 parameters.argv = base::mac::NSToCFCast(arguments); |
| 343 | 343 |
| 344 err = LSOpenApplication(¶meters, NULL); | 344 err = LSOpenApplication(¶meters, NULL); |
| 345 if (err != noErr) { | 345 if (err != noErr) { |
| 346 LOG(ERROR) << "LSOpenApplication: " << err; | 346 LOG(ERROR) << "LSOpenApplication: " << err; |
| 347 return false; | 347 return false; |
| 348 } | 348 } |
| 349 | 349 |
| 350 return true; | 350 return true; |
| 351 } | 351 } |
| 352 | 352 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 installer_path, | 429 installer_path, |
| 430 source_path, | 430 source_path, |
| 431 target_path) || | 431 target_path) || |
| 432 !LaunchInstalledApp(target_path)) { | 432 !LaunchInstalledApp(target_path)) { |
| 433 ShowErrorDialog(); | 433 ShowErrorDialog(); |
| 434 return false; | 434 return false; |
| 435 } | 435 } |
| 436 | 436 |
| 437 return true; | 437 return true; |
| 438 } | 438 } |
| OLD | NEW |