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

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: Fixed copyright 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";
36 std::cerr << GetMacOSStatusErrorString(status);
37 std::cerr << GetMacOSStatusCommentString(status);
38 exit(-1);
39 }
40
41 NSAppleEventDescriptor* sendEvent =
42 [NSAppleEventDescriptor appleEventWithEventClass:sendClass
43 eventID:sendClass
44 targetDescriptor:nil
45 returnID:kAutoGenerateReturnID
46 transactionID:kAnyTransactionID];
47 if (sendEvent == nil) {
48 // Write to system error log using cerr.
49 std::cerr << "Unable to create Apple Event";
50 }
51 LSApplicationParameters params = { 0, kLSLaunchDefaults, &ref, NULL, NULL,
52 NULL, NULL };
53 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]);
54 params.initialEvent = static_cast<AppleEvent*> (initialEvent);
55 status = LSOpenApplication(&params, NULL);
56
57 if (status != noErr) {
58 std::cerr << "Unable to launch Chrome to install";
59 std::cerr << GetMacOSStatusErrorString(status);
60 std::cerr << GetMacOSStatusCommentString(status);
61 exit(-1);
62 }
63 }
64
65 } // namespace cloud_print
OLDNEW
« no previous file with comments | « cloud_print/virtual_driver/posix/installer_util_mac.h ('k') | cloud_print/virtual_driver/posix/printer_driver_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698