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

Side by Side Diff: chrome/installer/mac/app/AppDelegate.m

Issue 2243863003: Added authorized install with a script to do the copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up code and made the script waiting not awkward Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "AppDelegate.h" 5 #import "AppDelegate.h"
6 6
7 #import "InstallerWindowController.h" 7 #import "InstallerWindowController.h"
8 #import "NSError+ChromeInstallerAdditions.h" 8 #import "NSError+ChromeInstallerAdditions.h"
9 #import "NSAlert+ChromeInstallerAdditions.h" 9 #import "NSAlert+ChromeInstallerAdditions.h"
10 #import "AuthorizedInstall.h"
10 11
11 @interface NSAlert () 12 @interface NSAlert ()
12 - (void)beginSheetModalForWindow:(NSWindow*)sheetWindow 13 - (void)beginSheetModalForWindow:(NSWindow*)sheetWindow
13 completionHandler: 14 completionHandler:
14 (void (^__nullable)(NSModalResponse returnCode))handler; 15 (void (^__nullable)(NSModalResponse returnCode))handler;
15 @end 16 @end
16 17
17 @interface AppDelegate ()<OmahaCommunicationDelegate, DownloaderDelegate> { 18 @interface AppDelegate ()<OmahaCommunicationDelegate, DownloaderDelegate> {
18 InstallerWindowController* installerWindowController_; 19 InstallerWindowController* installerWindowController_;
20 AuthorizedInstall* authorizedInstall_;
19 } 21 }
20 @property(strong) NSWindow* window; 22 @property(strong) NSWindow* window;
21 @end 23 @end
22 24
23 @implementation AppDelegate 25 @implementation AppDelegate
24 @synthesize window = window_; 26 @synthesize window = window_;
25 27
26 // Sets up the main window and begins the downloading process. 28 // Sets up the main window and begins the downloading process.
27 - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { 29 - (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
30 // TODO: fix UI not loading until after asking for authorization.
28 installerWindowController_ = 31 installerWindowController_ =
29 [[InstallerWindowController alloc] initWithWindow:window_]; 32 [[InstallerWindowController alloc] initWithWindow:window_];
30 [self startDownload]; 33 authorizedInstall_ = [[AuthorizedInstall alloc] init];
34 if ([authorizedInstall_ loadInstallationTool]) {
35 [self startDownload];
36 } else {
37 [self onLoadInstallationToolFailure];
38 }
31 } 39 }
32 40
33 - (void)applicationWillTerminate:(NSNotification*)aNotification { 41 - (void)applicationWillTerminate:(NSNotification*)aNotification {
34 } 42 }
35 43
36 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender { 44 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender {
37 return YES; 45 return YES;
38 } 46 }
39 47
40 - (void)startDownload { 48 - (void)startDownload {
(...skipping 22 matching lines...) Expand all
63 // Bridge method from Downloader to InstallerWindowController. Allows Downloader 71 // Bridge method from Downloader to InstallerWindowController. Allows Downloader
64 // to update the progressbar without having direct access to any UI obejcts. 72 // to update the progressbar without having direct access to any UI obejcts.
65 - (void)didDownloadData:(double)downloadProgressPercentage { 73 - (void)didDownloadData:(double)downloadProgressPercentage {
66 [installerWindowController_ 74 [installerWindowController_
67 updateDownloadProgress:(double)downloadProgressPercentage]; 75 updateDownloadProgress:(double)downloadProgressPercentage];
68 } 76 }
69 77
70 - (void)downloader:(Downloader*)download 78 - (void)downloader:(Downloader*)download
71 onDownloadSuccess:(NSURL*)diskImagePath { 79 onDownloadSuccess:(NSURL*)diskImagePath {
72 [installerWindowController_ updateStatusDescription:@"Done."]; 80 [installerWindowController_ updateStatusDescription:@"Done."];
73 // TODO: replace the line of code below with real code someday 81 // 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.
82 // the mounted disk image path to startInstall. Currently passing hardcoded
83 // path to preunpacked app bundle.
84 //[authorizedInstall_
85 // 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.
74 } 86 }
75 87
76 - (void)downloader:(Downloader*)download 88 - (void)downloader:(Downloader*)download
77 onDownloadFailureWithError:(NSError*)error { 89 onDownloadFailureWithError:(NSError*)error {
78 NSError* downloadError = 90 NSError* downloadError =
79 [NSError errorForAlerts:@"Download Failure" 91 [NSError errorForAlerts:@"Download Failure"
80 withDescription:@"Unable to download Google Chrome." 92 withDescription:@"Unable to download Google Chrome."
81 isRecoverable:NO]; 93 isRecoverable:NO];
82 [self displayError:downloadError]; 94 [self displayError:downloadError];
83 } 95 }
84 96
97 - (void)onLoadInstallationToolFailure {
98 NSError* loadToolError = [NSError
99 errorForAlerts:@"Could not load installion tool"
100 withDescription:
101 @"Your Chrome Installer may be corrupted. Download and try again."
102 isRecoverable:NO];
103 [self displayError:loadToolError];
104 }
105
85 // Displays an alert on the main window using the contents of the passed in 106 // Displays an alert on the main window using the contents of the passed in
86 // error. 107 // error.
87 - (void)displayError:(NSError*)error { 108 - (void)displayError:(NSError*)error {
88 NSAlert* alertForUser = [NSAlert alertWithError:error]; 109 NSAlert* alertForUser = [NSAlert alertWithError:error];
89 110
90 dispatch_sync(dispatch_get_main_queue(), ^{ 111 dispatch_async(dispatch_get_main_queue(), ^{
91 [alertForUser beginSheetModalForWindow:window_ 112 [alertForUser beginSheetModalForWindow:window_
92 completionHandler:^(NSModalResponse returnCode) { 113 completionHandler:^(NSModalResponse returnCode) {
93 if (returnCode != [alertForUser quitButton]) { 114 if (returnCode != [alertForUser quitButton]) {
94 [self startDownload]; 115 [self startDownload];
95 } else { 116 } else {
96 [NSApp terminate:nil]; 117 [NSApp terminate:nil];
97 } 118 }
98 }]; 119 }];
99 }); 120 });
100 } 121 }
101 122
123
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.
124
102 @end 125 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/mac/app/AuthorizedInstall.h » ('j') | chrome/installer/mac/app/AuthorizedInstall.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698