Chromium Code Reviews| 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 <stdlib.h> | 14 #include <stdlib.h> |
| 14 #include <string.h> | 15 #include <string.h> |
| 15 #include <sys/param.h> | 16 #include <sys/param.h> |
| 16 #include <sys/mount.h> | 17 #include <sys/mount.h> |
| 17 | 18 |
| 18 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 19 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 21 #include "base/file_path.h" | 22 #include "base/file_path.h" |
| 22 #include "base/logging.h" | 23 #include "base/logging.h" |
| 23 #import "base/mac/mac_util.h" | 24 #import "base/mac/mac_util.h" |
| 24 #include "base/mac/scoped_cftyperef.h" | 25 #include "base/mac/scoped_cftyperef.h" |
| 25 #include "base/mac/scoped_nsautorelease_pool.h" | 26 #include "base/mac/scoped_nsautorelease_pool.h" |
| 26 #include "base/string_util.h" | 27 #include "base/string_util.h" |
| 27 #include "base/sys_string_conversions.h" | 28 #include "base/sys_string_conversions.h" |
| 28 #include "chrome/browser/mac/authorization_util.h" | 29 #include "chrome/browser/mac/authorization_util.h" |
| 29 #include "chrome/browser/mac/scoped_authorizationref.h" | 30 #include "chrome/browser/mac/scoped_authorizationref.h" |
| 30 #include "chrome/browser/mac/scoped_ioobject.h" | 31 #include "chrome/browser/mac/scoped_ioobject.h" |
| 31 #import "chrome/browser/mac/keystone_glue.h" | 32 #import "chrome/browser/mac/keystone_glue.h" |
| 33 #include "chrome/browser/mac/launchd.h" | |
| 32 #include "chrome/browser/mac/relauncher.h" | 34 #include "chrome/browser/mac/relauncher.h" |
| 33 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
| 34 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/l10n/l10n_util_mac.h" | 39 #include "ui/base/l10n/l10n_util_mac.h" |
| 38 | 40 |
| 39 // When C++ exceptions are disabled, the C++ library defines |try| and | 41 // When C++ exceptions are disabled, the C++ library defines |try| and |
| 40 // |catch| so as to allow exception-expecting C++ code to build properly when | 42 // |catch| so as to allow exception-expecting C++ code to build properly when |
| 41 // language support for exceptions is not present. These macros interfere | 43 // language support for exceptions is not present. These macros interfere |
| 42 // with the use of |@try| and |@catch| in Objective-C files such as this one. | 44 // with the use of |@try| and |@catch| in Objective-C files such as this one. |
| 43 // Undefine these macros here, after everything has been #included, since | 45 // Undefine these macros here, after everything has been #included, since |
| 44 // there will be no C++ uses and only Objective-C uses from this point on. | 46 // there will be no C++ uses and only Objective-C uses from this point on. |
| 45 #undef try | 47 #undef try |
| 46 #undef catch | 48 #undef catch |
| 47 | 49 |
| 48 namespace { | 50 namespace { |
| 49 | 51 |
| 52 NSString* const kDockTileDataKey = @"tile-data"; | |
| 53 NSString* const kDockFileDataKey = @"file-data"; | |
| 54 NSString* const kDockCFURLStringKey = @"_CFURLString"; | |
| 55 NSString* const kDockCFURLStringTypeKey = @"_CFURLStringType"; | |
| 56 | |
| 50 // Given an io_service_t (expected to be of class IOMedia), walks the ancestor | 57 // Given an io_service_t (expected to be of class IOMedia), walks the ancestor |
| 51 // chain, returning the closest ancestor that implements class IOHDIXHDDrive, | 58 // chain, returning the closest ancestor that implements class IOHDIXHDDrive, |
| 52 // if any. If no such ancestor is found, returns NULL. Following the "copy" | 59 // if any. If no such ancestor is found, returns NULL. Following the "copy" |
| 53 // rule, the caller assumes ownership of the returned value. | 60 // rule, the caller assumes ownership of the returned value. |
| 54 // | 61 // |
| 55 // Note that this looks for a class that inherits from IOHDIXHDDrive, but it | 62 // Note that this looks for a class that inherits from IOHDIXHDDrive, but it |
| 56 // will not likely find a concrete IOHDIXHDDrive. It will be | 63 // will not likely find a concrete IOHDIXHDDrive. It will be |
| 57 // IOHDIXHDDriveOutKernel for disk images mounted "out-of-kernel" or | 64 // IOHDIXHDDriveOutKernel for disk images mounted "out-of-kernel" or |
| 58 // IOHDIXHDDriveInKernel for disk images mounted "in-kernel." Out-of-kernel is | 65 // IOHDIXHDDriveInKernel for disk images mounted "in-kernel." Out-of-kernel is |
| 59 // the default as of Mac OS X 10.5. See the documentation for "hdiutil attach | 66 // the default as of Mac OS X 10.5. See the documentation for "hdiutil attach |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 // ticket. Inform KeystoneGlue of the new path to use. | 340 // ticket. Inform KeystoneGlue of the new path to use. |
| 334 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; | 341 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; |
| 335 [keystone_glue setAppPath:target_path]; | 342 [keystone_glue setAppPath:target_path]; |
| 336 [keystone_glue promoteTicketWithAuthorization:authorization.release() | 343 [keystone_glue promoteTicketWithAuthorization:authorization.release() |
| 337 synchronous:YES]; | 344 synchronous:YES]; |
| 338 } | 345 } |
| 339 | 346 |
| 340 return true; | 347 return true; |
| 341 } | 348 } |
| 342 | 349 |
| 350 // Returns an array parallel to |persistent_apps| containing only the | |
| 351 // pathnames of the Dock tiles contained therein. Returns nil on failure, such | |
| 352 // as when the structure of |persistent_apps| is not understood. | |
| 353 NSMutableArray* PersistentAppPaths(NSArray* persistent_apps) { | |
| 354 NSMutableArray* app_paths = | |
| 355 [NSMutableArray arrayWithCapacity:[persistent_apps count]]; | |
| 356 | |
| 357 for (NSDictionary* app in persistent_apps) { | |
| 358 if (![app isKindOfClass:[NSDictionary class]]) { | |
| 359 LOG(ERROR) << "app not NSDictionary"; | |
| 360 return nil; | |
| 361 } | |
| 362 | |
| 363 NSDictionary* tile_data = [app objectForKey:kDockTileDataKey]; | |
| 364 if (![tile_data isKindOfClass:[NSDictionary class]]) { | |
| 365 LOG(ERROR) << "tile_data not NSDictionary"; | |
| 366 return nil; | |
| 367 } | |
| 368 | |
| 369 NSDictionary* file_data = [tile_data objectForKey:kDockFileDataKey]; | |
| 370 if (![file_data isKindOfClass:[NSDictionary class]]) { | |
| 371 LOG(ERROR) << "file_data not NSDictionary"; | |
| 372 return nil; | |
| 373 } | |
| 374 | |
| 375 NSNumber* type = [file_data objectForKey:kDockCFURLStringTypeKey]; | |
| 376 if (![type isKindOfClass:[NSNumber class]]) { | |
| 377 LOG(ERROR) << "type not NSNumber"; | |
| 378 return nil; | |
| 379 } | |
| 380 if ([type intValue] != 0) { | |
| 381 LOG(ERROR) << "type not 0"; | |
| 382 return nil; | |
| 383 } | |
| 384 | |
| 385 NSString* path = [file_data objectForKey:kDockCFURLStringKey]; | |
| 386 if (![path isKindOfClass:[NSString class]]) { | |
| 387 LOG(ERROR) << "path not NSString"; | |
| 388 return nil; | |
| 389 } | |
| 390 | |
| 391 [app_paths addObject:path]; | |
| 392 } | |
| 393 | |
| 394 return app_paths; | |
| 395 } | |
| 396 | |
| 397 // Adds an icon to the Dock pointing to |installed_path| if one is not already | |
| 398 // present. |dmg_app_path| is the path to the install source. Its tile will be | |
| 399 // removed if present. If any changes are made to the Dock's configuration, | |
| 400 // the Dock process is restarted to reflect those changes. | |
| 401 // | |
| 402 // Various heruistics are used to determine where to place the new icon | |
| 403 // relative to other items already present in the Dock: | |
| 404 // - If installed_path is already in the Dock, no new tiles for this path | |
| 405 // will be added. | |
| 406 // - If dmg_app_path is present in the Dock, it will be removed. If | |
| 407 // installed_path is not already present, the new tile referencing | |
| 408 // installed_path will be placed where the dmg_app_path tile was. This | |
| 409 // keeps the tile where a user expects it if they dragged the application | |
| 410 // icon from a disk image into the Dock and then clicked on the new icon | |
| 411 // in the Dock. | |
| 412 // - The new tile will precede any application with the same name already | |
| 413 // in the Dock. | |
| 414 // - In an official build, a new tile for Google Chrome will be placed | |
| 415 // immediately before the first existing tile for Google Chrome Canary, | |
| 416 // and a new tile for Google Chrome Canary will be placed immediately after | |
| 417 // the last existing tile for Google Chrome. | |
| 418 // - The new tile will be placed immediately after the last tile for another | |
| 419 // browser application already in the Dock. | |
| 420 // - The new tile will be placed last in the Dock. | |
| 421 // For the purposes of these comparisons, applications are identified by the | |
| 422 // last component in their path. For example, any application named Safari.app | |
| 423 // will be treated as a browser. If the user renames an application on disk, | |
| 424 // it will alter the result. Looking up the bundle ID could be slightly more | |
| 425 // robust in the presence of such alterations, but it's not thought to be a | |
| 426 // large enough problem to warrant such lookups. | |
| 427 // | |
| 428 // The changes made to the Dock's configuration are the minimal changes | |
| 429 // necessary to cause the desired behavior. Although it's possible to set | |
| 430 // additional properties on the dock tile added to the Dock's plist, this | |
| 431 // is not done. Upon relaunch, Dock.app will determine the correct values for | |
| 432 // the properties it requires and add them to its configuration. | |
| 433 // | |
| 434 // ApplicationServices.framework/Frameworks/HIServices.framework contains an | |
| 435 // undocumented function, CoreDockAddFileToDock, that is able to add items to | |
| 436 // the Dock "live" without requiring a Dock restart. Under the hood, it | |
| 437 // communicates with the Dock via Mach IPC. It is available as of Mac OS X | |
| 438 // 10.6. AddDockIcon could call CoreDockAddFileToDock if available, but | |
| 439 // CoreDockAddFileToDock seems to always to add the new Dock icon last, where | |
| 440 // AddDockIcon takes care to position the icon appropriately. Based on | |
| 441 // disassembly, the signature of the undocumented function appears to be | |
| 442 // extern "C" OSStatus CoreDockAddFileToDock(CFURLRef url, int); | |
| 443 // The int argument doesn't appear to have any effect. It's not used as the | |
| 444 // position to place the icon as hoped. | |
| 445 void AddDockIcon(NSString* installed_path, NSString* dmg_app_path) { | |
| 446 // There's enough potential allocation in this function to justify a | |
| 447 // distinct pool. | |
| 448 base::mac::ScopedNSAutoreleasePool autorelease_pool; | |
| 449 | |
| 450 NSString* const kDockDomain = @"com.apple.dock"; | |
| 451 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; | |
| 452 | |
| 453 NSDictionary* dock_plist_const = | |
| 454 [user_defaults persistentDomainForName:kDockDomain]; | |
| 455 if (![dock_plist_const isKindOfClass:[NSDictionary class]]) { | |
| 456 LOG(ERROR) << "dock_plist_const not NSDictionary"; | |
| 457 return; | |
| 458 } | |
| 459 NSMutableDictionary* dock_plist = | |
| 460 [NSMutableDictionary dictionaryWithDictionary:dock_plist_const]; | |
| 461 | |
| 462 NSString* const kDockPersistentAppsKey = @"persistent-apps"; | |
| 463 NSArray* persistent_apps_const = | |
| 464 [dock_plist objectForKey:kDockPersistentAppsKey]; | |
| 465 if (![persistent_apps_const isKindOfClass:[NSArray class]]) { | |
| 466 LOG(ERROR) << "persistent_apps_const not NSArray"; | |
| 467 return; | |
| 468 } | |
| 469 NSMutableArray* persistent_apps = | |
| 470 [NSMutableArray arrayWithArray:persistent_apps_const]; | |
| 471 | |
| 472 NSMutableArray* persistent_app_paths = PersistentAppPaths(persistent_apps); | |
| 473 if (!persistent_app_paths) { | |
| 474 return; | |
| 475 } | |
| 476 | |
| 477 // Directories in the Dock's plist are given with trailing slashes. Since | |
| 478 // installed_path and dmg_app_path both refer to application bundles, | |
| 479 // they're directories and will show up with trailing slashes. This is an | |
| 480 // artifact of the Dock's internal use of CFURL. Look for paths that match, | |
| 481 // and when adding an item to the Dock's plist, keep it in the form that the | |
| 482 // Dock likes. | |
| 483 NSString* installed_path_dock = [installed_path stringByAppendingString:@"/"]; | |
| 484 NSString* dmg_app_path_dock = [dmg_app_path stringByAppendingString:@"/"]; | |
| 485 | |
| 486 const NSUInteger kNotFound = -1; | |
|
Robert Sesek
2011/06/30 15:49:52
Why not use NSNotFound?
Mark Mentovai
2011/06/30 15:53:58
rsesek wrote:
Mark Mentovai
2011/06/30 16:02:41
I wrote:
| |
| 487 NSUInteger already_installed_app_index = kNotFound; | |
| 488 NSUInteger app_index = kNotFound; | |
| 489 for (NSUInteger index = 0; index < [persistent_apps count]; ++index) { | |
| 490 NSString* app_path = [persistent_app_paths objectAtIndex:index]; | |
| 491 if ([app_path isEqualToString:installed_path_dock]) { | |
| 492 // If the Dock already contains a reference to the newly installed | |
| 493 // application, don't add another one. | |
| 494 already_installed_app_index = index; | |
| 495 } else if ([app_path isEqualToString:dmg_app_path_dock]) { | |
| 496 // If the Dock contains a reference to the application on the disk | |
| 497 // image, replace it with a reference to the newly installed | |
| 498 // application. However, if the Dock contains a reference to both the | |
| 499 // application on the disk image and the newly installed application, | |
| 500 // just remove the one referencing the disk image. | |
| 501 // | |
| 502 // This case is only encountered when the user drags the icon from the | |
| 503 // disk image volume window in the Finder directly into the Dock. | |
| 504 app_index = index; | |
| 505 } | |
| 506 } | |
| 507 | |
| 508 bool made_change = false; | |
| 509 | |
| 510 if (app_index != kNotFound) { | |
| 511 // Remove the Dock's reference to the application on the disk image. | |
| 512 [persistent_apps removeObjectAtIndex:app_index]; | |
| 513 [persistent_app_paths removeObjectAtIndex:app_index]; | |
| 514 made_change = true; | |
| 515 } | |
| 516 | |
| 517 if (already_installed_app_index == kNotFound) { | |
| 518 // The Dock doesn't yet have a reference to the icon at the | |
| 519 // newly installed path. Figure out where to put the new icon. | |
| 520 NSString* app_name = [installed_path lastPathComponent]; | |
| 521 | |
| 522 if (app_index == kNotFound) { | |
| 523 // If an application with this name is already in the Dock, put the new | |
| 524 // one right before it. | |
| 525 for (NSUInteger index = 0; index < [persistent_apps count]; ++index) { | |
| 526 NSString* dock_app_name = | |
| 527 [[persistent_app_paths objectAtIndex:index] lastPathComponent]; | |
| 528 if ([dock_app_name isEqualToString:app_name]) { | |
| 529 app_index = index; | |
| 530 break; | |
| 531 } | |
| 532 } | |
| 533 } | |
| 534 | |
| 535 #if defined(GOOGLE_CHROME_BUILD) | |
| 536 if (app_index == kNotFound) { | |
| 537 // If this is an officially-branded Chrome (including Canary) and an | |
| 538 // application matching the "other" flavor is already in the Dock, put | |
| 539 // them next to each other. Google Chrome will precede Google Chrome | |
| 540 // Canary in the Dock. | |
| 541 NSString* chrome_name = @"Google Chrome.app"; | |
| 542 NSString* canary_name = @"Google Chrome Canary.app"; | |
| 543 for (NSUInteger index = 0; index < [persistent_apps count]; ++index) { | |
| 544 NSString* dock_app_name = | |
| 545 [[persistent_app_paths objectAtIndex:index] lastPathComponent]; | |
| 546 if ([dock_app_name isEqualToString:canary_name] && | |
| 547 [app_name isEqualToString:chrome_name]) { | |
| 548 app_index = index; | |
| 549 | |
| 550 // Break: put Google Chrome.app before the first Google Chrome | |
| 551 // Canary.app. | |
| 552 break; | |
| 553 } else if ([dock_app_name isEqualToString:chrome_name] && | |
| 554 [app_name isEqualToString:canary_name]) { | |
| 555 app_index = index + 1; | |
| 556 | |
| 557 // No break: put Google Chrome Canary.app after the last Google | |
| 558 // Chrome.app. | |
| 559 } | |
| 560 } | |
| 561 } | |
| 562 #endif // GOOGLE_CHROME_BUILD | |
| 563 | |
| 564 if (app_index == kNotFound) { | |
| 565 // Put the new application after the last browser application already | |
| 566 // present in the Dock. | |
| 567 NSArray* other_browser_app_names = | |
| 568 [NSArray arrayWithObjects: | |
| 569 #if defined(GOOGLE_CHROME_BUILD) | |
| 570 @"Chromium.app", // Unbranded Google Chrome | |
| 571 #else | |
| 572 @"Google Chrome.app", | |
| 573 @"Google Chrome Canary.app", | |
| 574 #endif | |
| 575 @"Safari.app", | |
| 576 @"Firefox.app", | |
| 577 @"Camino.app", | |
| 578 @"Opera.app", | |
| 579 @"OmniWeb.app", | |
| 580 @"WebKit.app", // Safari nightly | |
| 581 @"Aurora.app", // Firefox dev | |
| 582 @"Nightly.app", // Firefox nightly | |
| 583 nil]; | |
| 584 for (NSUInteger index = 0; index < [persistent_apps count]; ++index) { | |
| 585 NSString* dock_app_name = | |
| 586 [[persistent_app_paths objectAtIndex:index] lastPathComponent]; | |
| 587 if ([other_browser_app_names containsObject:dock_app_name]) { | |
| 588 app_index = index + 1; | |
| 589 } | |
| 590 } | |
| 591 } | |
| 592 | |
| 593 if (app_index == kNotFound) { | |
| 594 // Put the new application last in the Dock. | |
| 595 app_index = [persistent_apps count]; | |
| 596 } | |
| 597 | |
| 598 // Set up the new Dock tile. | |
| 599 NSDictionary* new_tile_file_data = | |
| 600 [NSDictionary dictionaryWithObjectsAndKeys: | |
| 601 installed_path_dock, kDockCFURLStringKey, | |
| 602 [NSNumber numberWithInt:0], kDockCFURLStringTypeKey, | |
| 603 nil]; | |
| 604 NSDictionary* new_tile_data = | |
| 605 [NSDictionary dictionaryWithObject:new_tile_file_data | |
| 606 forKey:kDockFileDataKey]; | |
| 607 NSDictionary* new_tile = | |
| 608 [NSDictionary dictionaryWithObject:new_tile_data | |
| 609 forKey:kDockTileDataKey]; | |
| 610 | |
| 611 // Add the new tile to the Dock. | |
| 612 [persistent_apps insertObject:new_tile atIndex:app_index]; | |
| 613 [persistent_app_paths insertObject:installed_path_dock atIndex:app_index]; | |
| 614 made_change = true; | |
| 615 } | |
| 616 | |
| 617 // Verify that the arrays are still parallel. | |
| 618 DCHECK_EQ([persistent_apps count], [persistent_app_paths count]); | |
| 619 | |
| 620 if (!made_change) { | |
| 621 // If no changes were made, there's no point in rewriting the Dock's | |
| 622 // plist or restarting the Dock. | |
| 623 return; | |
| 624 } | |
| 625 | |
| 626 // Rewrite the plist. | |
| 627 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; | |
| 628 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; | |
| 629 | |
| 630 // Restart the Dock. Doing this via launchd using the proper job label is | |
| 631 // the safest way to handle the restart. Unlike "killall Dock", looking this | |
| 632 // up via launchd guarantees that only the right process will be targeted. | |
| 633 // Sending a SIGHUP to the Dock seems to be a more reliable way to get the | |
| 634 // replacement Dock process to read the newly written plist than using the | |
| 635 // equivalent of "launchctl stop" (even if followed by "launchctl start.") | |
| 636 launchd::SignalJob("com.apple.Dock.agent", SIGHUP); | |
| 637 } | |
| 638 | |
| 343 // Launches the application at installed_path. The helper application | 639 // Launches the application at installed_path. The helper application |
| 344 // contained within install_path will be used for the relauncher process. This | 640 // contained within install_path will be used for the relauncher process. This |
| 345 // keeps Launch Services from ever having to see or think about the helper | 641 // keeps Launch Services from ever having to see or think about the helper |
| 346 // application on the disk image. The relauncher process will be asked to | 642 // application on the disk image. The relauncher process will be asked to |
| 347 // call EjectAndTrashDiskImage on dmg_bsd_device_name. | 643 // call EjectAndTrashDiskImage on dmg_bsd_device_name. |
| 348 bool LaunchInstalledApp(NSString* installed_path, | 644 bool LaunchInstalledApp(NSString* installed_path, |
| 349 const std::string& dmg_bsd_device_name) { | 645 const std::string& dmg_bsd_device_name) { |
| 350 FilePath browser_path([installed_path fileSystemRepresentation]); | 646 FilePath browser_path([installed_path fileSystemRepresentation]); |
| 351 | 647 |
| 352 FilePath helper_path = browser_path.Append("Contents/Versions"); | 648 FilePath helper_path = browser_path.Append("Contents/Versions"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 737 |
| 442 ScopedAuthorizationRef authorization( | 738 ScopedAuthorizationRef authorization( |
| 443 MaybeShowAuthorizationDialog(application_directory)); | 739 MaybeShowAuthorizationDialog(application_directory)); |
| 444 // authorization will be NULL if it's deemed unnecessary or if | 740 // authorization will be NULL if it's deemed unnecessary or if |
| 445 // authentication fails. In either case, try to install without privilege | 741 // authentication fails. In either case, try to install without privilege |
| 446 // escalation. | 742 // escalation. |
| 447 | 743 |
| 448 if (!InstallFromDiskImage(authorization.release(), | 744 if (!InstallFromDiskImage(authorization.release(), |
| 449 installer_path, | 745 installer_path, |
| 450 source_path, | 746 source_path, |
| 451 target_path) || | 747 target_path)) { |
| 452 !LaunchInstalledApp(target_path, dmg_bsd_device_name)) { | 748 ShowErrorDialog(); |
| 749 return false; | |
| 750 } | |
| 751 | |
| 752 AddDockIcon(target_path, source_path); | |
| 753 | |
| 754 if (!LaunchInstalledApp(target_path, dmg_bsd_device_name)) { | |
| 453 ShowErrorDialog(); | 755 ShowErrorDialog(); |
| 454 return false; | 756 return false; |
| 455 } | 757 } |
| 456 | 758 |
| 457 return true; | 759 return true; |
| 458 } | 760 } |
| 459 | 761 |
| 460 namespace { | 762 namespace { |
| 461 | 763 |
| 462 // A simple scoper that calls DASessionScheduleWithRunLoop when created and | 764 // A simple scoper that calls DASessionScheduleWithRunLoop when created and |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( | 958 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( |
| 657 trash_path.value().c_str()); | 959 trash_path.value().c_str()); |
| 658 status = FNNotifyByPath(trash_path_u8, | 960 status = FNNotifyByPath(trash_path_u8, |
| 659 kFNDirectoryModifiedMessage, | 961 kFNDirectoryModifiedMessage, |
| 660 kNilOptions); | 962 kNilOptions); |
| 661 if (status != noErr) { | 963 if (status != noErr) { |
| 662 LOG(ERROR) << "FNNotifyByPath: " << status; | 964 LOG(ERROR) << "FNNotifyByPath: " << status; |
| 663 return; | 965 return; |
| 664 } | 966 } |
| 665 } | 967 } |
| OLD | NEW |