Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/common/mac/app_mode_chrome_locator.h" | |
| 6 | |
| 7 #import <AppKit/AppKit.h> | |
| 8 #include <CoreFoundation/CoreFoundation.h> | |
| 9 | |
| 10 #include "base/file_path.h" | |
| 11 #include "base/sys_string_conversions.h" | |
| 12 | |
| 13 namespace app_mode { | |
| 14 | |
|
Mark Mentovai
2012/02/07 17:28:06
Who calls these functions? They may need their own
jeremy
2012/02/09 10:52:51
They are only called by the app_loader_mac.mm code
| |
| 15 bool FindBundleById(NSString* bundle_id, FilePath* out_bundle) { | |
| 16 NSString *bundlePath = [[NSWorkspace sharedWorkspace] | |
| 17 absolutePathForAppBundleWithIdentifier:bundle_id]; | |
|
Mark Mentovai
2012/02/07 17:28:06
Weird indentation.
jeremy
2012/02/09 10:52:51
Done.
| |
| 18 if (!bundlePath) | |
| 19 return false; | |
| 20 | |
| 21 *out_bundle = FilePath([bundlePath fileSystemRepresentation]); | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 bool GetChromeBundleInfo(FilePath& chrome_bundle, | |
| 26 string16* raw_version_str, | |
| 27 FilePath* version_path, | |
| 28 FilePath* framework_shlib_path) { | |
| 29 NSString* cr_bundle_path = | |
| 30 [[NSFileManager defaultManager] | |
| 31 stringWithFileSystemRepresentation:chrome_bundle.value().c_str() | |
| 32 length:chrome_bundle.value().size()]; | |
| 33 NSBundle* cr_bundle = [NSBundle bundleWithPath:cr_bundle_path]; | |
| 34 | |
| 35 if (!cr_bundle) | |
| 36 return false; | |
| 37 | |
| 38 // Read raw version string. | |
| 39 NSString* cr_version = | |
| 40 [cr_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; | |
| 41 if (!cr_version) | |
| 42 return false; | |
| 43 | |
| 44 // Get versioned directory. | |
| 45 NSArray* cr_versioned_path_components = | |
| 46 [NSArray arrayWithObjects:cr_bundle_path, | |
| 47 @"Contents", | |
| 48 @"Versions", | |
| 49 cr_version, | |
| 50 nil]; | |
| 51 NSString* cr_versioned_path = | |
| 52 [[NSString pathWithComponents:cr_versioned_path_components] | |
| 53 stringByStandardizingPath]; | |
|
Mark Mentovai
2012/02/07 17:28:06
Do you need -stringByStandardizingPath? Don’t thin
jeremy
2012/02/09 10:52:51
Done.
| |
| 54 | |
| 55 // Get the framework path. | |
| 56 NSString* cr_bundle_exe = | |
| 57 [cr_bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; | |
| 58 NSString* cr_framework_shlib_path = | |
| 59 [cr_versioned_path stringByAppendingPathComponent: | |
| 60 [cr_bundle_exe stringByAppendingString:@" Framework.framework"]]; | |
| 61 cr_framework_shlib_path = | |
| 62 [cr_framework_shlib_path stringByAppendingPathComponent: | |
| 63 [cr_bundle_exe stringByAppendingString:@" Framework"]]; | |
| 64 if (!cr_bundle_exe || !cr_framework_shlib_path) | |
| 65 return false; | |
| 66 | |
| 67 // A few more sanity checks. | |
| 68 BOOL is_directory; | |
| 69 BOOL exists = [[NSFileManager defaultManager] | |
| 70 fileExistsAtPath:cr_framework_shlib_path | |
| 71 isDirectory:&is_directory]; | |
| 72 if (!exists || is_directory) | |
| 73 return false; | |
| 74 | |
| 75 // Everything OK, copy output parameters. | |
| 76 *raw_version_str = base::SysNSStringToUTF16(cr_version); | |
| 77 *version_path = FilePath([cr_versioned_path fileSystemRepresentation]); | |
| 78 *framework_shlib_path = FilePath( | |
| 79 [cr_framework_shlib_path fileSystemRepresentation]); | |
| 80 return true; | |
| 81 } | |
| 82 | |
| 83 } // namespace app_mode | |
| 84 | |
|
Mark Mentovai
2012/02/07 17:28:06
Get rid of the blank line.
jeremy
2012/02/09 10:52:51
Done.
| |
| OLD | NEW |