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 #import "chrome/browser/mac/keystone_glue.h" | 5 #import "chrome/browser/mac/keystone_glue.h" |
6 | 6 |
7 #include <sys/mount.h> | 7 #include <sys/mount.h> |
8 #include <sys/param.h> | 8 #include <sys/param.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/sysctl.h> | |
11 #include <sys/types.h> | |
12 | 10 |
13 #include <vector> | 11 #include <vector> |
14 | 12 |
15 #include "base/bind.h" | 13 #include "base/bind.h" |
16 #include "base/location.h" | 14 #include "base/location.h" |
17 #include "base/logging.h" | 15 #include "base/logging.h" |
18 #include "base/mac/authorization_util.h" | 16 #include "base/mac/authorization_util.h" |
19 #include "base/mac/bundle_locations.h" | 17 #include "base/mac/bundle_locations.h" |
20 #include "base/mac/mac_logging.h" | 18 #include "base/mac/mac_logging.h" |
21 #include "base/mac/mac_util.h" | 19 #include "base/mac/mac_util.h" |
22 #include "base/mac/scoped_nsautorelease_pool.h" | 20 #include "base/mac/scoped_nsautorelease_pool.h" |
23 #include "base/mac/scoped_nsexception_enabler.h" | 21 #include "base/mac/scoped_nsexception_enabler.h" |
24 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
25 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
26 #include "base/threading/worker_pool.h" | 24 #include "base/threading/worker_pool.h" |
27 #include "build/build_config.h" | 25 #include "build/build_config.h" |
28 #import "chrome/browser/mac/keystone_registration.h" | 26 #import "chrome/browser/mac/keystone_registration.h" |
| 27 #include "chrome/browser/mac/system_bitness.h" |
29 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/common/chrome_version_info.h" | 29 #include "chrome/common/chrome_version_info.h" |
31 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
33 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/l10n/l10n_util_mac.h" | 33 #include "ui/base/l10n/l10n_util_mac.h" |
35 | 34 |
36 namespace { | 35 namespace { |
37 | 36 |
38 namespace ksr = keystone_registration; | 37 namespace ksr = keystone_registration; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // -promotionComplete. That routine calls | 183 // -promotionComplete. That routine calls |
185 // -changePermissionsForPromotionWithTool: on a work queue thread. When done, | 184 // -changePermissionsForPromotionWithTool: on a work queue thread. When done, |
186 // -changePermissionsForPromotionComplete is called on the main thread. | 185 // -changePermissionsForPromotionComplete is called on the main thread. |
187 - (void)changePermissionsForPromotionAsync; | 186 - (void)changePermissionsForPromotionAsync; |
188 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath; | 187 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath; |
189 - (void)changePermissionsForPromotionComplete; | 188 - (void)changePermissionsForPromotionComplete; |
190 | 189 |
191 // Returns the brand file path to use for Keystone. | 190 // Returns the brand file path to use for Keystone. |
192 - (NSString*)brandFilePath; | 191 - (NSString*)brandFilePath; |
193 | 192 |
194 // YES if the system's CPU is 32-bit-only, NO if it's 64-bit-capable. | |
195 - (BOOL)has32BitOnlyCPU; | |
196 | |
197 // YES if no update installation has succeeded since a binary diff patch | 193 // YES if no update installation has succeeded since a binary diff patch |
198 // installation failed. This signals the need to attempt a full installer | 194 // installation failed. This signals the need to attempt a full installer |
199 // which does not depend on applying a patch to existing files. | 195 // which does not depend on applying a patch to existing files. |
200 - (BOOL)wantsFullInstaller; | 196 - (BOOL)wantsFullInstaller; |
201 | 197 |
202 // Returns an NSString* suitable for appending to a Chrome Keystone tag value | 198 // Returns an NSString* suitable for appending to a Chrome Keystone tag value |
203 // or tag key. If the system has a 32-bit-only CPU, the tag suffix will | 199 // or tag key. If the system has a 32-bit-only CPU, the tag suffix will |
204 // contain the string "-32bit". If a full installer (as opposed to a binary | 200 // contain the string "-32bit". If a full installer (as opposed to a binary |
205 // diff/delta patch) is required, the tag suffix will contain the string | 201 // diff/delta patch) is required, the tag suffix will contain the string |
206 // "-full". If no special treatment is required, the tag suffix will be an | 202 // "-full". If no special treatment is required, the tag suffix will be an |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 [self updateStatus:kAutoupdatePromoted version:nil]; | 998 [self updateStatus:kAutoupdatePromoted version:nil]; |
1003 } | 999 } |
1004 | 1000 |
1005 - (void)setAppPath:(NSString*)appPath { | 1001 - (void)setAppPath:(NSString*)appPath { |
1006 if (appPath != appPath_) { | 1002 if (appPath != appPath_) { |
1007 [appPath_ release]; | 1003 [appPath_ release]; |
1008 appPath_ = [appPath copy]; | 1004 appPath_ = [appPath copy]; |
1009 } | 1005 } |
1010 } | 1006 } |
1011 | 1007 |
1012 - (BOOL)has32BitOnlyCPU { | |
1013 #if defined(ARCH_CPU_64_BITS) | |
1014 return NO; | |
1015 #else // ARCH_CPU_64_BITS | |
1016 int value; | |
1017 size_t valueSize = sizeof(value); | |
1018 if (sysctlbyname("hw.cpu64bit_capable", &value, &valueSize, NULL, 0) != 0) { | |
1019 return YES; | |
1020 } | |
1021 return value == 0; | |
1022 #endif // ARCH_CPU_64_BITS | |
1023 } | |
1024 | |
1025 - (BOOL)wantsFullInstaller { | 1008 - (BOOL)wantsFullInstaller { |
1026 // It's difficult to check the tag prior to Keystone registration, and | 1009 // It's difficult to check the tag prior to Keystone registration, and |
1027 // performing registration replaces the tag. keystone_install.sh | 1010 // performing registration replaces the tag. keystone_install.sh |
1028 // communicates a need for a full installer with Chrome in this file, | 1011 // communicates a need for a full installer with Chrome in this file, |
1029 // .want_full_installer. | 1012 // .want_full_installer. |
1030 NSString* wantFullInstallerPath = | 1013 NSString* wantFullInstallerPath = |
1031 [appPath_ stringByAppendingPathComponent:@".want_full_installer"]; | 1014 [appPath_ stringByAppendingPathComponent:@".want_full_installer"]; |
1032 NSString* wantFullInstallerContents = | 1015 NSString* wantFullInstallerContents = |
1033 [NSString stringWithContentsOfFile:wantFullInstallerPath | 1016 [NSString stringWithContentsOfFile:wantFullInstallerPath |
1034 encoding:NSUTF8StringEncoding | 1017 encoding:NSUTF8StringEncoding |
(...skipping 11 matching lines...) Expand all Loading... |
1046 - (NSString*)tagSuffix { | 1029 - (NSString*)tagSuffix { |
1047 // Tag suffix components are not entirely arbitrary: all possible tag keys | 1030 // Tag suffix components are not entirely arbitrary: all possible tag keys |
1048 // must be present in the application's Info.plist, there must be | 1031 // must be present in the application's Info.plist, there must be |
1049 // server-side agreement on the processing and meaning of tag suffix | 1032 // server-side agreement on the processing and meaning of tag suffix |
1050 // components, and other code that manipulates tag values (such as the | 1033 // components, and other code that manipulates tag values (such as the |
1051 // Keystone update installation script) must be tag suffix-aware. To reduce | 1034 // Keystone update installation script) must be tag suffix-aware. To reduce |
1052 // the number of tag suffix combinations that need to be listed in | 1035 // the number of tag suffix combinations that need to be listed in |
1053 // Info.plist, tag suffix components should only be appended to the tag | 1036 // Info.plist, tag suffix components should only be appended to the tag |
1054 // suffix in ASCII sort order. | 1037 // suffix in ASCII sort order. |
1055 NSString* tagSuffix = @""; | 1038 NSString* tagSuffix = @""; |
1056 if ([self has32BitOnlyCPU]) { | 1039 if (chrome::Has32BitOnlyCPU()) { |
1057 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; | 1040 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; |
1058 } | 1041 } |
1059 if ([self wantsFullInstaller]) { | 1042 if ([self wantsFullInstaller]) { |
1060 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; | 1043 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; |
1061 } | 1044 } |
1062 return tagSuffix; | 1045 return tagSuffix; |
1063 } | 1046 } |
1064 | 1047 |
1065 @end // @implementation KeystoneGlue | 1048 @end // @implementation KeystoneGlue |
1066 | 1049 |
(...skipping 30 matching lines...) Expand all Loading... |
1097 return [KeystoneGlue defaultKeystoneGlue] != nil; | 1080 return [KeystoneGlue defaultKeystoneGlue] != nil; |
1098 } | 1081 } |
1099 | 1082 |
1100 base::string16 CurrentlyInstalledVersion() { | 1083 base::string16 CurrentlyInstalledVersion() { |
1101 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; | 1084 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
1102 NSString* version = [keystoneGlue currentlyInstalledVersion]; | 1085 NSString* version = [keystoneGlue currentlyInstalledVersion]; |
1103 return base::SysNSStringToUTF16(version); | 1086 return base::SysNSStringToUTF16(version); |
1104 } | 1087 } |
1105 | 1088 |
1106 } // namespace keystone_glue | 1089 } // namespace keystone_glue |
OLD | NEW |