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

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

Issue 7485011: Virtual Cloud Print Driver for Mac. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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
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/printer_driver_util_posix.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/logging.h"
13 #include "base/mac/foundation_util.h"
14
15 #include <cups/backend.h>
16
17 #include <stdlib.h>
18 #include <string>
19
20 //Duplicated is content/common/cloud_print_class_mac.h
21 const AEEventClass cloud_print_class = 'GCPp';
22
23 void LaunchPrintDialog(std::string output_path,
24 std::string job_title,
25 std::string user) {
26 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
27 OSStatus status = noErr;
28 FSRef ref;
29
30 std::string bundleID= base::mac::BaseBundleID();
31 bundleID = bundleID + ".helper";
32 CFStringRef bundleIDCF = CFStringCreateWithCString(
33 NULL,
34 bundleID.c_str(),
35 kCFStringEncodingUTF8);
36 CFURLRef* kDontWantURL = NULL;
37 //Locate the service process with the help of the bundle ID.
38 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF,
39 NULL, &ref, kDontWantURL);
40
41 if (status != noErr) {
42 LOG(ERROR) <<"Couldn't find the service process";
43 exit(CUPS_BACKEND_CANCEL);
44 }
45 // Create the AppleEvent parameters.
46 NSAppleEventDescriptor *print_path = [NSAppleEventDescriptor
47 descriptorWithString:[NSString stringWithUTF8String:output_path.c_str()]];
48 NSAppleEventDescriptor *title = [NSAppleEventDescriptor
49 descriptorWithString:[NSString stringWithUTF8String:job_title.c_str()]];
50 NSAppleEventDescriptor *mime = [NSAppleEventDescriptor
51 descriptorWithString:@"application/pdf"];
52
53 // Create and populate the list of parameters.
54 // Note that the array starts at index 1.
55 NSAppleEventDescriptor *parameters = [NSAppleEventDescriptor listDescriptor];
56 [parameters insertDescriptor:mime atIndex:1];
57 [parameters insertDescriptor:print_path atIndex:2];
58 [parameters insertDescriptor:title atIndex:3];
59 NSAppleEventDescriptor *event = [NSAppleEventDescriptor
60 appleEventWithEventClass:
61 cloud_print_class
62 eventID:cloud_print_class
63 targetDescriptor:nil
64 returnID:kAutoGenerateReturnID
65 transactionID:kAnyTransactionID];
66
67 if(event == nil) {
68 LOG(ERROR) << "Unable to Create Event";
69 exit(CUPS_BACKEND_CANCEL);
70 }
71 // Set the application launch parameters.
72 // We are just using launch services to deliver our Apple Event.
73 LSApplicationParameters params = {0, kLSLaunchDefaults , &ref, NULL, NULL,
74 NULL, NULL};
75 // Create the actual Apple Event.
76 [event setParamDescriptor:parameters forKeyword:cloud_print_class];
77 params.initialEvent =(AppleEvent *) [event aeDesc];
78 // Deliver the Apple Event using launch services.
79 status = LSOpenApplication(&params, NULL);
80 if (status != noErr) {
81 LOG(ERROR) <<"Unable to launch";
82 LOG(ERROR) << GetMacOSStatusErrorString(status);
83 LOG(ERROR) << GetMacOSStatusCommentString(status);
84 exit(CUPS_BACKEND_CANCEL);
85 }
86
87 [pool release];
88 return;
89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698