[email protected] | ea053a98 | 2011-04-11 19:17:13 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 49df602 | 2008-08-27 19:03:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 4 | |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 5 | #include "base/file_version_info_mac.h" |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 6 | |
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 7 | #import <Foundation/Foundation.h> |
[email protected] | 1265917f | 2008-08-12 17:33:52 | [diff] [blame] | 8 | |
[email protected] | f539333 | 2009-06-03 15:01:29 | [diff] [blame] | 9 | #include "base/file_path.h" |
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 10 | #include "base/logging.h" |
[email protected] | 27d02e0 | 2011-05-05 21:27:07 | [diff] [blame^] | 11 | #include "base/mac/foundation_util.h" |
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 12 | #include "base/sys_string_conversions.h" |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 13 | |
[email protected] | ea053a98 | 2011-04-11 19:17:13 | [diff] [blame] | 14 | FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle) |
15 | : bundle_([bundle retain]) { | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 16 | } |
17 | |||||
[email protected] | 64b29caf | 2011-02-24 20:23:03 | [diff] [blame] | 18 | FileVersionInfoMac::~FileVersionInfoMac() {} |
19 | |||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 20 | // static |
21 | FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { | ||||
[email protected] | 0378bf4 | 2011-01-01 18:20:14 | [diff] [blame] | 22 | return CreateFileVersionInfo(base::mac::MainAppBundlePath()); |
[email protected] | 0956223 | 2008-12-23 16:57:36 | [diff] [blame] | 23 | } |
24 | |||||
25 | // static | ||||
26 | FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | ||||
27 | const FilePath& file_path) { | ||||
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 28 | NSString* path = base::SysUTF8ToNSString(file_path.value()); |
29 | NSBundle* bundle = [NSBundle bundleWithPath:path]; | ||||
30 | return new FileVersionInfoMac(bundle); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 31 | } |
32 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 33 | string16 FileVersionInfoMac::company_name() { |
34 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 35 | } |
36 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 37 | string16 FileVersionInfoMac::company_short_name() { |
38 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 39 | } |
40 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 41 | string16 FileVersionInfoMac::internal_name() { |
42 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 43 | } |
44 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 45 | string16 FileVersionInfoMac::product_name() { |
46 | return GetString16Value(kCFBundleNameKey); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 47 | } |
48 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 49 | string16 FileVersionInfoMac::product_short_name() { |
50 | return GetString16Value(kCFBundleNameKey); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 51 | } |
52 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 53 | string16 FileVersionInfoMac::comments() { |
54 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 55 | } |
56 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 57 | string16 FileVersionInfoMac::legal_copyright() { |
58 | return GetString16Value(CFSTR("CFBundleGetInfoString")); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 59 | } |
60 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 61 | string16 FileVersionInfoMac::product_version() { |
62 | return GetString16Value(CFSTR("CFBundleShortVersionString")); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 63 | } |
64 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 65 | string16 FileVersionInfoMac::file_description() { |
66 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 67 | } |
68 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 69 | string16 FileVersionInfoMac::legal_trademarks() { |
70 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 71 | } |
72 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 73 | string16 FileVersionInfoMac::private_build() { |
74 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 75 | } |
76 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 77 | string16 FileVersionInfoMac::file_version() { |
[email protected] | 41cd00a4 | 2009-10-14 15:51:57 | [diff] [blame] | 78 | return product_version(); |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 79 | } |
80 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 81 | string16 FileVersionInfoMac::original_filename() { |
82 | return GetString16Value(kCFBundleNameKey); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 83 | } |
84 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 85 | string16 FileVersionInfoMac::special_build() { |
86 | return string16(); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 87 | } |
88 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 89 | string16 FileVersionInfoMac::last_change() { |
90 | return GetString16Value(CFSTR("SVNRevision")); | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 91 | } |
92 | |||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 93 | bool FileVersionInfoMac::is_official_build() { |
[email protected] | 1f2fe99 | 2009-06-01 18:27:27 | [diff] [blame] | 94 | #if defined (GOOGLE_CHROME_BUILD) |
95 | return true; | ||||
96 | #else | ||||
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 97 | return false; |
[email protected] | 1f2fe99 | 2009-06-01 18:27:27 | [diff] [blame] | 98 | #endif |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 99 | } |
100 | |||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 101 | string16 FileVersionInfoMac::GetString16Value(CFStringRef name) { |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 102 | if (bundle_) { |
[email protected] | 0378bf4 | 2011-01-01 18:20:14 | [diff] [blame] | 103 | NSString *ns_name = base::mac::CFToNSCast(name); |
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 104 | NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name]; |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 105 | if (value) { |
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 106 | return base::SysNSStringToUTF16(value); |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 107 | } |
108 | } | ||||
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 109 | return string16(); |
[email protected] | 6723f83 | 2008-08-11 15:38:27 | [diff] [blame] | 110 | } |