Index: chrome/installer/mac/app/AppDelegate.m |
diff --git a/chrome/installer/mac/app/AppDelegate.m b/chrome/installer/mac/app/AppDelegate.m |
index ab05d489cf93123af33ee5c139dc8539e2603f91..e7a11a5ddc84c428dc68360dc30e5df972994b0f 100644 |
--- a/chrome/installer/mac/app/AppDelegate.m |
+++ b/chrome/installer/mac/app/AppDelegate.m |
@@ -7,6 +7,7 @@ |
#import "InstallerWindowController.h" |
#import "NSError+ChromeInstallerAdditions.h" |
#import "NSAlert+ChromeInstallerAdditions.h" |
+#import "AuthorizedInstall.h" |
@interface NSAlert () |
- (void)beginSheetModalForWindow:(NSWindow*)sheetWindow |
@@ -16,6 +17,7 @@ |
@interface AppDelegate ()<OmahaCommunicationDelegate, DownloaderDelegate> { |
InstallerWindowController* installerWindowController_; |
+ AuthorizedInstall* authorizedInstall_; |
} |
@property(strong) NSWindow* window; |
@end |
@@ -25,9 +27,15 @@ |
// Sets up the main window and begins the downloading process. |
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification { |
+ // TODO: fix UI not loading until after asking for authorization. |
installerWindowController_ = |
[[InstallerWindowController alloc] initWithWindow:window_]; |
- [self startDownload]; |
+ authorizedInstall_ = [[AuthorizedInstall alloc] init]; |
+ if ([authorizedInstall_ loadInstallationTool]) { |
+ [self startDownload]; |
+ } else { |
+ [self onLoadInstallationToolFailure]; |
+ } |
} |
- (void)applicationWillTerminate:(NSNotification*)aNotification { |
@@ -71,7 +79,11 @@ |
onDownloadSuccess:(NSURL*)diskImagePath { |
[installerWindowController_ updateStatusDescription:@"Done."]; |
[installerWindowController_ enableLaunchButton]; |
- // TODO: replace the line of code below with real code someday |
+ // TODO: Add unpacking step here and pass the path to the app bundle inside |
+ // the mounted disk image path to startInstall. Currently passing hardcoded |
+ // path to preunpacked app bundle. |
+ //[authorizedInstall_ |
+ // startInstall:@"$HOME/Downloads/Google Chrome.app"]; |
} |
- (void)downloader:(Downloader*)download |
@@ -83,12 +95,21 @@ |
[self displayError:downloadError]; |
} |
+- (void)onLoadInstallationToolFailure { |
+ NSError* loadToolError = [NSError |
+ errorForAlerts:@"Could not load installion tool" |
+ withDescription: |
+ @"Your Chrome Installer may be corrupted. Download and try again." |
+ isRecoverable:NO]; |
+ [self displayError:loadToolError]; |
+} |
+ |
// Displays an alert on the main window using the contents of the passed in |
// error. |
- (void)displayError:(NSError*)error { |
NSAlert* alertForUser = [NSAlert alertWithError:error]; |
- dispatch_sync(dispatch_get_main_queue(), ^{ |
+ dispatch_async(dispatch_get_main_queue(), ^{ |
[alertForUser beginSheetModalForWindow:window_ |
completionHandler:^(NSModalResponse returnCode) { |
if (returnCode != [alertForUser quitButton]) { |