| Index: cloud_print/virtual_driver/posix/installer_util_mac.mm
|
| diff --git a/cloud_print/virtual_driver/posix/installer_util_mac.mm b/cloud_print/virtual_driver/posix/installer_util_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2ae5922c2c0bd0f8592922edaf077eb46eb5b669
|
| --- /dev/null
|
| +++ b/cloud_print/virtual_driver/posix/installer_util_mac.mm
|
| @@ -0,0 +1,54 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "cloud_print/virtual_driver/posix/installer_util_mac.h"
|
| +
|
| +#import <ApplicationServices/ApplicationServices.h>
|
| +#import <Foundation/NSAutoreleasePool.h>
|
| +#import <Foundation/NSAppleEventDescriptor.h>
|
| +#import <CoreServices/CoreServices.h>
|
| +
|
| +#include "base/mac/foundation_util.h"
|
| +
|
| +#include <stdlib.h>
|
| +#include <string>
|
| +#include <iostream>
|
| +
|
| +void sendEvent(const AEEventClass send_class) {
|
| + FSRef ref;
|
| + OSStatus status = noErr;
|
| + CFURLRef* kDontWantURL = NULL;
|
| +
|
| + std::string bundleID= base::mac::BaseBundleID();
|
| + CFStringRef bundleIDCF = CFStringCreateWithCString(NULL,bundleID.c_str(),
|
| + kCFStringEncodingUTF8);
|
| +
|
| + status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, NULL,
|
| + &ref, kDontWantURL);
|
| +
|
| + if (status != noErr) {
|
| + std::cerr <<"Failed to make path ref";
|
| + std::cerr << GetMacOSStatusErrorString(status);
|
| + std::cerr << GetMacOSStatusCommentString(status);
|
| + exit(-1);
|
| + }
|
| +
|
| + NSAppleEventDescriptor *send_event = [NSAppleEventDescriptor
|
| + appleEventWithEventClass:send_class
|
| + eventID:send_class
|
| + targetDescriptor:nil
|
| + returnID:kAutoGenerateReturnID
|
| + transactionID:kAnyTransactionID];
|
| + LSApplicationParameters params = {0, kLSLaunchDefaults , &ref, NULL, NULL,
|
| + NULL, NULL};
|
| + params.initialEvent =(AppleEvent *) [send_event aeDesc];
|
| + status = LSOpenApplication(¶ms, NULL);
|
| +
|
| + if (status != noErr) {
|
| + std::cerr <<"Unable to launch Chrome to install";
|
| + std::cerr << GetMacOSStatusErrorString(status);
|
| + std::cerr << GetMacOSStatusCommentString(status);
|
| + exit(-1);
|
| + }
|
| +}
|
|
|