summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/keystone_glue.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 02:09:40 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 02:09:40 +0000
commit55652a0ce6b265034edf06b0b413a03c105cf673 (patch)
treeb42d85e6c2a14104e0a88b882e58bf04b6ff23a8 /chrome/browser/cocoa/keystone_glue.mm
parent44ba8b4dfbaf1d436d23c52a7d8194afd3f21004 (diff)
downloadchromium_src-55652a0ce6b265034edf06b0b413a03c105cf673.zip
chromium_src-55652a0ce6b265034edf06b0b413a03c105cf673.tar.gz
chromium_src-55652a0ce6b265034edf06b0b413a03c105cf673.tar.bz2
Adapt Chrome to use KeystoneRegistration 1.0.7.1306. Use "tag path" and "tag
key" to direct Keystone to use a tag stored in the application as opposed to in its ticket. BUG=30730 TEST= - ksadmin --print-ticket --productid com.google.Chrome should show tagPath pointing to GC.app/Contents/Info.plist, and tagKey of KSChannelID; - ksadmin --print-tag --productid com.google.Chrome should show the value of the KSChannelID key in GC.app/Contents/Info.plist; this should be the tag that is used for auto-updates The above steps should be validated after the following operations: - launching Chrome when on a user ticket, - promoting Chrome from a user ticket to a system ticket, and - when a Chrome update is applied (using this version of keystone_install.sh) when on either a user or a system ticket. The tagPath and tagKey will NOT be set when launching Chrome on a system (promoted) ticket, but they WILL be set when the ticket is initially promoted and also when an update is applied using this version of keystone_install.sh. Review URL: http://codereview.chromium.org/506061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/keystone_glue.mm')
-rw-r--r--chrome/browser/cocoa/keystone_glue.mm94
1 files changed, 60 insertions, 34 deletions
diff --git a/chrome/browser/cocoa/keystone_glue.mm b/chrome/browser/cocoa/keystone_glue.mm
index 3ef10bc..468eca90 100644
--- a/chrome/browser/cocoa/keystone_glue.mm
+++ b/chrome/browser/cocoa/keystone_glue.mm
@@ -32,6 +32,15 @@ typedef enum {
kKSRegistrationDontKnowWhatKindOfTicket,
} KSRegistrationTicketType;
+NSString* KSRegistrationVersionKey = @"Version";
+NSString* KSRegistrationExistenceCheckerTypeKey = @"ExistenceCheckerType";
+NSString* KSRegistrationExistenceCheckerStringKey = @"ExistenceCheckerString";
+NSString* KSRegistrationServerURLStringKey = @"URLString";
+NSString* KSRegistrationPreserveTrustedTesterTokenKey = @"PreserveTTT";
+NSString* KSRegistrationTagKey = @"Tag";
+NSString* KSRegistrationTagPathKey = @"TagPath";
+NSString* KSRegistrationTagKeyKey = @"TagKey";
+
NSString *KSRegistrationDidCompleteNotification =
@"KSRegistrationDidCompleteNotification";
NSString *KSRegistrationPromotionDidCompleteNotification =
@@ -40,7 +49,6 @@ NSString *KSRegistrationPromotionDidCompleteNotification =
NSString *KSRegistrationCheckForUpdateNotification =
@"KSRegistrationCheckForUpdateNotification";
NSString *KSRegistrationStatusKey = @"Status";
-NSString *KSRegistrationVersionKey = @"Version";
NSString *KSRegistrationUpdateCheckErrorKey = @"Error";
NSString *KSRegistrationStartUpdateNotification =
@@ -57,20 +65,10 @@ NSString *KSRegistrationRemoveExistingTag = @"";
+ (id)registrationWithProductID:(NSString*)productID;
-- (BOOL)registerWithVersion:(NSString*)version
- existenceCheckerType:(KSExistenceCheckerType)xctype
- existenceCheckerString:(NSString*)xc
- serverURLString:(NSString*)serverURLString
- preserveTTToken:(BOOL)preserveToken
- tag:(NSString*)tag;
-
-- (BOOL)promoteWithVersion:(NSString*)version
- existenceCheckerType:(KSExistenceCheckerType)xctype
- existenceCheckerString:(NSString*)xc
- serverURLString:(NSString*)serverURLString
- preserveTTToken:(BOOL)preserveToken
- tag:(NSString*)tag
- authorization:(AuthorizationRef)authorization;
+- (BOOL)registerWithParameters:(NSDictionary*)args;
+
+- (BOOL)promoteWithParameters:(NSDictionary*)args
+ authorization:(AuthorizationRef)authorization;
- (void)setActive;
- (void)checkForUpdate;
@@ -81,6 +79,14 @@ NSString *KSRegistrationRemoveExistingTag = @"";
@interface KeystoneGlue(Private)
+// Returns the path to the application's Info.plist file. This returns the
+// outer application bundle's Info.plist, not the framework's Info.plist.
+- (NSString*)appInfoPlistPath;
+
+// Returns a dictionary containing parameters to be used for a KSRegistration
+// -registerWithParameters: or -promoteWithParameters:authorization: call.
+- (NSDictionary*)keystoneParameters;
+
// Called when Keystone registration completes.
- (void)registrationComplete:(NSNotification*)notification;
@@ -145,6 +151,12 @@ const NSString* const kAutoupdateStatusNotification =
const NSString* const kAutoupdateStatusStatus = @"status";
const NSString* const kAutoupdateStatusVersion = @"version";
+namespace {
+
+const NSString* const kChannelKey = @"KSChannelID";
+
+} // namespace
+
@implementation KeystoneGlue
+ (id)defaultKeystoneGlue {
@@ -233,7 +245,7 @@ const NSString* const kAutoupdateStatusVersion = @"version";
return;
}
- NSString* channel = [infoDictionary objectForKey:@"KSChannelID"];
+ NSString* channel = [infoDictionary objectForKey:kChannelKey];
// The stable channel has no tag. If updating to stable, remove the
// dev and beta tags since we've been "promoted".
if (channel == nil)
@@ -268,15 +280,35 @@ const NSString* const kAutoupdateStatusVersion = @"version";
return YES;
}
+- (NSString*)appInfoPlistPath {
+ // NSBundle ought to have a way to access this path directly, but it
+ // doesn't.
+ return [[appPath_ stringByAppendingPathComponent:@"Contents"]
+ stringByAppendingPathComponent:@"Info.plist"];
+}
+
+- (NSDictionary*)keystoneParameters {
+ NSNumber* xcType = [NSNumber numberWithInt:kKSPathExistenceChecker];
+ NSNumber* preserveTTToken = [NSNumber numberWithBool:YES];
+ NSString* tagPath = [self appInfoPlistPath];
+
+ return [NSDictionary dictionaryWithObjectsAndKeys:
+ version_, KSRegistrationVersionKey,
+ xcType, KSRegistrationExistenceCheckerTypeKey,
+ appPath_, KSRegistrationExistenceCheckerStringKey,
+ url_, KSRegistrationServerURLStringKey,
+ preserveTTToken, KSRegistrationPreserveTrustedTesterTokenKey,
+ channel_, KSRegistrationTagKey,
+ tagPath, KSRegistrationTagPathKey,
+ kChannelKey, KSRegistrationTagKeyKey,
+ nil];
+}
+
- (void)registerWithKeystone {
[self updateStatus:kAutoupdateRegistering version:nil];
- if (![registration_ registerWithVersion:version_
- existenceCheckerType:kKSPathExistenceChecker
- existenceCheckerString:appPath_
- serverURLString:url_
- preserveTTToken:YES
- tag:channel_]) {
+ NSDictionary* parameters = [self keystoneParameters];
+ if (![registration_ registerWithParameters:parameters]) {
[self updateStatus:kAutoupdateRegisterFailed version:nil];
return;
}
@@ -398,9 +430,7 @@ const NSString* const kAutoupdateStatusVersion = @"version";
- (void)determineUpdateStatus {
DCHECK(![NSThread isMainThread]);
- NSString* appInfoPlistPath =
- [[appPath_ stringByAppendingPathComponent:@"Contents"]
- stringByAppendingPathComponent:@"Info.plist"];
+ NSString* appInfoPlistPath = [self appInfoPlistPath];
NSDictionary* infoPlist =
[NSDictionary dictionaryWithContentsOfFile:appInfoPlistPath];
NSString* version = [infoPlist objectForKey:@"CFBundleShortVersionString"];
@@ -609,8 +639,8 @@ const NSString* const kAutoupdateStatusVersion = @"version";
// causes http://b/2289908, which this workaround addresses.
//
// This is run synchronously, which isn't optimal, but
- // -[KSRegistration promoteWithVersion:...] is currently synchronous too,
- // and this operation needs to happen before that one.
+ // -[KSRegistration promoteWithParameters:authorization:] is currently
+ // synchronous too, and this operation needs to happen before that one.
//
// TODO(mark): Make asynchronous. That only makes sense if the promotion
// operation itself is asynchronous too. http://b/2290009. Hopefully,
@@ -647,13 +677,9 @@ const NSString* const kAutoupdateStatusVersion = @"version";
// call.
authorization_.swap(authorization);
- if (![registration_ promoteWithVersion:version_
- existenceCheckerType:kKSPathExistenceChecker
- existenceCheckerString:appPath_
- serverURLString:url_
- preserveTTToken:YES
- tag:channel_
- authorization:authorization_]) {
+ NSDictionary* parameters = [self keystoneParameters];
+ if (![registration_ promoteWithParameters:parameters
+ authorization:authorization_]) {
[self updateStatus:kAutoupdatePromoteFailed version:nil];
authorization_.reset();
return;