| OLD | NEW |
| 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 #include "cloud_print/virtual_driver/posix/installer_util_mac.h" | 5 #include "cloud_print/virtual_driver/posix/installer_util_mac.h" |
| 6 | 6 |
| 7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
| 8 #import <Foundation/NSAutoreleasePool.h> | 8 #import <Foundation/NSAutoreleasePool.h> |
| 9 #import <Foundation/NSAppleEventDescriptor.h> | 9 #import <Foundation/NSAppleEventDescriptor.h> |
| 10 #import <CoreServices/CoreServices.h> | 10 #import <CoreServices/CoreServices.h> |
| 11 | 11 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 25 CFURLRef* kDontWantURL = NULL; | 25 CFURLRef* kDontWantURL = NULL; |
| 26 | 26 |
| 27 std::string bundleID = base::mac::BaseBundleID(); | 27 std::string bundleID = base::mac::BaseBundleID(); |
| 28 CFStringRef bundleIDCF = CFStringCreateWithCString(NULL, bundleID.c_str(), | 28 CFStringRef bundleIDCF = CFStringCreateWithCString(NULL, bundleID.c_str(), |
| 29 kCFStringEncodingUTF8); | 29 kCFStringEncodingUTF8); |
| 30 | 30 |
| 31 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, NULL, | 31 status = LSFindApplicationForInfo(kLSUnknownCreator, bundleIDCF, NULL, |
| 32 &ref, kDontWantURL); | 32 &ref, kDontWantURL); |
| 33 | 33 |
| 34 if (status != noErr) { | 34 if (status != noErr) { |
| 35 std::cerr << "Failed to make path ref"; | 35 std::cerr << "Failed to make path ref: " |
| 36 std::cerr << GetMacOSStatusErrorString(status); | 36 << GetMacOSStatusErrorString(status) |
| 37 std::cerr << GetMacOSStatusCommentString(status); | 37 << " (" |
| 38 << status |
| 39 << ")"; |
| 38 exit(-1); | 40 exit(-1); |
| 39 } | 41 } |
| 40 | 42 |
| 41 NSAppleEventDescriptor* sendEvent = | 43 NSAppleEventDescriptor* sendEvent = |
| 42 [NSAppleEventDescriptor appleEventWithEventClass:sendClass | 44 [NSAppleEventDescriptor appleEventWithEventClass:sendClass |
| 43 eventID:sendClass | 45 eventID:sendClass |
| 44 targetDescriptor:nil | 46 targetDescriptor:nil |
| 45 returnID:kAutoGenerateReturnID | 47 returnID:kAutoGenerateReturnID |
| 46 transactionID:kAnyTransactionID]; | 48 transactionID:kAnyTransactionID]; |
| 47 if (sendEvent == nil) { | 49 if (sendEvent == nil) { |
| 48 // Write to system error log using cerr. | 50 // Write to system error log using cerr. |
| 49 std::cerr << "Unable to create Apple Event"; | 51 std::cerr << "Unable to create Apple Event"; |
| 50 } | 52 } |
| 51 LSApplicationParameters params = { 0, kLSLaunchDefaults, &ref, NULL, NULL, | 53 LSApplicationParameters params = { 0, kLSLaunchDefaults, &ref, NULL, NULL, |
| 52 NULL, NULL }; | 54 NULL, NULL }; |
| 53 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]); | 55 AEDesc* initialEvent = const_cast<AEDesc*> ([sendEvent aeDesc]); |
| 54 params.initialEvent = static_cast<AppleEvent*> (initialEvent); | 56 params.initialEvent = static_cast<AppleEvent*> (initialEvent); |
| 55 status = LSOpenApplication(¶ms, NULL); | 57 status = LSOpenApplication(¶ms, NULL); |
| 56 | 58 |
| 57 if (status != noErr) { | 59 if (status != noErr) { |
| 58 std::cerr << "Unable to launch Chrome to install"; | 60 std::cerr << "Unable to launch Chrome to install: " |
| 59 std::cerr << GetMacOSStatusErrorString(status); | 61 << GetMacOSStatusErrorString(status) |
| 60 std::cerr << GetMacOSStatusCommentString(status); | 62 << " (" |
| 63 << status |
| 64 << ")"; |
| 61 exit(-1); | 65 exit(-1); |
| 62 } | 66 } |
| 63 } | 67 } |
| 64 | 68 |
| 65 } // namespace cloud_print | 69 } // namespace cloud_print |
| OLD | NEW |