| OLD | NEW |
| 1 // Copyright (c) 2012 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/common/mac/app_mode_chrome_locator.h" | 5 #import "chrome/common/mac/app_mode_chrome_locator.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/mac/app_mode_common.h" |
| 15 | 16 |
| 16 namespace app_mode { | 17 namespace app_mode { |
| 17 | 18 |
| 18 bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) { | 19 bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) { |
| 19 NSWorkspace* ws = [NSWorkspace sharedWorkspace]; | 20 NSWorkspace* ws = [NSWorkspace sharedWorkspace]; |
| 20 NSString *bundlePath = [ws absolutePathForAppBundleWithIdentifier:bundle_id]; | 21 NSString *bundlePath = [ws absolutePathForAppBundleWithIdentifier:bundle_id]; |
| 21 if (!bundlePath) | 22 if (!bundlePath) |
| 22 return false; | 23 return false; |
| 23 | 24 |
| 24 *out_bundle = base::mac::NSStringToFilePath(bundlePath); | 25 *out_bundle = base::mac::NSStringToFilePath(bundlePath); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 47 NSString* cr_versioned_path; | 48 NSString* cr_versioned_path; |
| 48 if (!version_str.empty()) { | 49 if (!version_str.empty()) { |
| 49 cr_versioned_path = | 50 cr_versioned_path = |
| 50 GetVersionedPath(cr_bundle_path, base::SysUTF8ToNSString(version_str)); | 51 GetVersionedPath(cr_bundle_path, base::SysUTF8ToNSString(version_str)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 if (version_str.empty() || | 54 if (version_str.empty() || |
| 54 !base::PathExists(base::mac::NSStringToFilePath(cr_versioned_path))) { | 55 !base::PathExists(base::mac::NSStringToFilePath(cr_versioned_path))) { |
| 55 // Read version string. | 56 // Read version string. |
| 56 NSString* cr_version = ObjCCast<NSString>( | 57 NSString* cr_version = ObjCCast<NSString>( |
| 57 [cr_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]); | 58 [cr_bundle objectForInfoDictionaryKey:app_mode::kCrBundleVersionKey]); |
| 59 if (!cr_version) { |
| 60 // Older bundles have the Chrome version in the following key. |
| 61 cr_version = ObjCCast<NSString>([cr_bundle |
| 62 objectForInfoDictionaryKey:app_mode::kCFBundleShortVersionStringKey]); |
| 63 } |
| 58 if (!cr_version) | 64 if (!cr_version) |
| 59 return false; | 65 return false; |
| 60 | 66 |
| 61 cr_versioned_path = GetVersionedPath(cr_bundle_path, cr_version); | 67 cr_versioned_path = GetVersionedPath(cr_bundle_path, cr_version); |
| 62 } | 68 } |
| 63 | 69 |
| 64 // Get the framework path. | 70 // Get the framework path. |
| 65 NSString* cr_bundle_exe = | 71 NSString* cr_bundle_exe = |
| 66 ObjCCast<NSString>( | 72 ObjCCast<NSString>( |
| 67 [cr_bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]); | 73 [cr_bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 97 | 103 |
| 98 // Everything OK, copy output parameters. | 104 // Everything OK, copy output parameters. |
| 99 *executable_path = base::mac::NSStringToFilePath([cr_bundle executablePath]); | 105 *executable_path = base::mac::NSStringToFilePath([cr_bundle executablePath]); |
| 100 *version_path = base::mac::NSStringToFilePath(cr_versioned_path); | 106 *version_path = base::mac::NSStringToFilePath(cr_versioned_path); |
| 101 *framework_shlib_path = | 107 *framework_shlib_path = |
| 102 base::mac::NSStringToFilePath(cr_framework_shlib_path); | 108 base::mac::NSStringToFilePath(cr_framework_shlib_path); |
| 103 return true; | 109 return true; |
| 104 } | 110 } |
| 105 | 111 |
| 106 } // namespace app_mode | 112 } // namespace app_mode |
| OLD | NEW |