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

Side by Side Diff: remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.mm

Issue 10807061: [Chromoting] Update uninstaller to facilitate testing automation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(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_authorizationref.h"
10 #include "base/mac/scoped_cftyperef.h"
11 #include "remoting/host/installer/mac/uninstaller/remoting_uninstaller.h"
12
13 @implementation RemotingUninstallerAppDelegate
14
15 - (void)dealloc {
16 [super dealloc];
17 }
18
19 - (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
20 }
21
22 - (void)messageBox:(const char*)message {
23 base::mac::ScopedCFTypeRef<CFStringRef> message_ref(
24 CFStringCreateWithCString(kCFAllocatorDefault, message,
25 kCFStringEncodingUTF8));
26 CFOptionFlags result;
27 CFUserNotificationDisplayAlert(0, kCFUserNotificationNoteAlertLevel,
28 NULL, NULL, NULL,
29 CFSTR("Chrome Remote Desktop Uninstaller"),
30 message_ref, NULL, NULL, NULL, &result);
31 }
32
33 - (IBAction)uninstall:(NSButton*)sender {
34 base::mac::ScopedAuthorizationRef authRef;
35
36 NSLog(@"Chrome Remote Desktop uninstall starting.");
37
38 @try {
39 OSStatus status;
40 status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
41 kAuthorizationFlagDefaults, &authRef);
42 if (status != errAuthorizationSuccess) {
43 [NSException raise:@"AuthorizationCreate Failure"
44 format:@"Error during AuthorizationCreate status=%ld", status];
45 }
46
47 AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0};
48 AuthorizationRights rights = {1, &right};
49 AuthorizationFlags flags = kAuthorizationFlagDefaults |
50 kAuthorizationFlagInteractionAllowed |
51 kAuthorizationFlagPreAuthorize |
52 kAuthorizationFlagExtendRights;
53 status = AuthorizationCopyRights(authRef, &rights, NULL, flags, NULL);
54 if (status == errAuthorizationCanceled) {
55 NSLog(@"Chrome Remote Desktop Host uninstall canceled.");
56 const char* message = "Chrome Remote Desktop Host uninstall canceled.";
57 [self messageBox:message];
58 } else if (status == errAuthorizationSuccess) {
59 RemotingUninstaller* uninstaller =
60 [[[RemotingUninstaller alloc] init] autorelease];
61 [uninstaller remotingUninstallUsingAuth:authRef];
62
63 NSLog(@"Chrome Remote Desktop Host uninstall complete.");
64 const char* message =
65 "Chrome Remote Desktop Host was successfully uninstalled.";
66 [self messageBox:message];
67 } else {
68 [NSException raise:@"AuthorizationCopyRights Failure"
69 format:@"Error during AuthorizationCopyRights status=%ld", status];
70 }
71 }
72 @catch (NSException* exception) {
73 NSLog(@"Exception %@ %@", [exception name], [exception reason]);
74 const char* message =
75 "Error! Unable to uninstall Chrome Remote Desktop Host.";
76 [self messageBox:message];
77 }
78
79 [NSApp terminate:self];
80 }
81
82 - (IBAction)cancel:(id)sender {
83 [NSApp terminate:self];
84 }
85
86 - (IBAction)handleMenuClose:(NSMenuItem*)sender {
87 [NSApp terminate:self];
88 }
89
90 @end
91
92 int main(int argc, char* argv[])
93 {
94 // If we're launched as root, then skip the elevation and UI confirmations.
95 // This is provided as a convenience for our automated testing.
96 int euid = geteuid();
Lambros 2012/07/23 22:06:47 nit: s/int/uid_t, but I think it's OK to get rid o
garykac 2012/07/23 22:41:09 No longer applicable
97 if (euid == 0) {
98 @autoreleasepool {
99 NSLog(@"Running as euid=0. Suppressing UI and elevation prompts.");
100
101 RemotingUninstaller* uninstaller =
102 [[[RemotingUninstaller alloc] init] autorelease];
103 [uninstaller remotingUninstallUsingAuth:nil];
104
105 NSLog(@"Chrome Remote Desktop Host uninstall complete.");
106 return 0;
107 }
108 } else {
109 return NSApplicationMain(argc, (const char**)argv);
110 }
111 }
112
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698