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

Side by Side Diff: chrome/browser/mac/keystone_glue.mm

Issue 122713003: Merge trunk r242964 to the 33.0.1750 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1750/src/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « build/mac/tweak_info_plist.py ('k') | chrome/installer/mac/keystone_install.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
10 12
11 #include <vector> 13 #include <vector>
12 14
13 #include "base/bind.h" 15 #include "base/bind.h"
14 #include "base/location.h" 16 #include "base/location.h"
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/mac/authorization_util.h" 18 #include "base/mac/authorization_util.h"
17 #include "base/mac/bundle_locations.h" 19 #include "base/mac/bundle_locations.h"
18 #include "base/mac/mac_logging.h" 20 #include "base/mac/mac_logging.h"
19 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
20 #include "base/mac/scoped_nsautorelease_pool.h" 22 #include "base/mac/scoped_nsautorelease_pool.h"
21 #include "base/mac/scoped_nsexception_enabler.h" 23 #include "base/mac/scoped_nsexception_enabler.h"
22 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
23 #include "base/strings/sys_string_conversions.h" 25 #include "base/strings/sys_string_conversions.h"
24 #include "base/threading/worker_pool.h" 26 #include "base/threading/worker_pool.h"
27 #include "build/build_config.h"
25 #import "chrome/browser/mac/keystone_registration.h" 28 #import "chrome/browser/mac/keystone_registration.h"
26 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_version_info.h" 30 #include "chrome/common/chrome_version_info.h"
28 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/l10n/l10n_util_mac.h" 34 #include "ui/base/l10n/l10n_util_mac.h"
32 35
33 namespace { 36 namespace {
34 37
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // -promotionComplete. That routine calls 184 // -promotionComplete. That routine calls
182 // -changePermissionsForPromotionWithTool: on a work queue thread. When done, 185 // -changePermissionsForPromotionWithTool: on a work queue thread. When done,
183 // -changePermissionsForPromotionComplete is called on the main thread. 186 // -changePermissionsForPromotionComplete is called on the main thread.
184 - (void)changePermissionsForPromotionAsync; 187 - (void)changePermissionsForPromotionAsync;
185 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath; 188 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath;
186 - (void)changePermissionsForPromotionComplete; 189 - (void)changePermissionsForPromotionComplete;
187 190
188 // Returns the brand file path to use for Keystone. 191 // Returns the brand file path to use for Keystone.
189 - (NSString*)brandFilePath; 192 - (NSString*)brandFilePath;
190 193
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
198 // installation failed. This signals the need to attempt a full installer
199 // which does not depend on applying a patch to existing files.
200 - (BOOL)wantsFullInstaller;
201
202 // 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
204 // 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
206 // "-full". If no special treatment is required, the tag suffix will be an
207 // empty string.
208 - (NSString*)tagSuffix;
209
191 @end // @interface KeystoneGlue (Private) 210 @end // @interface KeystoneGlue (Private)
192 211
193 NSString* const kAutoupdateStatusNotification = @"AutoupdateStatusNotification"; 212 NSString* const kAutoupdateStatusNotification = @"AutoupdateStatusNotification";
194 NSString* const kAutoupdateStatusStatus = @"status"; 213 NSString* const kAutoupdateStatusStatus = @"status";
195 NSString* const kAutoupdateStatusVersion = @"version"; 214 NSString* const kAutoupdateStatusVersion = @"version";
196 215
197 namespace { 216 namespace {
198 217
199 NSString* const kChannelKey = @"KSChannelID"; 218 NSString* const kChannelKey = @"KSChannelID";
200 NSString* const kBrandKey = @"KSBrandID"; 219 NSString* const kBrandKey = @"KSBrandID";
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 NSString* appInfoPlistPath = [self appInfoPlistPath]; 465 NSString* appInfoPlistPath = [self appInfoPlistPath];
447 NSString* brandKey = kBrandKey; 466 NSString* brandKey = kBrandKey;
448 NSString* brandPath = [self brandFilePath]; 467 NSString* brandPath = [self brandFilePath];
449 468
450 if ([brandPath length] == 0) { 469 if ([brandPath length] == 0) {
451 // Brand path and brand key must be cleared together or ksadmin seems 470 // Brand path and brand key must be cleared together or ksadmin seems
452 // to throw an error. 471 // to throw an error.
453 brandKey = @""; 472 brandKey = @"";
454 } 473 }
455 474
475 // Note that channel_ is permitted to be an empty string, but it must not be
476 // nil.
477 DCHECK(channel_);
478 NSString* tagSuffix = [self tagSuffix];
479 NSString* tagValue = [channel_ stringByAppendingString:tagSuffix];
480 NSString* tagKey = [kChannelKey stringByAppendingString:tagSuffix];
481
456 return [NSDictionary dictionaryWithObjectsAndKeys: 482 return [NSDictionary dictionaryWithObjectsAndKeys:
457 version_, ksr::KSRegistrationVersionKey, 483 version_, ksr::KSRegistrationVersionKey,
458 appInfoPlistPath, ksr::KSRegistrationVersionPathKey, 484 appInfoPlistPath, ksr::KSRegistrationVersionPathKey,
459 kVersionKey, ksr::KSRegistrationVersionKeyKey, 485 kVersionKey, ksr::KSRegistrationVersionKeyKey,
460 xcType, ksr::KSRegistrationExistenceCheckerTypeKey, 486 xcType, ksr::KSRegistrationExistenceCheckerTypeKey,
461 appPath_, ksr::KSRegistrationExistenceCheckerStringKey, 487 appPath_, ksr::KSRegistrationExistenceCheckerStringKey,
462 url_, ksr::KSRegistrationServerURLStringKey, 488 url_, ksr::KSRegistrationServerURLStringKey,
463 preserveTTToken, ksr::KSRegistrationPreserveTrustedTesterTokenKey, 489 preserveTTToken, ksr::KSRegistrationPreserveTrustedTesterTokenKey,
464 channel_, ksr::KSRegistrationTagKey, 490 tagValue, ksr::KSRegistrationTagKey,
465 appInfoPlistPath, ksr::KSRegistrationTagPathKey, 491 appInfoPlistPath, ksr::KSRegistrationTagPathKey,
466 kChannelKey, ksr::KSRegistrationTagKeyKey, 492 tagKey, ksr::KSRegistrationTagKeyKey,
467 brandPath, ksr::KSRegistrationBrandPathKey, 493 brandPath, ksr::KSRegistrationBrandPathKey,
468 brandKey, ksr::KSRegistrationBrandKeyKey, 494 brandKey, ksr::KSRegistrationBrandKeyKey,
469 nil]; 495 nil];
470 } 496 }
471 497
472 - (void)registerWithKeystone { 498 - (void)registerWithKeystone {
473 [self updateStatus:kAutoupdateRegistering version:nil]; 499 [self updateStatus:kAutoupdateRegistering version:nil];
474 500
475 NSDictionary* parameters = [self keystoneParameters]; 501 NSDictionary* parameters = [self keystoneParameters];
476 BOOL result; 502 BOOL result;
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 [self updateStatus:kAutoupdatePromoted version:nil]; 1002 [self updateStatus:kAutoupdatePromoted version:nil];
977 } 1003 }
978 1004
979 - (void)setAppPath:(NSString*)appPath { 1005 - (void)setAppPath:(NSString*)appPath {
980 if (appPath != appPath_) { 1006 if (appPath != appPath_) {
981 [appPath_ release]; 1007 [appPath_ release];
982 appPath_ = [appPath copy]; 1008 appPath_ = [appPath copy];
983 } 1009 }
984 } 1010 }
985 1011
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 {
1026 // It's difficult to check the tag prior to Keystone registration, and
1027 // performing registration replaces the tag. keystone_install.sh
1028 // communicates a need for a full installer with Chrome in this file,
1029 // .want_full_installer.
1030 NSString* wantFullInstallerPath =
1031 [appPath_ stringByAppendingPathComponent:@".want_full_installer"];
1032 NSString* wantFullInstallerContents =
1033 [NSString stringWithContentsOfFile:wantFullInstallerPath
1034 encoding:NSUTF8StringEncoding
1035 error:NULL];
1036 if (!wantFullInstallerContents) {
1037 return NO;
1038 }
1039
1040 NSString* wantFullInstallerVersion =
1041 [wantFullInstallerContents stringByTrimmingCharactersInSet:
1042 [NSCharacterSet newlineCharacterSet]];
1043 return [wantFullInstallerVersion isEqualToString:version_];
1044 }
1045
1046 - (NSString*)tagSuffix {
1047 // Tag suffix components are not entirely arbitrary: all possible tag keys
1048 // must be present in the application's Info.plist, there must be
1049 // server-side agreement on the processing and meaning of tag suffix
1050 // components, and other code that manipulates tag values (such as the
1051 // Keystone update installation script) must be tag suffix-aware. To reduce
1052 // 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
1054 // suffix in ASCII sort order.
1055 NSString* tagSuffix = @"";
1056 if ([self has32BitOnlyCPU]) {
1057 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"];
1058 }
1059 if ([self wantsFullInstaller]) {
1060 tagSuffix = [tagSuffix stringByAppendingString:@"-full"];
1061 }
1062 return tagSuffix;
1063 }
1064
986 @end // @implementation KeystoneGlue 1065 @end // @implementation KeystoneGlue
987 1066
988 namespace { 1067 namespace {
989 1068
990 std::string BrandCodeInternal() { 1069 std::string BrandCodeInternal() {
991 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; 1070 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue];
992 NSString* brand_path = [keystone_glue brandFilePath]; 1071 NSString* brand_path = [keystone_glue brandFilePath];
993 1072
994 if (![brand_path length]) 1073 if (![brand_path length])
995 return std::string(); 1074 return std::string();
(...skipping 22 matching lines...) Expand all
1018 return [KeystoneGlue defaultKeystoneGlue] != nil; 1097 return [KeystoneGlue defaultKeystoneGlue] != nil;
1019 } 1098 }
1020 1099
1021 base::string16 CurrentlyInstalledVersion() { 1100 base::string16 CurrentlyInstalledVersion() {
1022 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; 1101 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
1023 NSString* version = [keystoneGlue currentlyInstalledVersion]; 1102 NSString* version = [keystoneGlue currentlyInstalledVersion];
1024 return base::SysNSStringToUTF16(version); 1103 return base::SysNSStringToUTF16(version);
1025 } 1104 }
1026 1105
1027 } // namespace keystone_glue 1106 } // namespace keystone_glue
OLDNEW
« no previous file with comments | « build/mac/tweak_info_plist.py ('k') | chrome/installer/mac/keystone_install.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698