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

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

Issue 9235084: Add OSSTATUS_LOG API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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"
8 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/mac_logging.h"
9 #import "chrome/common/cloud_print/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 ServiceApplication () 12 @interface ServiceApplication ()
13 - (void)setCloudPrintHandler; 13 - (void)setCloudPrintHandler;
14 - (void)submitPrint:(NSAppleEventDescriptor*)event; 14 - (void)submitPrint:(NSAppleEventDescriptor*)event;
15 @end 15 @end
16 16
17 @implementation ServiceApplication 17 @implementation ServiceApplication
18 18
(...skipping 10 matching lines...) Expand all
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 };
35 // Argv array that will be passed. 35 // Argv array that will be passed.
36 CFArrayRef passArgv = 36 CFArrayRef passArgv =
37 CFArrayCreate(NULL, (const void**) flags, 1, &kCFTypeArrayCallBacks); 37 CFArrayCreate(NULL, (const void**) flags, 1, &kCFTypeArrayCallBacks);
38 FSRef ref; 38 FSRef ref;
39 OSStatus status = noErr;
40 CFURLRef* kDontWantURL = NULL; 39 CFURLRef* kDontWantURL = NULL;
41 // Get Chrome's bundle ID. 40 // Get Chrome's bundle ID.
42 std::string bundleID = base::mac::BaseBundleID(); 41 std::string bundleID = base::mac::BaseBundleID();
43 CFStringRef bundleIDCF = 42 CFStringRef bundleIDCF =
44 CFStringCreateWithCString(NULL, bundleID.c_str(), kCFStringEncodingUTF8); 43 CFStringCreateWithCString(NULL, bundleID.c_str(), kCFStringEncodingUTF8);
45 // Use Launch Services to locate Chrome using its bundleID. 44 // Use Launch Services to locate Chrome using its bundleID.
46 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, 45 OSStatus status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF,
47 NULL, &ref, kDontWantURL); 46 NULL, &ref, kDontWantURL);
48 47
49 if (status != noErr) { 48 if (status != noErr) {
50 LOG(ERROR) << "Failed to make path ref"; 49 OSSTATUS_LOG(ERROR, status) << "Failed to make path ref";
51 LOG(ERROR) << GetMacOSStatusErrorString(status);
52 LOG(ERROR) << GetMacOSStatusCommentString(status);
Tristan Schmelcher 2 2012/01/27 19:56:23 Looks like this won't be logged in the new code. I
Mark Mentovai 2012/01/27 19:58:41 Tristan Schmelcher 2 wrote:
53 return; 50 return;
54 } 51 }
55 // Actually create the Apple Event. 52 // Actually create the Apple Event.
56 NSAppleEventDescriptor* sendEvent = 53 NSAppleEventDescriptor* sendEvent =
57 [NSAppleEventDescriptor 54 [NSAppleEventDescriptor
58 appleEventWithEventClass:cloud_print::kAECloudPrintClass 55 appleEventWithEventClass:cloud_print::kAECloudPrintClass
59 eventID:cloud_print::kAECloudPrintClass 56 eventID:cloud_print::kAECloudPrintClass
60 targetDescriptor:nil 57 targetDescriptor:nil
61 returnID:kAutoGenerateReturnID 58 returnID:kAutoGenerateReturnID
62 transactionID:kAnyTransactionID]; 59 transactionID:kAnyTransactionID];
63 // Pull the parameters out of AppleEvent sent to us and attach them 60 // Pull the parameters out of AppleEvent sent to us and attach them
64 // to our Apple Event. 61 // to our Apple Event.
65 NSAppleEventDescriptor* parameters = 62 NSAppleEventDescriptor* parameters =
66 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass]; 63 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass];
67 [sendEvent setParamDescriptor:parameters 64 [sendEvent setParamDescriptor:parameters
68 forKeyword:cloud_print::kAECloudPrintClass]; 65 forKeyword:cloud_print::kAECloudPrintClass];
69 LSApplicationParameters params = { 0, 66 LSApplicationParameters params = { 0,
70 kLSLaunchDefaults, 67 kLSLaunchDefaults,
71 &ref, 68 &ref,
72 NULL, 69 NULL,
73 NULL, 70 NULL,
74 passArgv, 71 passArgv,
75 NULL }; 72 NULL };
76 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]); 73 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]);
77 params.initialEvent = static_cast<AppleEvent*> (initialEvent); 74 params.initialEvent = static_cast<AppleEvent*> (initialEvent);
78 // Send the Apple Event Using launch services, launching Chrome if necessary. 75 // Send the Apple Event Using launch services, launching Chrome if necessary.
79 status = LSOpenApplication(&params, NULL); 76 status = LSOpenApplication(&params, NULL);
80 if (status != noErr) { 77 if (status != noErr) {
81 LOG(ERROR) << "Unable to launch"; 78 OSSTATUS_LOG(ERROR, status) << "Unable to launch";
82 LOG(ERROR) << GetMacOSStatusErrorString(status);
83 LOG(ERROR) << GetMacOSStatusCommentString(status);
84 } 79 }
85 } 80 }
86 81
87 82
88 @end 83 @end
89 84
90 85
91 namespace chrome_service_application_mac { 86 namespace chrome_service_application_mac {
92 87
93 void RegisterServiceApp() { 88 void RegisterServiceApp() {
94 ServiceApplication* var = 89 ServiceApplication* var =
95 base::mac::ObjCCastStrict<ServiceApplication>( 90 base::mac::ObjCCastStrict<ServiceApplication>(
96 [ServiceApplication sharedApplication]); 91 [ServiceApplication sharedApplication]);
97 [var setCloudPrintHandler]; 92 [var setCloudPrintHandler];
98 } 93 }
99 94
100 } // namespace chrome_service_application_mac 95 } // namespace chrome_service_application_mac
101
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698