| 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/obsolete_system.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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 [self updateStatus:kAutoupdatePromoted version:nil]; | 1002 [self updateStatus:kAutoupdatePromoted version:nil]; |
| 1007 } | 1003 } |
| 1008 | 1004 |
| 1009 - (void)setAppPath:(NSString*)appPath { | 1005 - (void)setAppPath:(NSString*)appPath { |
| 1010 if (appPath != appPath_) { | 1006 if (appPath != appPath_) { |
| 1011 [appPath_ release]; | 1007 [appPath_ release]; |
| 1012 appPath_ = [appPath copy]; | 1008 appPath_ = [appPath copy]; |
| 1013 } | 1009 } |
| 1014 } | 1010 } |
| 1015 | 1011 |
| 1016 - (BOOL)has32BitOnlyCPU { | |
| 1017 #if defined(ARCH_CPU_64_BITS) | |
| 1018 return NO; | |
| 1019 #else // ARCH_CPU_64_BITS | |
| 1020 int value; | |
| 1021 size_t valueSize = sizeof(value); | |
| 1022 if (sysctlbyname("hw.cpu64bit_capable", &value, &valueSize, NULL, 0) != 0) { | |
| 1023 return YES; | |
| 1024 } | |
| 1025 return value == 0; | |
| 1026 #endif // ARCH_CPU_64_BITS | |
| 1027 } | |
| 1028 | |
| 1029 - (BOOL)wantsFullInstaller { | 1012 - (BOOL)wantsFullInstaller { |
| 1030 // It's difficult to check the tag prior to Keystone registration, and | 1013 // It's difficult to check the tag prior to Keystone registration, and |
| 1031 // performing registration replaces the tag. keystone_install.sh | 1014 // performing registration replaces the tag. keystone_install.sh |
| 1032 // communicates a need for a full installer with Chrome in this file, | 1015 // communicates a need for a full installer with Chrome in this file, |
| 1033 // .want_full_installer. | 1016 // .want_full_installer. |
| 1034 NSString* wantFullInstallerPath = | 1017 NSString* wantFullInstallerPath = |
| 1035 [appPath_ stringByAppendingPathComponent:@".want_full_installer"]; | 1018 [appPath_ stringByAppendingPathComponent:@".want_full_installer"]; |
| 1036 NSString* wantFullInstallerContents = | 1019 NSString* wantFullInstallerContents = |
| 1037 [NSString stringWithContentsOfFile:wantFullInstallerPath | 1020 [NSString stringWithContentsOfFile:wantFullInstallerPath |
| 1038 encoding:NSUTF8StringEncoding | 1021 encoding:NSUTF8StringEncoding |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1050 - (NSString*)tagSuffix { | 1033 - (NSString*)tagSuffix { |
| 1051 // Tag suffix components are not entirely arbitrary: all possible tag keys | 1034 // Tag suffix components are not entirely arbitrary: all possible tag keys |
| 1052 // must be present in the application's Info.plist, there must be | 1035 // must be present in the application's Info.plist, there must be |
| 1053 // server-side agreement on the processing and meaning of tag suffix | 1036 // server-side agreement on the processing and meaning of tag suffix |
| 1054 // components, and other code that manipulates tag values (such as the | 1037 // components, and other code that manipulates tag values (such as the |
| 1055 // Keystone update installation script) must be tag suffix-aware. To reduce | 1038 // Keystone update installation script) must be tag suffix-aware. To reduce |
| 1056 // the number of tag suffix combinations that need to be listed in | 1039 // the number of tag suffix combinations that need to be listed in |
| 1057 // Info.plist, tag suffix components should only be appended to the tag | 1040 // Info.plist, tag suffix components should only be appended to the tag |
| 1058 // suffix in ASCII sort order. | 1041 // suffix in ASCII sort order. |
| 1059 NSString* tagSuffix = @""; | 1042 NSString* tagSuffix = @""; |
| 1060 if ([self has32BitOnlyCPU]) { | 1043 if (ObsoleteSystemMac::Has32BitOnlyCPU()) { |
| 1061 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; | 1044 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; |
| 1062 } | 1045 } |
| 1063 if ([self wantsFullInstaller]) { | 1046 if ([self wantsFullInstaller]) { |
| 1064 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; | 1047 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; |
| 1065 } | 1048 } |
| 1066 return tagSuffix; | 1049 return tagSuffix; |
| 1067 } | 1050 } |
| 1068 | 1051 |
| 1069 @end // @implementation KeystoneGlue | 1052 @end // @implementation KeystoneGlue |
| 1070 | 1053 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1101 return [KeystoneGlue defaultKeystoneGlue] != nil; | 1084 return [KeystoneGlue defaultKeystoneGlue] != nil; |
| 1102 } | 1085 } |
| 1103 | 1086 |
| 1104 base::string16 CurrentlyInstalledVersion() { | 1087 base::string16 CurrentlyInstalledVersion() { |
| 1105 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; | 1088 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
| 1106 NSString* version = [keystoneGlue currentlyInstalledVersion]; | 1089 NSString* version = [keystoneGlue currentlyInstalledVersion]; |
| 1107 return base::SysNSStringToUTF16(version); | 1090 return base::SysNSStringToUTF16(version); |
| 1108 } | 1091 } |
| 1109 | 1092 |
| 1110 } // namespace keystone_glue | 1093 } // namespace keystone_glue |
| OLD | NEW |