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/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
14 | 14 |
15 namespace app_mode { | 15 namespace app_mode { |
16 | 16 |
17 bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) { | 17 bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) { |
18 NSWorkspace* ws = [NSWorkspace sharedWorkspace]; | 18 NSWorkspace* ws = [NSWorkspace sharedWorkspace]; |
19 NSString *bundlePath = [ws absolutePathForAppBundleWithIdentifier:bundle_id]; | 19 NSString *bundlePath = [ws absolutePathForAppBundleWithIdentifier:bundle_id]; |
20 if (!bundlePath) | 20 if (!bundlePath) |
21 return false; | 21 return false; |
22 | 22 |
23 *out_bundle = base::mac::NSStringToFilePath(bundlePath); | 23 *out_bundle = base::mac::NSStringToFilePath(bundlePath); |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 bool GetChromeBundleInfo(const base::FilePath& chrome_bundle, | 27 bool GetChromeBundleInfo(const base::FilePath& chrome_bundle, |
| 28 base::FilePath* executable_path, |
28 base::string16* raw_version_str, | 29 base::string16* raw_version_str, |
29 base::FilePath* version_path, | 30 base::FilePath* version_path, |
30 base::FilePath* framework_shlib_path) { | 31 base::FilePath* framework_shlib_path) { |
31 using base::mac::ObjCCast; | 32 using base::mac::ObjCCast; |
32 | 33 |
33 NSString* cr_bundle_path = base::mac::FilePathToNSString(chrome_bundle); | 34 NSString* cr_bundle_path = base::mac::FilePathToNSString(chrome_bundle); |
34 NSBundle* cr_bundle = [NSBundle bundleWithPath:cr_bundle_path]; | 35 NSBundle* cr_bundle = [NSBundle bundleWithPath:cr_bundle_path]; |
35 | 36 |
36 if (!cr_bundle) | 37 if (!cr_bundle) |
37 return false; | 38 return false; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 76 |
76 // A few more sanity checks. | 77 // A few more sanity checks. |
77 BOOL is_directory; | 78 BOOL is_directory; |
78 BOOL exists = [[NSFileManager defaultManager] | 79 BOOL exists = [[NSFileManager defaultManager] |
79 fileExistsAtPath:cr_framework_shlib_path | 80 fileExistsAtPath:cr_framework_shlib_path |
80 isDirectory:&is_directory]; | 81 isDirectory:&is_directory]; |
81 if (!exists || is_directory) | 82 if (!exists || is_directory) |
82 return false; | 83 return false; |
83 | 84 |
84 // Everything OK, copy output parameters. | 85 // Everything OK, copy output parameters. |
| 86 *executable_path = base::mac::NSStringToFilePath([cr_bundle executablePath]); |
85 *raw_version_str = base::SysNSStringToUTF16(cr_version); | 87 *raw_version_str = base::SysNSStringToUTF16(cr_version); |
86 *version_path = base::mac::NSStringToFilePath(cr_versioned_path); | 88 *version_path = base::mac::NSStringToFilePath(cr_versioned_path); |
87 *framework_shlib_path = | 89 *framework_shlib_path = |
88 base::mac::NSStringToFilePath(cr_framework_shlib_path); | 90 base::mac::NSStringToFilePath(cr_framework_shlib_path); |
89 return true; | 91 return true; |
90 } | 92 } |
91 | 93 |
92 } // namespace app_mode | 94 } // namespace app_mode |
OLD | NEW |