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

Side by Side Diff: chrome/service/chrome_service_application_mac.mm

Issue 8341079: Move cloud_print_class_mac files from content/common to chrome/common/cloud_print. They don't bel... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/service/chrome_service_application_mac.h" 5 #import "chrome/service/chrome_service_application_mac.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #import "content/common/cloud_print_class_mac.h" 9 #import "chrome/common/cloud_print/cloud_print_class_mac.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 11
12 @interface ServiceCrApplication () 12 @interface ServiceCrApplication ()
13 - (void)setCloudPrintHandler; 13 - (void)setCloudPrintHandler;
14 - (void)submitPrint:(NSAppleEventDescriptor*)event; 14 - (void)submitPrint:(NSAppleEventDescriptor*)event;
15 @end 15 @end
16 16
17 @implementation ServiceCrApplication 17 @implementation ServiceCrApplication
18 18
19 -(void)setCloudPrintHandler { 19 -(void)setCloudPrintHandler {
20 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; 20 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
21 [em setEventHandler:self 21 [em setEventHandler:self
22 andSelector:@selector(submitPrint:) 22 andSelector:@selector(submitPrint:)
23 forEventClass:content::kAECloudPrintClass 23 forEventClass:cloud_print::kAECloudPrintClass
24 andEventID:content::kAECloudPrintClass]; 24 andEventID:cloud_print::kAECloudPrintClass];
25 } 25 }
26 26
27 // Event handler for Cloud Print Event. Forwards print job received to Chrome, 27 // Event handler for Cloud Print Event. Forwards print job received to Chrome,
28 // launching Chrome if necessary. Used to beat CUPS sandboxing. 28 // launching Chrome if necessary. Used to beat CUPS sandboxing.
29 - (void)submitPrint:(NSAppleEventDescriptor*)event { 29 - (void)submitPrint:(NSAppleEventDescriptor*)event {
30 std::string silent = std::string("--") + switches::kNoStartupWindow; 30 std::string silent = std::string("--") + switches::kNoStartupWindow;
31 // Set up flag so that it can be passed along with the Apple Event. 31 // Set up flag so that it can be passed along with the Apple Event.
32 CFStringRef silentLaunchFlag = 32 CFStringRef silentLaunchFlag =
33 CFStringCreateWithCString(NULL, silent.c_str(), kCFStringEncodingUTF8); 33 CFStringCreateWithCString(NULL, silent.c_str(), kCFStringEncodingUTF8);
34 CFStringRef flags[] = { silentLaunchFlag }; 34 CFStringRef flags[] = { silentLaunchFlag };
(...skipping 13 matching lines...) Expand all
48 48
49 if (status != noErr) { 49 if (status != noErr) {
50 LOG(ERROR) << "Failed to make path ref"; 50 LOG(ERROR) << "Failed to make path ref";
51 LOG(ERROR) << GetMacOSStatusErrorString(status); 51 LOG(ERROR) << GetMacOSStatusErrorString(status);
52 LOG(ERROR) << GetMacOSStatusCommentString(status); 52 LOG(ERROR) << GetMacOSStatusCommentString(status);
53 return; 53 return;
54 } 54 }
55 // Actually create the Apple Event. 55 // Actually create the Apple Event.
56 NSAppleEventDescriptor* sendEvent = 56 NSAppleEventDescriptor* sendEvent =
57 [NSAppleEventDescriptor 57 [NSAppleEventDescriptor
58 appleEventWithEventClass:content::kAECloudPrintClass 58 appleEventWithEventClass:cloud_print::kAECloudPrintClass
59 eventID:content::kAECloudPrintClass 59 eventID:cloud_print::kAECloudPrintClass
60 targetDescriptor:nil 60 targetDescriptor:nil
61 returnID:kAutoGenerateReturnID 61 returnID:kAutoGenerateReturnID
62 transactionID:kAnyTransactionID]; 62 transactionID:kAnyTransactionID];
63 // Pull the parameters out of AppleEvent sent to us and attach them 63 // Pull the parameters out of AppleEvent sent to us and attach them
64 // to our Apple Event. 64 // to our Apple Event.
65 NSAppleEventDescriptor* parameters = 65 NSAppleEventDescriptor* parameters =
66 [event paramDescriptorForKeyword:content::kAECloudPrintClass]; 66 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass];
67 [sendEvent setParamDescriptor:parameters 67 [sendEvent setParamDescriptor:parameters
68 forKeyword:content::kAECloudPrintClass]; 68 forKeyword:cloud_print::kAECloudPrintClass];
69 LSApplicationParameters params = { 0, 69 LSApplicationParameters params = { 0,
70 kLSLaunchDefaults, 70 kLSLaunchDefaults,
71 &ref, 71 &ref,
72 NULL, 72 NULL,
73 NULL, 73 NULL,
74 passArgv, 74 passArgv,
75 NULL }; 75 NULL };
76 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]); 76 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]);
77 params.initialEvent = static_cast<AppleEvent*> (initialEvent); 77 params.initialEvent = static_cast<AppleEvent*> (initialEvent);
78 // Send the Apple Event Using launch services, launching Chrome if necessary. 78 // Send the Apple Event Using launch services, launching Chrome if necessary.
(...skipping 13 matching lines...) Expand all
92 92
93 void RegisterServiceCrApp() { 93 void RegisterServiceCrApp() {
94 ServiceCrApplication* var = 94 ServiceCrApplication* var =
95 static_cast<ServiceCrApplication*> 95 static_cast<ServiceCrApplication*>
96 ([ServiceCrApplication sharedApplication]); 96 ([ServiceCrApplication sharedApplication]);
97 [var setCloudPrintHandler]; 97 [var setCloudPrintHandler];
98 } 98 }
99 99
100 } // namespace chrome_service_application_mac 100 } // namespace chrome_service_application_mac
101 101
OLDNEW
« no previous file with comments | « chrome/common/cloud_print/cloud_print_class_mac.mm ('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