Chromium Code Reviews| Index: chrome/installer/mac/app/AppDelegate.m |
| diff --git a/chrome/installer/mac/app/AppDelegate.m b/chrome/installer/mac/app/AppDelegate.m |
| index f60f0db6e36ed8641e1c40dca619541c7b868187..2896d280129ed6c629a1966ee6af182e347082e7 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 { |
| @@ -70,7 +78,11 @@ |
| - (void)downloader:(Downloader*)download |
| onDownloadSuccess:(NSURL*)diskImagePath { |
| [installerWindowController_ updateStatusDescription:@"Done."]; |
| - // 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 |
|
Anna Zeng
2016/08/23 19:36:12
I appreciate the verboseness of this TODO.
ivanhernandez
2016/08/24 18:23:16
Done.
|
| + // the mounted disk image path to startInstall. Currently passing hardcoded |
| + // path to preunpacked app bundle. |
| + //[authorizedInstall_ |
| + // startInstall:@"/Users/ivanhernandez/Downloads/Google Chromo.app"]; |
|
Elly Fong-Jones
2016/08/24 16:39:22
In comments it's fine to be like, @"$HOME/Download
ivanhernandez
2016/08/24 18:23:16
Done.
|
| } |
| - (void)downloader:(Downloader*)download |
| @@ -82,12 +94,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]) { |
| @@ -99,4 +120,6 @@ |
| }); |
| } |
| + |
|
Anna Zeng
2016/08/23 19:36:12
Odd that there's extra new lines here. Remove?
ivanhernandez
2016/08/24 18:23:16
Done.
|
| + |
| @end |