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

Side by Side Diff: cloud_print/virtual_driver/posix/installer_util_mac.mm

Issue 7485011: Virtual Cloud Print Driver for Mac. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update GYP file to show warnings. Created 9 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "cloud_print/virtual_driver/posix/installer_util_mac.h"
6
7 #import <ApplicationServices/ApplicationServices.h>
8 #import <Foundation/NSAutoreleasePool.h>
9 #import <Foundation/NSAppleEventDescriptor.h>
10 #import <CoreServices/CoreServices.h>
11
12 #include "base/mac/foundation_util.h"
13
14 #include <stdlib.h>
15 #include <string>
16 #include <iostream>
17
18 namespace cloud_print {
19 // Sends an event of a class Type sendClass to the Chromium
20 // service process. Used to install and uninstall the Cloud
21 // Print driver on Mac.
22 void sendServiceProcessEvent(const AEEventClass sendClass) {
23 FSRef ref;
24 OSStatus status = noErr;
25 CFURLRef* kDontWantURL = NULL;
26
27 std::string bundleID = base::mac::BaseBundleID();
28 CFStringRef bundleIDCF = CFStringCreateWithCString(NULL, bundleID.c_str(),
29 kCFStringEncodingUTF8);
30
31 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, NULL,
32 &ref, kDontWantURL);
33
34 if (status != noErr) {
35 std::cerr << "Failed to make path ref";
Scott Byer 2011/08/02 23:52:52 Add a comment explaining the iostream use.
abeera 2011/08/03 20:34:47 Done.
36 std::cerr << GetMacOSStatusErrorString(status);
37 std::cerr << GetMacOSStatusCommentString(status);
38 exit(-1);
39 }
40
41 NSAppleEventDescriptor* sendEvent =
Scott Byer 2011/08/02 23:52:52 Be consistent with error checking - check for nil.
abeera 2011/08/03 20:34:47 Done.
42 [NSAppleEventDescriptor appleEventWithEventClass:sendClass
43 eventID:sendClass
44 targetDescriptor:nil
45 returnID:kAutoGenerateReturnID
46 transactionID:kAnyTransactionID];
47 LSApplicationParameters params = { 0, kLSLaunchDefaults , &ref, NULL, NULL,
Scott Byer 2011/08/02 23:52:52 nit: no space before comma
abeera 2011/08/03 20:34:47 Done.
48 NULL, NULL };
49 params.initialEvent = (AppleEvent*) [sendEvent aeDesc];
Scott Byer 2011/08/02 23:52:52 prefer static_cast<>()
abeera 2011/08/03 20:34:47 Done.
50 status = LSOpenApplication(&params, NULL);
51
52 if (status != noErr) {
53 std::cerr << "Unable to launch Chrome to install";
54 std::cerr << GetMacOSStatusErrorString(status);
55 std::cerr << GetMacOSStatusCommentString(status);
56 exit(-1);
57 }
58 }
59
60 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698