Index: chrome/service/chrome_service_application_mac.mm |
diff --git a/chrome/service/chrome_service_application_mac.mm b/chrome/service/chrome_service_application_mac.mm |
index 0b9bc7c85f10b31f473a52bb23f5db0145a41bc9..1f44b94fc88e5df56ce9c01d4134bcedbcbdc206 100644 |
--- a/chrome/service/chrome_service_application_mac.mm |
+++ b/chrome/service/chrome_service_application_mac.mm |
@@ -6,6 +6,7 @@ |
#include "base/mac/foundation_util.h" |
#include "base/mac/mac_logging.h" |
+#include "base/sys_string_conversions.h" |
#import "chrome/common/cloud_print/cloud_print_class_mac.h" |
#include "chrome/common/chrome_switches.h" |
@@ -29,18 +30,18 @@ |
- (void)submitPrint:(NSAppleEventDescriptor*)event { |
std::string silent = std::string("--") + switches::kNoStartupWindow; |
// Set up flag so that it can be passed along with the Apple Event. |
- CFStringRef silentLaunchFlag = |
- CFStringCreateWithCString(NULL, silent.c_str(), kCFStringEncodingUTF8); |
Avi (use Gerrit)
2013/02/05 05:15:49
Yikes. This leaked...
|
+ base::mac::ScopedCFTypeRef<CFStringRef> silentLaunchFlag( |
+ base::SysUTF8ToCFStringRef(silent)); |
CFStringRef flags[] = { silentLaunchFlag }; |
// Argv array that will be passed. |
- CFArrayRef passArgv = |
- CFArrayCreate(NULL, (const void**) flags, 1, &kCFTypeArrayCallBacks); |
Avi (use Gerrit)
2013/02/05 05:15:49
Did this leak? What does LSApplicationParameters r
jeremya
2013/02/05 05:42:15
I think so. I can't find any documentation saying
|
+ base::mac::ScopedCFTypeRef<CFArrayRef> passArgv( |
+ CFArrayCreate(NULL, (const void**) flags, 1, &kCFTypeArrayCallBacks)); |
FSRef ref; |
CFURLRef* kDontWantURL = NULL; |
// Get Chrome's bundle ID. |
- std::string bundleID = base::mac::BaseBundleID(); |
- CFStringRef bundleIDCF = |
- CFStringCreateWithCString(NULL, bundleID.c_str(), kCFStringEncodingUTF8); |
Avi (use Gerrit)
2013/02/05 05:15:49
.. and this clearly leaked.
|
+ std::string bundleID = base::mac::BaseBundleID(); |
+ base::mac::ScopedCFTypeRef<CFStringRef> bundleIDCF( |
+ base::SysUTF8ToCFStringRef(bundleID)); |
// Use Launch Services to locate Chrome using its bundleID. |
OSStatus status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, |
NULL, &ref, kDontWantURL); |
Avi (use Gerrit)
2013/02/05 05:15:49
Put a null in this last parameter rather than this
jeremya
2013/02/05 05:42:15
Done.
|
@@ -70,8 +71,8 @@ |
NULL, |
passArgv, |
NULL }; |
- AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]); |
- params.initialEvent = static_cast<AppleEvent*> (initialEvent); |
+ AEDesc* initialEvent = const_cast<AEDesc*>([sendEvent aeDesc]); |
+ params.initialEvent = static_cast<AppleEvent*>(initialEvent); |
// Send the Apple Event Using launch services, launching Chrome if necessary. |
status = LSOpenApplication(¶ms, NULL); |
if (status != noErr) { |