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

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

Issue 6990046: Register with Keystone using a versionPath and versionKey (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 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 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/cocoa/keystone_glue.h" 5 #import "chrome/browser/cocoa/keystone_glue.h"
6 6
7 #include <sys/param.h> 7 #include <sys/param.h>
8 #include <sys/mount.h> 8 #include <sys/mount.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 NSString* const KSRegistrationExistenceCheckerTypeKey = @"ExistenceCheckerType"; 42 NSString* const KSRegistrationExistenceCheckerTypeKey = @"ExistenceCheckerType";
43 NSString* const KSRegistrationExistenceCheckerStringKey = 43 NSString* const KSRegistrationExistenceCheckerStringKey =
44 @"ExistenceCheckerString"; 44 @"ExistenceCheckerString";
45 NSString* const KSRegistrationServerURLStringKey = @"URLString"; 45 NSString* const KSRegistrationServerURLStringKey = @"URLString";
46 NSString* const KSRegistrationPreserveTrustedTesterTokenKey = @"PreserveTTT"; 46 NSString* const KSRegistrationPreserveTrustedTesterTokenKey = @"PreserveTTT";
47 NSString* const KSRegistrationTagKey = @"Tag"; 47 NSString* const KSRegistrationTagKey = @"Tag";
48 NSString* const KSRegistrationTagPathKey = @"TagPath"; 48 NSString* const KSRegistrationTagPathKey = @"TagPath";
49 NSString* const KSRegistrationTagKeyKey = @"TagKey"; 49 NSString* const KSRegistrationTagKeyKey = @"TagKey";
50 NSString* const KSRegistrationBrandPathKey = @"BrandPath"; 50 NSString* const KSRegistrationBrandPathKey = @"BrandPath";
51 NSString* const KSRegistrationBrandKeyKey = @"BrandKey"; 51 NSString* const KSRegistrationBrandKeyKey = @"BrandKey";
52 NSString* const KSRegistrationVersionPathKey = @"VersionPath";
53 NSString* const KSRegistrationVersionKeyKey = @"VersionKey";
52 54
53 NSString* const KSRegistrationDidCompleteNotification = 55 NSString* const KSRegistrationDidCompleteNotification =
54 @"KSRegistrationDidCompleteNotification"; 56 @"KSRegistrationDidCompleteNotification";
55 NSString* const KSRegistrationPromotionDidCompleteNotification = 57 NSString* const KSRegistrationPromotionDidCompleteNotification =
56 @"KSRegistrationPromotionDidCompleteNotification"; 58 @"KSRegistrationPromotionDidCompleteNotification";
57 59
58 NSString* const KSRegistrationCheckForUpdateNotification = 60 NSString* const KSRegistrationCheckForUpdateNotification =
59 @"KSRegistrationCheckForUpdateNotification"; 61 @"KSRegistrationCheckForUpdateNotification";
60 NSString* KSRegistrationStatusKey = @"Status"; 62 NSString* KSRegistrationStatusKey = @"Status";
61 NSString* KSRegistrationUpdateCheckErrorKey = @"Error"; 63 NSString* KSRegistrationUpdateCheckErrorKey = @"Error";
62 64
63 NSString* const KSRegistrationStartUpdateNotification = 65 NSString* const KSRegistrationStartUpdateNotification =
64 @"KSRegistrationStartUpdateNotification"; 66 @"KSRegistrationStartUpdateNotification";
65 NSString* const KSUpdateCheckSuccessfulKey = @"CheckSuccessful"; 67 NSString* const KSUpdateCheckSuccessfulKey = @"CheckSuccessful";
66 NSString* const KSUpdateCheckSuccessfullyInstalledKey = 68 NSString* const KSUpdateCheckSuccessfullyInstalledKey =
67 @"SuccessfullyInstalled"; 69 @"SuccessfullyInstalled";
68 70
69 NSString* const KSRegistrationRemoveExistingTag = @""; 71 NSString* const KSRegistrationRemoveExistingTag = @"";
70 #define KSRegistrationPreserveExistingTag nil 72 #define KSRegistrationPreserveExistingTag nil
71 73
72 // Constants for the brand file (uses an external file so it can survive updates 74 // Constants for the brand file (uses an external file so it can survive
73 // to Chrome. 75 // updates to Chrome.)
74 76
75 #if defined(GOOGLE_CHROME_BUILD) 77 #if defined(GOOGLE_CHROME_BUILD)
76 #define kBrandFileName @"Google Chrome Brand.plist"; 78 #define kBrandFileName @"Google Chrome Brand.plist";
77 #elif defined(CHROMIUM_BUILD) 79 #elif defined(CHROMIUM_BUILD)
78 #define kBrandFileName @"Chromium Brand.plist"; 80 #define kBrandFileName @"Chromium Brand.plist";
79 #else 81 #else
80 #error Unknown branding 82 #error Unknown branding
81 #endif 83 #endif
82 84
83 // These directories are hardcoded in Keystone promotion preflight and the 85 // These directories are hardcoded in Keystone promotion preflight and the
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 - (BOOL)promoteWithParameters:(NSDictionary*)args 150 - (BOOL)promoteWithParameters:(NSDictionary*)args
149 authorization:(AuthorizationRef)authorization; 151 authorization:(AuthorizationRef)authorization;
150 152
151 - (void)setActive; 153 - (void)setActive;
152 - (void)checkForUpdate; 154 - (void)checkForUpdate;
153 - (void)startUpdate; 155 - (void)startUpdate;
154 - (KSRegistrationTicketType)ticketType; 156 - (KSRegistrationTicketType)ticketType;
155 157
156 @end // @interface KSRegistration 158 @end // @interface KSRegistration
157 159
158 @interface KeystoneGlue(Private) 160 @interface KeystoneGlue (Private)
159 161
160 // Returns the path to the application's Info.plist file. This returns the 162 // Returns the path to the application's Info.plist file. This returns the
161 // outer application bundle's Info.plist, not the framework's Info.plist. 163 // outer application bundle's Info.plist, not the framework's Info.plist.
162 - (NSString*)appInfoPlistPath; 164 - (NSString*)appInfoPlistPath;
163 165
164 // Returns a dictionary containing parameters to be used for a KSRegistration 166 // Returns a dictionary containing parameters to be used for a KSRegistration
165 // -registerWithParameters: or -promoteWithParameters:authorization: call. 167 // -registerWithParameters: or -promoteWithParameters:authorization: call.
166 - (NSDictionary*)keystoneParameters; 168 - (NSDictionary*)keystoneParameters;
167 169
168 // Called when Keystone registration completes. 170 // Called when Keystone registration completes.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // -promotionComplete. That routine calls 223 // -promotionComplete. That routine calls
222 // -changePermissionsForPromotionWithTool: on a work queue thread. When done, 224 // -changePermissionsForPromotionWithTool: on a work queue thread. When done,
223 // -changePermissionsForPromotionComplete is called on the main thread. 225 // -changePermissionsForPromotionComplete is called on the main thread.
224 - (void)changePermissionsForPromotionAsync; 226 - (void)changePermissionsForPromotionAsync;
225 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath; 227 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath;
226 - (void)changePermissionsForPromotionComplete; 228 - (void)changePermissionsForPromotionComplete;
227 229
228 // Returns the brand file path to use for Keystone. 230 // Returns the brand file path to use for Keystone.
229 - (NSString*)brandFilePath; 231 - (NSString*)brandFilePath;
230 232
231 @end // @interface KeystoneGlue(Private) 233 @end // @interface KeystoneGlue (Private)
232 234
233 NSString* const kAutoupdateStatusNotification = @"AutoupdateStatusNotification"; 235 NSString* const kAutoupdateStatusNotification = @"AutoupdateStatusNotification";
234 NSString* const kAutoupdateStatusStatus = @"status"; 236 NSString* const kAutoupdateStatusStatus = @"status";
235 NSString* const kAutoupdateStatusVersion = @"version"; 237 NSString* const kAutoupdateStatusVersion = @"version";
236 238
237 namespace { 239 namespace {
238 240
239 NSString* const kChannelKey = @"KSChannelID"; 241 NSString* const kChannelKey = @"KSChannelID";
240 NSString* const kBrandKey = @"KSBrandID"; 242 NSString* const kBrandKey = @"KSBrandID";
243 NSString* const kVersionKey = @"KSVersion";
241 244
242 } // namespace 245 } // namespace
243 246
244 @implementation KeystoneGlue 247 @implementation KeystoneGlue
245 248
246 + (id)defaultKeystoneGlue { 249 + (id)defaultKeystoneGlue {
247 static bool sTriedCreatingDefaultKeystoneGlue = false; 250 static bool sTriedCreatingDefaultKeystoneGlue = false;
248 // TODO(jrg): use base::SingletonObjC<KeystoneGlue> 251 // TODO(jrg): use base::SingletonObjC<KeystoneGlue>
249 static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked 252 static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
250 253
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 NSBundle* appBundle = [NSBundle mainBundle]; 316 NSBundle* appBundle = [NSBundle mainBundle];
314 NSDictionary* infoDictionary = [self infoDictionary]; 317 NSDictionary* infoDictionary = [self infoDictionary];
315 318
316 NSString* productID = [infoDictionary objectForKey:@"KSProductID"]; 319 NSString* productID = [infoDictionary objectForKey:@"KSProductID"];
317 if (productID == nil) { 320 if (productID == nil) {
318 productID = [appBundle bundleIdentifier]; 321 productID = [appBundle bundleIdentifier];
319 } 322 }
320 323
321 NSString* appPath = [appBundle bundlePath]; 324 NSString* appPath = [appBundle bundlePath];
322 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; 325 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"];
323 NSString* version = [infoDictionary objectForKey:@"KSVersion"]; 326 NSString* version = [infoDictionary objectForKey:kVersionKey];
324 327
325 if (!productID || !appPath || !url || !version) { 328 if (!productID || !appPath || !url || !version) {
326 // If parameters required for Keystone are missing, don't use it. 329 // If parameters required for Keystone are missing, don't use it.
327 return; 330 return;
328 } 331 }
329 332
330 NSString* channel = [infoDictionary objectForKey:kChannelKey]; 333 NSString* channel = [infoDictionary objectForKey:kChannelKey];
331 // The stable channel has no tag. If updating to stable, remove the 334 // The stable channel has no tag. If updating to stable, remove the
332 // dev and beta tags since we've been "promoted". 335 // dev and beta tags since we've been "promoted".
333 if (channel == nil) 336 if (channel == nil)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 - (NSString*)appInfoPlistPath { 478 - (NSString*)appInfoPlistPath {
476 // NSBundle ought to have a way to access this path directly, but it 479 // NSBundle ought to have a way to access this path directly, but it
477 // doesn't. 480 // doesn't.
478 return [[appPath_ stringByAppendingPathComponent:@"Contents"] 481 return [[appPath_ stringByAppendingPathComponent:@"Contents"]
479 stringByAppendingPathComponent:@"Info.plist"]; 482 stringByAppendingPathComponent:@"Info.plist"];
480 } 483 }
481 484
482 - (NSDictionary*)keystoneParameters { 485 - (NSDictionary*)keystoneParameters {
483 NSNumber* xcType = [NSNumber numberWithInt:kKSPathExistenceChecker]; 486 NSNumber* xcType = [NSNumber numberWithInt:kKSPathExistenceChecker];
484 NSNumber* preserveTTToken = [NSNumber numberWithBool:YES]; 487 NSNumber* preserveTTToken = [NSNumber numberWithBool:YES];
485 NSString* tagPath = [self appInfoPlistPath]; 488 NSString* appInfoPlistPath = [self appInfoPlistPath];
486
487 NSString* brandKey = kBrandKey; 489 NSString* brandKey = kBrandKey;
488 NSString* brandPath = [self brandFilePath]; 490 NSString* brandPath = [self brandFilePath];
489 491
490 if ([brandPath length] == 0) { 492 if ([brandPath length] == 0) {
491 // Brand path and brand key must be cleared together or ksadmin seems 493 // Brand path and brand key must be cleared together or ksadmin seems
492 // to throw an error. 494 // to throw an error.
493 brandKey = @""; 495 brandKey = @"";
494 } 496 }
495 497
496 return [NSDictionary dictionaryWithObjectsAndKeys: 498 return [NSDictionary dictionaryWithObjectsAndKeys:
497 version_, KSRegistrationVersionKey, 499 version_, KSRegistrationVersionKey,
500 appInfoPlistPath, KSRegistrationVersionPathKey,
501 kVersionKey, KSRegistrationVersionKeyKey,
498 xcType, KSRegistrationExistenceCheckerTypeKey, 502 xcType, KSRegistrationExistenceCheckerTypeKey,
499 appPath_, KSRegistrationExistenceCheckerStringKey, 503 appPath_, KSRegistrationExistenceCheckerStringKey,
500 url_, KSRegistrationServerURLStringKey, 504 url_, KSRegistrationServerURLStringKey,
501 preserveTTToken, KSRegistrationPreserveTrustedTesterTokenKey, 505 preserveTTToken, KSRegistrationPreserveTrustedTesterTokenKey,
502 channel_, KSRegistrationTagKey, 506 channel_, KSRegistrationTagKey,
503 tagPath, KSRegistrationTagPathKey, 507 appInfoPlistPath, KSRegistrationTagPathKey,
504 kChannelKey, KSRegistrationTagKeyKey, 508 kChannelKey, KSRegistrationTagKeyKey,
505 brandPath, KSRegistrationBrandPathKey, 509 brandPath, KSRegistrationBrandPathKey,
506 brandKey, KSRegistrationBrandKeyKey, 510 brandKey, KSRegistrationBrandKeyKey,
507 nil]; 511 nil];
508 } 512 }
509 513
510 - (void)registerWithKeystone { 514 - (void)registerWithKeystone {
511 [self updateStatus:kAutoupdateRegistering version:nil]; 515 [self updateStatus:kAutoupdateRegistering version:nil];
512 516
513 NSDictionary* parameters = [self keystoneParameters]; 517 NSDictionary* parameters = [self keystoneParameters];
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 // synchronous too, and this operation needs to happen before that one. 824 // synchronous too, and this operation needs to happen before that one.
821 // 825 //
822 // TODO(mark): Make asynchronous. That only makes sense if the promotion 826 // TODO(mark): Make asynchronous. That only makes sense if the promotion
823 // operation itself is asynchronous too. http://b/2290009. Hopefully, 827 // operation itself is asynchronous too. http://b/2290009. Hopefully,
824 // the Keystone promotion code will just be changed to do what preflight 828 // the Keystone promotion code will just be changed to do what preflight
825 // now does, and then the preflight script can be removed instead. 829 // now does, and then the preflight script can be removed instead.
826 // However, preflight operation (and promotion) should only be asynchronous 830 // However, preflight operation (and promotion) should only be asynchronous
827 // if the synchronous parameter is NO. 831 // if the synchronous parameter is NO.
828 NSString* preflightPath = 832 NSString* preflightPath =
829 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_preflight" 833 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_preflight"
830 ofType:@"sh"]; 834 ofType:@"sh"];
831 const char* preflightPathC = [preflightPath fileSystemRepresentation]; 835 const char* preflightPathC = [preflightPath fileSystemRepresentation];
832 const char* userBrandFile = NULL; 836 const char* userBrandFile = NULL;
833 const char* systemBrandFile = NULL; 837 const char* systemBrandFile = NULL;
834 if (brandFileType_ == kBrandFileTypeUser) { 838 if (brandFileType_ == kBrandFileTypeUser) {
835 // Running with user level brand file, promote to the system level. 839 // Running with user level brand file, promote to the system level.
836 userBrandFile = [UserBrandFilePath() fileSystemRepresentation]; 840 userBrandFile = [UserBrandFilePath() fileSystemRepresentation];
837 systemBrandFile = [SystemBrandFilePath() fileSystemRepresentation]; 841 systemBrandFile = [SystemBrandFilePath() fileSystemRepresentation];
838 } 842 }
839 const char* arguments[] = {userBrandFile, systemBrandFile, NULL}; 843 const char* arguments[] = {userBrandFile, systemBrandFile, NULL};
840 844
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 910
907 - (void)changePermissionsForPromotionAsync { 911 - (void)changePermissionsForPromotionAsync {
908 // NSBundle is not documented as being thread-safe. Do NSBundle operations 912 // NSBundle is not documented as being thread-safe. Do NSBundle operations
909 // on the main thread before jumping over to a WorkerPool-managed 913 // on the main thread before jumping over to a WorkerPool-managed
910 // thread to run the tool. 914 // thread to run the tool.
911 DCHECK([NSThread isMainThread]); 915 DCHECK([NSThread isMainThread]);
912 916
913 SEL selector = @selector(changePermissionsForPromotionWithTool:); 917 SEL selector = @selector(changePermissionsForPromotionWithTool:);
914 NSString* toolPath = 918 NSString* toolPath =
915 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_postflight" 919 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_postflight"
916 ofType:@"sh"]; 920 ofType:@"sh"];
917 921
918 PerformBridge::PostPerform(self, selector, toolPath); 922 PerformBridge::PostPerform(self, selector, toolPath);
919 } 923 }
920 924
921 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath { 925 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath {
922 const char* toolPathC = [toolPath fileSystemRepresentation]; 926 const char* toolPathC = [toolPath fileSystemRepresentation];
923 927
924 const char* appPathC = [appPath_ fileSystemRepresentation]; 928 const char* appPathC = [appPath_ fileSystemRepresentation];
925 const char* arguments[] = {appPathC, NULL}; 929 const char* arguments[] = {appPathC, NULL};
926 930
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 return [KeystoneGlue defaultKeystoneGlue] != nil; 969 return [KeystoneGlue defaultKeystoneGlue] != nil;
966 } 970 }
967 971
968 string16 CurrentlyInstalledVersion() { 972 string16 CurrentlyInstalledVersion() {
969 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; 973 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
970 NSString* version = [keystoneGlue currentlyInstalledVersion]; 974 NSString* version = [keystoneGlue currentlyInstalledVersion];
971 return base::SysNSStringToUTF16(version); 975 return base::SysNSStringToUTF16(version);
972 } 976 }
973 977
974 } // namespace keystone_glue 978 } // namespace keystone_glue
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698