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 #include "base/file_version_info_mac.h" | 5 #include "base/file_version_info_mac.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 // static | 26 // static |
27 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | 27 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( |
28 const base::FilePath& file_path) { | 28 const base::FilePath& file_path) { |
29 NSString* path = base::SysUTF8ToNSString(file_path.value()); | 29 NSString* path = base::SysUTF8ToNSString(file_path.value()); |
30 NSBundle* bundle = [NSBundle bundleWithPath:path]; | 30 NSBundle* bundle = [NSBundle bundleWithPath:path]; |
31 return new FileVersionInfoMac(bundle); | 31 return new FileVersionInfoMac(bundle); |
32 } | 32 } |
33 | 33 |
34 string16 FileVersionInfoMac::company_name() { | 34 base::string16 FileVersionInfoMac::company_name() { |
35 return string16(); | 35 return base::string16(); |
36 } | 36 } |
37 | 37 |
38 string16 FileVersionInfoMac::company_short_name() { | 38 base::string16 FileVersionInfoMac::company_short_name() { |
39 return string16(); | 39 return base::string16(); |
40 } | 40 } |
41 | 41 |
42 string16 FileVersionInfoMac::internal_name() { | 42 base::string16 FileVersionInfoMac::internal_name() { |
43 return string16(); | 43 return base::string16(); |
44 } | 44 } |
45 | 45 |
46 string16 FileVersionInfoMac::product_name() { | 46 base::string16 FileVersionInfoMac::product_name() { |
47 return GetString16Value(kCFBundleNameKey); | 47 return GetString16Value(kCFBundleNameKey); |
48 } | 48 } |
49 | 49 |
50 string16 FileVersionInfoMac::product_short_name() { | 50 base::string16 FileVersionInfoMac::product_short_name() { |
51 return GetString16Value(kCFBundleNameKey); | 51 return GetString16Value(kCFBundleNameKey); |
52 } | 52 } |
53 | 53 |
54 string16 FileVersionInfoMac::comments() { | 54 base::string16 FileVersionInfoMac::comments() { |
55 return string16(); | 55 return base::string16(); |
56 } | 56 } |
57 | 57 |
58 string16 FileVersionInfoMac::legal_copyright() { | 58 base::string16 FileVersionInfoMac::legal_copyright() { |
59 return GetString16Value(CFSTR("CFBundleGetInfoString")); | 59 return GetString16Value(CFSTR("CFBundleGetInfoString")); |
60 } | 60 } |
61 | 61 |
62 string16 FileVersionInfoMac::product_version() { | 62 base::string16 FileVersionInfoMac::product_version() { |
63 // On OS X, CFBundleVersion is used by LaunchServices, and must follow | 63 // On OS X, CFBundleVersion is used by LaunchServices, and must follow |
64 // specific formatting rules, so the four-part Chrome version is in | 64 // specific formatting rules, so the four-part Chrome version is in |
65 // CFBundleShortVersionString. On iOS, however, CFBundleVersion can be the | 65 // CFBundleShortVersionString. On iOS, however, CFBundleVersion can be the |
66 // full version, but CFBundleShortVersionString has a policy-enfoced limit | 66 // full version, but CFBundleShortVersionString has a policy-enfoced limit |
67 // of three version components. | 67 // of three version components. |
68 #if defined(OS_IOS) | 68 #if defined(OS_IOS) |
69 return GetString16Value(CFSTR("CFBundleVersion")); | 69 return GetString16Value(CFSTR("CFBundleVersion")); |
70 #else | 70 #else |
71 return GetString16Value(CFSTR("CFBundleShortVersionString")); | 71 return GetString16Value(CFSTR("CFBundleShortVersionString")); |
72 #endif // defined(OS_IOS) | 72 #endif // defined(OS_IOS) |
73 } | 73 } |
74 | 74 |
75 string16 FileVersionInfoMac::file_description() { | 75 base::string16 FileVersionInfoMac::file_description() { |
76 return string16(); | 76 return base::string16(); |
77 } | 77 } |
78 | 78 |
79 string16 FileVersionInfoMac::legal_trademarks() { | 79 base::string16 FileVersionInfoMac::legal_trademarks() { |
80 return string16(); | 80 return base::string16(); |
81 } | 81 } |
82 | 82 |
83 string16 FileVersionInfoMac::private_build() { | 83 base::string16 FileVersionInfoMac::private_build() { |
84 return string16(); | 84 return base::string16(); |
85 } | 85 } |
86 | 86 |
87 string16 FileVersionInfoMac::file_version() { | 87 base::string16 FileVersionInfoMac::file_version() { |
88 return product_version(); | 88 return product_version(); |
89 } | 89 } |
90 | 90 |
91 string16 FileVersionInfoMac::original_filename() { | 91 base::string16 FileVersionInfoMac::original_filename() { |
92 return GetString16Value(kCFBundleNameKey); | 92 return GetString16Value(kCFBundleNameKey); |
93 } | 93 } |
94 | 94 |
95 string16 FileVersionInfoMac::special_build() { | 95 base::string16 FileVersionInfoMac::special_build() { |
96 return string16(); | 96 return base::string16(); |
97 } | 97 } |
98 | 98 |
99 string16 FileVersionInfoMac::last_change() { | 99 base::string16 FileVersionInfoMac::last_change() { |
100 return GetString16Value(CFSTR("SCMRevision")); | 100 return GetString16Value(CFSTR("SCMRevision")); |
101 } | 101 } |
102 | 102 |
103 bool FileVersionInfoMac::is_official_build() { | 103 bool FileVersionInfoMac::is_official_build() { |
104 #if defined (GOOGLE_CHROME_BUILD) | 104 #if defined (GOOGLE_CHROME_BUILD) |
105 return true; | 105 return true; |
106 #else | 106 #else |
107 return false; | 107 return false; |
108 #endif | 108 #endif |
109 } | 109 } |
110 | 110 |
111 string16 FileVersionInfoMac::GetString16Value(CFStringRef name) { | 111 base::string16 FileVersionInfoMac::GetString16Value(CFStringRef name) { |
112 if (bundle_) { | 112 if (bundle_) { |
113 NSString *ns_name = base::mac::CFToNSCast(name); | 113 NSString *ns_name = base::mac::CFToNSCast(name); |
114 NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name]; | 114 NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name]; |
115 if (value) { | 115 if (value) { |
116 return base::SysNSStringToUTF16(value); | 116 return base::SysNSStringToUTF16(value); |
117 } | 117 } |
118 } | 118 } |
119 return string16(); | 119 return base::string16(); |
120 } | 120 } |
OLD | NEW |