OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
12 #include "base/mac_util.h" | 12 #include "base/mac_util.h" |
13 | 13 |
14 FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle) : bundle_(bundle) { | 14 FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle) : bundle_(bundle) { |
15 } | 15 } |
16 | 16 |
17 // static | 17 // static |
18 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { | 18 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { |
19 return CreateFileVersionInfo(mac_util::MainAppBundlePath()); | 19 return CreateFileVersionInfo(mac_util::MainAppBundlePath()); |
20 } | 20 } |
21 | 21 |
22 // static | 22 // static |
23 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | 23 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( |
24 const FilePath& file_path) { | 24 const FilePath& file_path) { |
25 NSString* path = base::SysUTF8ToNSString(file_path.value()); | 25 NSString* path = base::SysUTF8ToNSString(file_path.value()); |
26 NSBundle* bundle = [NSBundle bundleWithPath:path]; | 26 NSBundle* bundle = [NSBundle bundleWithPath:path]; |
27 return new FileVersionInfoMac(bundle); | 27 return new FileVersionInfoMac(bundle); |
28 } | 28 } |
29 | 29 |
30 std::wstring FileVersionInfoMac::company_name() { | 30 string16 FileVersionInfoMac::company_name() { |
31 return std::wstring(); | 31 return string16(); |
32 } | 32 } |
33 | 33 |
34 std::wstring FileVersionInfoMac::company_short_name() { | 34 string16 FileVersionInfoMac::company_short_name() { |
35 return std::wstring(); | 35 return string16(); |
36 } | 36 } |
37 | 37 |
38 std::wstring FileVersionInfoMac::internal_name() { | 38 string16 FileVersionInfoMac::internal_name() { |
39 return std::wstring(); | 39 return string16(); |
40 } | 40 } |
41 | 41 |
42 std::wstring FileVersionInfoMac::product_name() { | 42 string16 FileVersionInfoMac::product_name() { |
43 return GetWStringValue(kCFBundleNameKey); | 43 return GetString16Value(kCFBundleNameKey); |
44 } | 44 } |
45 | 45 |
46 std::wstring FileVersionInfoMac::product_short_name() { | 46 string16 FileVersionInfoMac::product_short_name() { |
47 return GetWStringValue(kCFBundleNameKey); | 47 return GetString16Value(kCFBundleNameKey); |
48 } | 48 } |
49 | 49 |
50 std::wstring FileVersionInfoMac::comments() { | 50 string16 FileVersionInfoMac::comments() { |
51 return std::wstring(); | 51 return string16(); |
52 } | 52 } |
53 | 53 |
54 std::wstring FileVersionInfoMac::legal_copyright() { | 54 string16 FileVersionInfoMac::legal_copyright() { |
55 return GetWStringValue(CFSTR("CFBundleGetInfoString")); | 55 return GetString16Value(CFSTR("CFBundleGetInfoString")); |
56 } | 56 } |
57 | 57 |
58 std::wstring FileVersionInfoMac::product_version() { | 58 string16 FileVersionInfoMac::product_version() { |
59 return GetWStringValue(CFSTR("CFBundleShortVersionString")); | 59 return GetString16Value(CFSTR("CFBundleShortVersionString")); |
60 } | 60 } |
61 | 61 |
62 std::wstring FileVersionInfoMac::file_description() { | 62 string16 FileVersionInfoMac::file_description() { |
63 return std::wstring(); | 63 return string16(); |
64 } | 64 } |
65 | 65 |
66 std::wstring FileVersionInfoMac::legal_trademarks() { | 66 string16 FileVersionInfoMac::legal_trademarks() { |
67 return std::wstring(); | 67 return string16(); |
68 } | 68 } |
69 | 69 |
70 std::wstring FileVersionInfoMac::private_build() { | 70 string16 FileVersionInfoMac::private_build() { |
71 return std::wstring(); | 71 return string16(); |
72 } | 72 } |
73 | 73 |
74 std::wstring FileVersionInfoMac::file_version() { | 74 string16 FileVersionInfoMac::file_version() { |
75 return product_version(); | 75 return product_version(); |
76 } | 76 } |
77 | 77 |
78 std::wstring FileVersionInfoMac::original_filename() { | 78 string16 FileVersionInfoMac::original_filename() { |
79 return GetWStringValue(kCFBundleNameKey); | 79 return GetString16Value(kCFBundleNameKey); |
80 } | 80 } |
81 | 81 |
82 std::wstring FileVersionInfoMac::special_build() { | 82 string16 FileVersionInfoMac::special_build() { |
83 return std::wstring(); | 83 return string16(); |
84 } | 84 } |
85 | 85 |
86 std::wstring FileVersionInfoMac::last_change() { | 86 string16 FileVersionInfoMac::last_change() { |
87 return GetWStringValue(CFSTR("SVNRevision")); | 87 return GetString16Value(CFSTR("SVNRevision")); |
88 } | 88 } |
89 | 89 |
90 bool FileVersionInfoMac::is_official_build() { | 90 bool FileVersionInfoMac::is_official_build() { |
91 #if defined (GOOGLE_CHROME_BUILD) | 91 #if defined (GOOGLE_CHROME_BUILD) |
92 return true; | 92 return true; |
93 #else | 93 #else |
94 return false; | 94 return false; |
95 #endif | 95 #endif |
96 } | 96 } |
97 | 97 |
98 std::wstring FileVersionInfoMac::GetWStringValue(CFStringRef name) { | 98 string16 FileVersionInfoMac::GetString16Value(CFStringRef name) { |
99 if (bundle_) { | 99 if (bundle_) { |
100 NSString *ns_name = mac_util::CFToNSCast(name); | 100 NSString *ns_name = mac_util::CFToNSCast(name); |
101 NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name]; | 101 NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name]; |
102 if (value) { | 102 if (value) { |
103 return base::SysNSStringToWide(value); | 103 return base::SysNSStringToUTF16(value); |
104 } | 104 } |
105 } | 105 } |
106 return std::wstring(); | 106 return string16(); |
107 } | 107 } |
OLD | NEW |