Update broken references to image assets
[chromium-blink-merge.git] / base / file_version_info_mac.mm
blob8542b19844114c28b02e47e4d86e93ca9b8a32aa
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.
5 #include "base/file_version_info_mac.h"
7 #import <Foundation/Foundation.h>
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "base/mac/bundle_locations.h"
12 #include "base/mac/foundation_util.h"
13 #include "base/strings/sys_string_conversions.h"
15 FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle)
16     : bundle_([bundle retain]) {
19 FileVersionInfoMac::~FileVersionInfoMac() {}
21 // static
22 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() {
23   return CreateFileVersionInfo(base::mac::FrameworkBundlePath());
26 // static
27 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo(
28     const base::FilePath& file_path) {
29   NSString* path = base::SysUTF8ToNSString(file_path.value());
30   NSBundle* bundle = [NSBundle bundleWithPath:path];
31   return new FileVersionInfoMac(bundle);
34 base::string16 FileVersionInfoMac::company_name() {
35   return base::string16();
38 base::string16 FileVersionInfoMac::company_short_name() {
39   return base::string16();
42 base::string16 FileVersionInfoMac::internal_name() {
43   return base::string16();
46 base::string16 FileVersionInfoMac::product_name() {
47   return GetString16Value(kCFBundleNameKey);
50 base::string16 FileVersionInfoMac::product_short_name() {
51   return GetString16Value(kCFBundleNameKey);
54 base::string16 FileVersionInfoMac::comments() {
55   return base::string16();
58 base::string16 FileVersionInfoMac::legal_copyright() {
59   return GetString16Value(CFSTR("CFBundleGetInfoString"));
62 base::string16 FileVersionInfoMac::product_version() {
63   // On OS X, CFBundleVersion is used by LaunchServices, and must follow
64   // specific formatting rules, so the four-part Chrome version is in
65   // CFBundleShortVersionString. On iOS, both have a policy-enfoced limit
66   // of three version components, so the full version is stored in a custom
67   // key (CrBundleVersion) falling back to CFBundleVersion if not present.
68 #if defined(OS_IOS)
69   base::string16 version(GetString16Value(CFSTR("CrBundleVersion")));
70   if (version.length() > 0)
71     return version;
72   return GetString16Value(CFSTR("CFBundleVersion"));
73 #else
74   return GetString16Value(CFSTR("CFBundleShortVersionString"));
75 #endif  // defined(OS_IOS)
78 base::string16 FileVersionInfoMac::file_description() {
79   return base::string16();
82 base::string16 FileVersionInfoMac::legal_trademarks() {
83   return base::string16();
86 base::string16 FileVersionInfoMac::private_build() {
87   return base::string16();
90 base::string16 FileVersionInfoMac::file_version() {
91   return product_version();
94 base::string16 FileVersionInfoMac::original_filename() {
95   return GetString16Value(kCFBundleNameKey);
98 base::string16 FileVersionInfoMac::special_build() {
99   return base::string16();
102 base::string16 FileVersionInfoMac::last_change() {
103   return GetString16Value(CFSTR("SCMRevision"));
106 bool FileVersionInfoMac::is_official_build() {
107 #if defined (GOOGLE_CHROME_BUILD)
108   return true;
109 #else
110   return false;
111 #endif
114 base::string16 FileVersionInfoMac::GetString16Value(CFStringRef name) {
115   if (bundle_) {
116     NSString *ns_name = base::mac::CFToNSCast(name);
117     NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name];
118     if (value) {
119       return base::SysNSStringToUTF16(value);
120     }
121   }
122   return base::string16();