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

Side by Side Diff: chrome/browser/mac/install_from_dmg.mm

Issue 9764013: Move authorization_util files into base/mac. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix license headers Created 8 years, 9 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
« no previous file with comments | « chrome/browser/mac/authorization_util.mm ('k') | chrome/browser/mac/keystone_glue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/authorization_util.h"
24 #include "base/mac/bundle_locations.h" 25 #include "base/mac/bundle_locations.h"
25 #include "base/mac/mac_logging.h" 26 #include "base/mac/mac_logging.h"
26 #import "base/mac/mac_util.h" 27 #import "base/mac/mac_util.h"
28 #include "base/mac/scoped_authorizationref.h"
27 #include "base/mac/scoped_cftyperef.h" 29 #include "base/mac/scoped_cftyperef.h"
28 #include "base/mac/scoped_nsautorelease_pool.h" 30 #include "base/mac/scoped_nsautorelease_pool.h"
29 #include "base/string_util.h" 31 #include "base/string_util.h"
30 #include "base/sys_string_conversions.h" 32 #include "base/sys_string_conversions.h"
31 #include "chrome/browser/mac/authorization_util.h"
32 #include "chrome/browser/mac/dock.h" 33 #include "chrome/browser/mac/dock.h"
33 #include "chrome/browser/mac/scoped_authorizationref.h"
34 #include "chrome/browser/mac/scoped_ioobject.h" 34 #include "chrome/browser/mac/scoped_ioobject.h"
35 #import "chrome/browser/mac/keystone_glue.h" 35 #import "chrome/browser/mac/keystone_glue.h"
36 #include "chrome/browser/mac/relauncher.h" 36 #include "chrome/browser/mac/relauncher.h"
37 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
38 #include "grit/chromium_strings.h" 38 #include "grit/chromium_strings.h"
39 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/l10n/l10n_util_mac.h" 41 #include "ui/base/l10n/l10n_util_mac.h"
42 42
43 // When C++ exceptions are disabled, the C++ library defines |try| and 43 // When C++ exceptions are disabled, the C++ library defines |try| and
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // application_directory. Returns NULL if authorization fails. 272 // application_directory. Returns NULL if authorization fails.
273 AuthorizationRef MaybeShowAuthorizationDialog(NSString* application_directory) { 273 AuthorizationRef MaybeShowAuthorizationDialog(NSString* application_directory) {
274 NSFileManager* file_manager = [NSFileManager defaultManager]; 274 NSFileManager* file_manager = [NSFileManager defaultManager];
275 if ([file_manager isWritableFileAtPath:application_directory]) { 275 if ([file_manager isWritableFileAtPath:application_directory]) {
276 return NULL; 276 return NULL;
277 } 277 }
278 278
279 NSString* prompt = l10n_util::GetNSStringFWithFixup( 279 NSString* prompt = l10n_util::GetNSStringFWithFixup(
280 IDS_INSTALL_FROM_DMG_AUTHENTICATION_PROMPT, 280 IDS_INSTALL_FROM_DMG_AUTHENTICATION_PROMPT,
281 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 281 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
282 return authorization_util::AuthorizationCreateToRunAsRoot( 282 return base::mac::AuthorizationCreateToRunAsRoot(
283 base::mac::NSToCFCast(prompt)); 283 base::mac::NSToCFCast(prompt));
284 } 284 }
285 285
286 // Invokes the installer program at installer_path to copy source_path to 286 // Invokes the installer program at installer_path to copy source_path to
287 // target_path and perform any additional on-disk bookkeeping needed to be 287 // target_path and perform any additional on-disk bookkeeping needed to be
288 // able to launch target_path properly. If authorization_arg is non-NULL, 288 // able to launch target_path properly. If authorization_arg is non-NULL,
289 // function will assume ownership of it, will invoke the installer with that 289 // function will assume ownership of it, will invoke the installer with that
290 // authorization reference, and will attempt Keystone ticket promotion. 290 // authorization reference, and will attempt Keystone ticket promotion.
291 bool InstallFromDiskImage(AuthorizationRef authorization_arg, 291 bool InstallFromDiskImage(AuthorizationRef authorization_arg,
292 NSString* installer_path, 292 NSString* installer_path,
293 NSString* source_path, 293 NSString* source_path,
294 NSString* target_path) { 294 NSString* target_path) {
295 ScopedAuthorizationRef authorization(authorization_arg); 295 base::mac::ScopedAuthorizationRef authorization(authorization_arg);
296 authorization_arg = NULL; 296 authorization_arg = NULL;
297 int exit_status; 297 int exit_status;
298 if (authorization) { 298 if (authorization) {
299 const char* installer_path_c = [installer_path fileSystemRepresentation]; 299 const char* installer_path_c = [installer_path fileSystemRepresentation];
300 const char* source_path_c = [source_path fileSystemRepresentation]; 300 const char* source_path_c = [source_path fileSystemRepresentation];
301 const char* target_path_c = [target_path fileSystemRepresentation]; 301 const char* target_path_c = [target_path fileSystemRepresentation];
302 const char* arguments[] = {source_path_c, target_path_c, NULL}; 302 const char* arguments[] = {source_path_c, target_path_c, NULL};
303 303
304 OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( 304 OSStatus status = base::mac::ExecuteWithPrivilegesAndWait(
305 authorization, 305 authorization,
306 installer_path_c, 306 installer_path_c,
307 kAuthorizationFlagDefaults, 307 kAuthorizationFlagDefaults,
308 arguments, 308 arguments,
309 NULL, // pipe 309 NULL, // pipe
310 &exit_status); 310 &exit_status);
311 if (status != errAuthorizationSuccess) { 311 if (status != errAuthorizationSuccess) {
312 OSSTATUS_LOG(ERROR, status) 312 OSSTATUS_LOG(ERROR, status)
313 << "AuthorizationExecuteWithPrivileges install"; 313 << "AuthorizationExecuteWithPrivileges install";
314 return false; 314 return false;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 [base::mac::FrameworkBundle() pathForResource:@"install" ofType:@"sh"]; 441 [base::mac::FrameworkBundle() pathForResource:@"install" ofType:@"sh"];
442 if (!installer_path) { 442 if (!installer_path) {
443 VLOG(1) << "Could not locate install.sh"; 443 VLOG(1) << "Could not locate install.sh";
444 return false; 444 return false;
445 } 445 }
446 446
447 if (!ShouldInstallDialog()) { 447 if (!ShouldInstallDialog()) {
448 return false; 448 return false;
449 } 449 }
450 450
451 ScopedAuthorizationRef authorization( 451 base::mac::ScopedAuthorizationRef authorization(
452 MaybeShowAuthorizationDialog(application_directory)); 452 MaybeShowAuthorizationDialog(application_directory));
453 // authorization will be NULL if it's deemed unnecessary or if 453 // authorization will be NULL if it's deemed unnecessary or if
454 // authentication fails. In either case, try to install without privilege 454 // authentication fails. In either case, try to install without privilege
455 // escalation. 455 // escalation.
456 456
457 if (!InstallFromDiskImage(authorization.release(), 457 if (!InstallFromDiskImage(authorization.release(),
458 installer_path, 458 installer_path,
459 source_path, 459 source_path,
460 target_path)) { 460 target_path)) {
461 ShowErrorDialog(); 461 ShowErrorDialog();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( 676 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>(
677 trash_path.value().c_str()); 677 trash_path.value().c_str());
678 status = FNNotifyByPath(trash_path_u8, 678 status = FNNotifyByPath(trash_path_u8,
679 kFNDirectoryModifiedMessage, 679 kFNDirectoryModifiedMessage,
680 kNilOptions); 680 kNilOptions);
681 if (status != noErr) { 681 if (status != noErr) {
682 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath"; 682 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath";
683 return; 683 return;
684 } 684 }
685 } 685 }
OLDNEW
« no previous file with comments | « chrome/browser/mac/authorization_util.mm ('k') | chrome/browser/mac/keystone_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698