Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: base/file_version_info_mac.mm

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/file_version_info_mac.h ('k') | base/file_version_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/file_version_info_mac.h"
6
7 #import <Foundation/Foundation.h>
8
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"
14
15 FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle)
16 : bundle_([bundle retain]) {
17 }
18
19 FileVersionInfoMac::~FileVersionInfoMac() {}
20
21 // static
22 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() {
23 return CreateFileVersionInfo(base::mac::FrameworkBundlePath());
24 }
25
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);
32 }
33
34 base::string16 FileVersionInfoMac::company_name() {
35 return base::string16();
36 }
37
38 base::string16 FileVersionInfoMac::company_short_name() {
39 return base::string16();
40 }
41
42 base::string16 FileVersionInfoMac::internal_name() {
43 return base::string16();
44 }
45
46 base::string16 FileVersionInfoMac::product_name() {
47 return GetString16Value(kCFBundleNameKey);
48 }
49
50 base::string16 FileVersionInfoMac::product_short_name() {
51 return GetString16Value(kCFBundleNameKey);
52 }
53
54 base::string16 FileVersionInfoMac::comments() {
55 return base::string16();
56 }
57
58 base::string16 FileVersionInfoMac::legal_copyright() {
59 return GetString16Value(CFSTR("CFBundleGetInfoString"));
60 }
61
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)
76 }
77
78 base::string16 FileVersionInfoMac::file_description() {
79 return base::string16();
80 }
81
82 base::string16 FileVersionInfoMac::legal_trademarks() {
83 return base::string16();
84 }
85
86 base::string16 FileVersionInfoMac::private_build() {
87 return base::string16();
88 }
89
90 base::string16 FileVersionInfoMac::file_version() {
91 return product_version();
92 }
93
94 base::string16 FileVersionInfoMac::original_filename() {
95 return GetString16Value(kCFBundleNameKey);
96 }
97
98 base::string16 FileVersionInfoMac::special_build() {
99 return base::string16();
100 }
101
102 base::string16 FileVersionInfoMac::last_change() {
103 return GetString16Value(CFSTR("SCMRevision"));
104 }
105
106 bool FileVersionInfoMac::is_official_build() {
107 #if defined (GOOGLE_CHROME_BUILD)
108 return true;
109 #else
110 return false;
111 #endif
112 }
113
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();
123 }
OLDNEW
« no previous file with comments | « base/file_version_info_mac.h ('k') | base/file_version_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698