OLD | NEW |
(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 void sendEvent(const AEEventClass sendClass) { |
| 19 FSRef ref; |
| 20 OSStatus status = noErr; |
| 21 CFURLRef* kDontWantURL = NULL; |
| 22 |
| 23 std::string bundleID = base::mac::BaseBundleID(); |
| 24 CFStringRef bundleIDCF = CFStringCreateWithCString(NULL, bundleID.c_str(), |
| 25 kCFStringEncodingUTF8); |
| 26 |
| 27 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, NULL, |
| 28 &ref, kDontWantURL); |
| 29 |
| 30 if (status != noErr) { |
| 31 std::cerr << "Failed to make path ref"; |
| 32 std::cerr << GetMacOSStatusErrorString(status); |
| 33 std::cerr << GetMacOSStatusCommentString(status); |
| 34 exit(-1); |
| 35 } |
| 36 |
| 37 NSAppleEventDescriptor* sendEvent = |
| 38 [NSAppleEventDescriptor |
| 39 appleEventWithEventClass:sendClass |
| 40 eventID:sendClass |
| 41 targetDescriptor:nil |
| 42 returnID:kAutoGenerateReturnID |
| 43 transactionID:kAnyTransactionID]; |
| 44 LSApplicationParameters params = { 0, kLSLaunchDefaults , &ref, NULL, NULL, |
| 45 NULL, NULL }; |
| 46 params.initialEvent = (AppleEvent *) [sendEvent aeDesc]; |
| 47 status = LSOpenApplication(¶ms, NULL); |
| 48 |
| 49 if (status != noErr) { |
| 50 std::cerr << "Unable to launch Chrome to install"; |
| 51 std::cerr << GetMacOSStatusErrorString(status); |
| 52 std::cerr << GetMacOSStatusCommentString(status); |
| 53 exit(-1); |
| 54 } |
| 55 } |
OLD | NEW |