OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "remoting/host/installer/mac/uninstaller/remoting_uninstaller.h" |
| 11 |
| 12 @implementation RemotingUninstallerAppDelegate |
| 13 |
| 14 - (void)dealloc { |
| 15 [super dealloc]; |
| 16 } |
| 17 |
| 18 - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { |
| 19 } |
| 20 |
| 21 - (void)showSuccess:(bool)success withMessage:(NSString*) message { |
| 22 NSString* summary = success ? @"Uninstall succeeded" : @"Uninstall failed"; |
| 23 NSAlert* alert = [NSAlert alertWithMessageText:summary |
| 24 defaultButton:@"OK" |
| 25 alternateButton:nil |
| 26 otherButton:nil |
| 27 informativeTextWithFormat:message]; |
| 28 [alert runModal]; |
| 29 } |
| 30 |
| 31 - (IBAction)uninstall:(NSButton*)sender { |
| 32 @try { |
| 33 NSLog(@"Chrome Remote Desktop uninstall starting."); |
| 34 |
| 35 RemotingUninstaller* uninstaller = |
| 36 [[[RemotingUninstaller alloc] init] autorelease]; |
| 37 OSStatus status = [uninstaller remotingUninstall]; |
| 38 |
| 39 NSLog(@"Chrome Remote Desktop Host uninstall complete."); |
| 40 |
| 41 bool success = false; |
| 42 NSString* message = NULL; |
| 43 if (status == errAuthorizationSuccess) { |
| 44 success = true; |
| 45 message = @"Chrome Remote Desktop Host successfully uninstalled."; |
| 46 } else if (status == errAuthorizationCanceled) { |
| 47 message = @"Chrome Remote Desktop Host uninstall canceled."; |
| 48 } else if (status == errAuthorizationDenied) { |
| 49 message = @"Chrome Remote Desktop Host uninstall authorization denied."; |
| 50 } else { |
| 51 [NSException raise:@"AuthorizationCopyRights Failure" |
| 52 format:@"Error during AuthorizationCopyRights status=%ld", status]; |
| 53 } |
| 54 if (message != NULL) { |
| 55 NSLog(@"Uninstall %s: %@", success ? "succeeded" : "failed", message); |
| 56 [self showSuccess:success withMessage:message]; |
| 57 } |
| 58 } |
| 59 @catch (NSException* exception) { |
| 60 NSLog(@"Exception %@ %@", [exception name], [exception reason]); |
| 61 NSString* message = |
| 62 @"Error! Unable to uninstall Chrome Remote Desktop Host."; |
| 63 [self showSuccess:false withMessage:message]; |
| 64 } |
| 65 |
| 66 [NSApp terminate:self]; |
| 67 } |
| 68 |
| 69 - (IBAction)cancel:(id)sender { |
| 70 [NSApp terminate:self]; |
| 71 } |
| 72 |
| 73 - (IBAction)handleMenuClose:(NSMenuItem*)sender { |
| 74 [NSApp terminate:self]; |
| 75 } |
| 76 |
| 77 @end |
| 78 |
| 79 int main(int argc, char* argv[]) |
| 80 { |
| 81 // The no-ui option skips the UI confirmation dialogs. This is provided as |
| 82 // a convenience for our automated testing. |
| 83 // There will still be an elevation prompt unless the command is run as root. |
| 84 if (argc == 2 && !strcmp(argv[1], "--no-ui")) { |
| 85 @autoreleasepool { |
| 86 NSLog(@"Chrome Remote Desktop uninstall starting."); |
| 87 NSLog(@"--no-ui : Suppressing UI"); |
| 88 |
| 89 RemotingUninstaller* uninstaller = |
| 90 [[[RemotingUninstaller alloc] init] autorelease]; |
| 91 OSStatus status = [uninstaller remotingUninstall]; |
| 92 |
| 93 NSLog(@"Chrome Remote Desktop Host uninstall complete."); |
| 94 NSLog(@"Status = %ld", status); |
| 95 return status != errAuthorizationSuccess; |
| 96 } |
| 97 } else { |
| 98 return NSApplicationMain(argc, (const char**)argv); |
| 99 } |
| 100 } |
| 101 |
OLD | NEW |