Enable password generation only if sync for passwords is enabled.
[chromium-blink-merge.git] / base / file_version_info_mac.mm
blob93191e0c5237fa820577901debd55436acc8e2b7
1 // Copyright (c) 2011 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/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/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 FilePath& file_path) {
29   NSString* path = base::SysUTF8ToNSString(file_path.value());
30   NSBundle* bundle = [NSBundle bundleWithPath:path];
31   return new FileVersionInfoMac(bundle);
34 string16 FileVersionInfoMac::company_name() {
35   return string16();
38 string16 FileVersionInfoMac::company_short_name() {
39   return string16();
42 string16 FileVersionInfoMac::internal_name() {
43   return string16();
46 string16 FileVersionInfoMac::product_name() {
47   return GetString16Value(kCFBundleNameKey);
50 string16 FileVersionInfoMac::product_short_name() {
51   return GetString16Value(kCFBundleNameKey);
54 string16 FileVersionInfoMac::comments() {
55   return string16();
58 string16 FileVersionInfoMac::legal_copyright() {
59   return GetString16Value(CFSTR("CFBundleGetInfoString"));
62 string16 FileVersionInfoMac::product_version() {
63   return GetString16Value(CFSTR("CFBundleShortVersionString"));
66 string16 FileVersionInfoMac::file_description() {
67   return string16();
70 string16 FileVersionInfoMac::legal_trademarks() {
71   return string16();
74 string16 FileVersionInfoMac::private_build() {
75   return string16();
78 string16 FileVersionInfoMac::file_version() {
79   return product_version();
82 string16 FileVersionInfoMac::original_filename() {
83   return GetString16Value(kCFBundleNameKey);
86 string16 FileVersionInfoMac::special_build() {
87   return string16();
90 string16 FileVersionInfoMac::last_change() {
91   return GetString16Value(CFSTR("SVNRevision"));
94 bool FileVersionInfoMac::is_official_build() {
95 #if defined (GOOGLE_CHROME_BUILD)
96   return true;
97 #else
98   return false;
99 #endif
102 string16 FileVersionInfoMac::GetString16Value(CFStringRef name) {
103   if (bundle_) {
104     NSString *ns_name = base::mac::CFToNSCast(name);
105     NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name];
106     if (value) {
107       return base::SysNSStringToUTF16(value);
108     }
109   }
110   return string16();