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