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)messageBox:(const char*)message { |
| 22 base::mac::ScopedCFTypeRef<CFStringRef> message_ref( |
| 23 CFStringCreateWithCString(kCFAllocatorDefault, message, |
| 24 kCFStringEncodingUTF8)); |
| 25 CFOptionFlags result; |
| 26 CFUserNotificationDisplayAlert(0, kCFUserNotificationNoteAlertLevel, |
| 27 NULL, NULL, NULL, |
| 28 CFSTR("Chrome Remote Desktop Uninstaller"), |
| 29 message_ref, NULL, NULL, NULL, &result); |
| 30 } |
| 31 |
| 32 - (IBAction)uninstall:(NSButton*)sender { |
| 33 @try { |
| 34 NSLog(@"Chrome Remote Desktop uninstall starting."); |
| 35 |
| 36 RemotingUninstaller* uninstaller = |
| 37 [[[RemotingUninstaller alloc] init] autorelease]; |
| 38 OSStatus status = [uninstaller remotingUninstall]; |
| 39 |
| 40 NSLog(@"Chrome Remote Desktop Host uninstall complete."); |
| 41 |
| 42 const char* message = NULL; |
| 43 if (status == errAuthorizationSuccess) { |
| 44 message = "Chrome Remote Desktop Host was successfully uninstalled."; |
| 45 } else if (status == errAuthorizationCanceled) { |
| 46 message = "Chrome Remote Desktop Host uninstall canceled."; |
| 47 } else if (status == errAuthorizationDenied) { |
| 48 message = "Chrome Remote Desktop Host uninstall authorization denied."; |
| 49 } else { |
| 50 [NSException raise:@"AuthorizationCopyRights Failure" |
| 51 format:@"Error during AuthorizationCopyRights status=%ld", status]; |
| 52 } |
| 53 if (message != NULL) { |
| 54 NSLog(@"%s", message); |
| 55 [self messageBox:message]; |
| 56 } |
| 57 } |
| 58 @catch (NSException* exception) { |
| 59 NSLog(@"Exception %@ %@", [exception name], [exception reason]); |
| 60 const char* message = |
| 61 "Error! Unable to uninstall Chrome Remote Desktop Host."; |
| 62 [self messageBox:message]; |
| 63 } |
| 64 |
| 65 [NSApp terminate:self]; |
| 66 } |
| 67 |
| 68 - (IBAction)cancel:(id)sender { |
| 69 [NSApp terminate:self]; |
| 70 } |
| 71 |
| 72 - (IBAction)handleMenuClose:(NSMenuItem*)sender { |
| 73 [NSApp terminate:self]; |
| 74 } |
| 75 |
| 76 @end |
| 77 |
| 78 int main(int argc, char* argv[]) |
| 79 { |
| 80 // The no-ui option skips the UI confirmatino dialogs. This is provided as |
| 81 // a convenience for our automated testing. |
| 82 // There will still be an elevation prompt unless the command is run as root. |
| 83 if (argc == 2 && !strcmp(argv[1], "--no-ui")) { |
| 84 @autoreleasepool { |
| 85 NSLog(@"Chrome Remote Desktop uninstall starting."); |
| 86 NSLog(@"--no-ui : Suppressing UI"); |
| 87 |
| 88 RemotingUninstaller* uninstaller = |
| 89 [[[RemotingUninstaller alloc] init] autorelease]; |
| 90 OSStatus status = [uninstaller remotingUninstall]; |
| 91 |
| 92 NSLog(@"Chrome Remote Desktop Host uninstall complete."); |
| 93 NSLog(@"Status = %ld", status); |
| 94 return status != errAuthorizationSuccess; |
| 95 } |
| 96 } else { |
| 97 return NSApplicationMain(argc, (const char**)argv); |
| 98 } |
| 99 } |
| 100 |
OLD | NEW |