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..49e902bc1e87ace260e44e6025dff4acefe91172 100644 |
| --- a/chrome/installer/mac/app/AppDelegate.m |
| +++ b/chrome/installer/mac/app/AppDelegate.m |
| @@ -4,9 +4,12 @@ |
| #import "AppDelegate.h" |
| +#import "Downloader.h" |
| #import "InstallerWindowController.h" |
| #import "NSError+ChromeInstallerAdditions.h" |
| #import "NSAlert+ChromeInstallerAdditions.h" |
| +#import "OmahaCommunication.h" |
| +#import "Unpacker.h" |
| @interface NSAlert () |
| - (void)beginSheetModalForWindow:(NSWindow*)sheetWindow |
| @@ -14,7 +17,9 @@ |
| (void (^__nullable)(NSModalResponse returnCode))handler; |
| @end |
| -@interface AppDelegate ()<OmahaCommunicationDelegate, DownloaderDelegate> { |
| +@interface AppDelegate ()<OmahaCommunicationDelegate, |
| + DownloaderDelegate, |
| + UnpackDelegate> { |
| InstallerWindowController* installerWindowController_; |
| } |
| @property(strong) NSWindow* window; |
| @@ -45,14 +50,16 @@ |
| [omahaMessenger fetchDownloadURLs]; |
| } |
| -- (void)onOmahaSuccessWithURLs:(NSArray*)URLs { |
| +- (void)omahaCommunication:(OmahaCommunication*)messenger |
| + onOmahaSuccessWithURLs:(NSArray*)URLs { |
| [installerWindowController_ updateStatusDescription:@"Downloading..."]; |
| Downloader* download = [[Downloader alloc] init]; |
| download.delegate = self; |
| - [download downloadChromeImageToDownloadsDirectory:[URLs firstObject]]; |
| + [download downloadChromeImageFrom:[URLs firstObject]]; |
| } |
| -- (void)onOmahaFailureWithError:(NSError*)error { |
| +- (void)omahaCommunication:(OmahaCommunication*)messenger |
| + onOmahaFailureWithError:(NSError*)error { |
| NSError* networkError = |
| [NSError errorForAlerts:@"Network Error" |
| withDescription:@"Could not connect to Chrome server." |
| @@ -62,15 +69,21 @@ |
| // Bridge method from Downloader to InstallerWindowController. Allows Downloader |
| // to update the progressbar without having direct access to any UI obejcts. |
| -- (void)didDownloadData:(double)downloadProgressPercentage { |
| +- (void)downloader:(Downloader*)download |
| + didDownloadData:(double)downloadProgressPercentage { |
| [installerWindowController_ |
| updateDownloadProgress:(double)downloadProgressPercentage]; |
| } |
| - (void)downloader:(Downloader*)download |
| - onDownloadSuccess:(NSURL*)diskImagePath { |
| + onDownloadSuccessWithDiskURL:(NSURL*)diskImagePath { |
| [installerWindowController_ updateStatusDescription:@"Done."]; |
| - // TODO: replace the line of code below with real code someday |
| + |
| + Unpacker* unpacker = [[Unpacker alloc] |
|
Elly Fong-Jones
2016/08/16 15:26:18
who owns the unpacker? it looks like we don't stor
Anna Zeng
2016/08/16 23:07:39
Currently, nobody owns it, just the same as how we
Sidney San Martín
2016/08/17 22:09:06
ellyjones@: Just curious, is the plan to use ARC f
|
| + initWithFinalAppPath:@"/Applications/Google Chromo.app"]; |
| + unpacker.delegate = self; |
| + |
| + [unpacker mountDMGFromURL:diskImagePath]; |
| } |
| - (void)downloader:(Downloader*)download |
| @@ -82,6 +95,46 @@ |
| [self displayError:downloadError]; |
| } |
| +- (void)unpacker:(Unpacker*)unpacker onMountSuccess:(NSString*)mountpath { |
| + [unpacker extractChrome]; |
| +} |
| + |
| +// TODO: adjust error descriptions for the following failure methods |
| +- (void)unpacker:(Unpacker*)unpacker onMountFailure:(NSString*)mountpath { |
| + NSError* mountError = |
| + [NSError errorForAlerts:@"Install Failure" |
| + withDescription:@"Unable to add Google Chrome to Applications." |
| + isRecoverable:NO]; |
| + [self displayError:mountError]; |
| +} |
| + |
| +- (void)unpacker:(Unpacker*)unpacker onExtractSuccess:(NSString*)appPath { |
| + [unpacker unmountDMG]; |
| +} |
| + |
| +- (void)unpacker:(Unpacker*)unpacker onExtractFailure:(NSString*)appPath { |
| + NSError* extractError = |
| + [NSError errorForAlerts:@"Install Failure" |
| + withDescription:@"Unable to add Google Chrome to Applications." |
| + isRecoverable:NO]; |
| + [self displayError:extractError]; |
| +} |
| + |
| +- (void)unpacker:(Unpacker*)unpacker onUnmountSuccess:(NSError*)error { |
| + // TODO: change the name of chromo to chrome |
| + if (![[NSWorkspace sharedWorkspace] launchApplication:@"Google Chromo"]) { |
|
Sidney San Martín
2016/08/13 12:37:18
Pass the full path or use `launchApplicationAtURL:
Elly Fong-Jones
2016/08/16 15:26:18
Also, we're not called "Chromo" :)
Anna Zeng
2016/08/16 23:07:39
Done.
Anna Zeng
2016/08/16 23:07:39
I made a note of this, and added a TODO to make th
|
| + NSLog(@"Chromo failed to launch"); |
| + } |
| +} |
| + |
| +- (void)unpacker:(Unpacker*)unpacker onUnmountFailure:(NSString*)appPath { |
| + NSError* extractError = |
| + [NSError errorForAlerts:@"Install Failure" |
| + withDescription:@"Unable to add Google Chrome to Applications." |
| + isRecoverable:NO]; |
| + [self displayError:extractError]; |
|
Sidney San Martín
2016/08/13 12:37:18
Is an unmount failure fatal/worth showing the user
Anna Zeng
2016/08/16 23:07:39
This is true! I have now moved the unmount step to
|
| +} |
| + |
| // Displays an alert on the main window using the contents of the passed in |
| // error. |
| - (void)displayError:(NSError*)error { |