diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:41:26 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:41:26 +0000 |
commit | 04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf (patch) | |
tree | 9decee40b998d4db7ce5d2fd97a6d8be0b5a90da /chrome/app/keystone_glue.m | |
parent | 3f918787e1073e17439e55ed34f23ffdc31f891f (diff) | |
download | chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.zip chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.tar.gz chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.tar.bz2 |
Adapt (and move) mark@chromium.org's Keystone integration to Chromium.
Call it from the Browser. (no-op if not packaged for branding).
Add new build target "app_packaging" to package (if possible).
(app_packaging target intentionally left out of "All").
For convenience, here is the app_packaging script embedded in the xcodeproj:
PACKAGER="${PROJECT_DIR}/tools/mac/package_chrome.sh"
if [ -f "${PACKAGER}" ]; then
"${PACKAGER}"
fi
Mark, I know this is not in gyp... I am happy to have this klobbered
and redo it (in gyp) at the appropriate time.
Review URL: http://codereview.chromium.org/27293
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/keystone_glue.m')
-rw-r--r-- | chrome/app/keystone_glue.m | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/chrome/app/keystone_glue.m b/chrome/app/keystone_glue.m new file mode 100644 index 0000000..45ae1c2 --- /dev/null +++ b/chrome/app/keystone_glue.m @@ -0,0 +1,81 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "keystone_glue.h" + +// Provide declarations of the Keystone registration bits needed here. From +// KSRegistration.h. +typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType; +@interface KSRegistration : NSObject ++ (id)registrationWithProductID:(NSString*)productID; +- (BOOL)registerWithVersion:(NSString*)version + existenceCheckerType:(KSExistenceCheckerType)xctype + existenceCheckerString:(NSString*)xc + serverURLString:(NSString*)serverURLString; +- (void)setActive; +@end + +@implementation KeystoneGlue + +// TODO(mmentovai): Determine if the app is writable, and don't register for +// updates if not - but keep the periodic activity pings. ++ (void)registerWithKeystone { + // Figure out who we are. + NSBundle* mainBundle = [NSBundle mainBundle]; + NSDictionary* infoDictionary = [mainBundle infoDictionary]; + NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; + NSString* bundleIdentifier = [infoDictionary objectForKey:@"KSProductID"]; + if (bundleIdentifier == nil) { + bundleIdentifier = [mainBundle bundleIdentifier]; + } + // TODO(mmentovai): The svn version serves our purposes for now, but it will + // likely be replaced. The key problem is that it does not monotonically + // increase for releases when considering svn branches and tags. For the + // purposes of TestShell, though, which will likely only ever survive in + // auto-updatable form in builds straight from the trunk, this is fine. + NSString* version = [infoDictionary objectForKey:@"SVNRevision"]; + if (!bundleIdentifier || !url || !version) { + // If parameters required for Keystone are missing, don't use it. + return; + } + + // Load the KeystoneRegistration framework bundle. + NSString* ksrPath = + [[mainBundle privateFrameworksPath] + stringByAppendingPathComponent:@"KeystoneRegistration.framework"]; + NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath]; + [ksrBundle load]; + + // Harness the KSRegistration class. + Class ksrClass = [ksrBundle classNamed:@"KSRegistration"]; + KSRegistration* ksr = [ksrClass registrationWithProductID:bundleIdentifier]; + if (!ksr) { + // Strictly speaking, this isn't necessary, because it's harmless to send + // messages to nil. However, if there really isn't a + // KeystoneRegistration.framework or KSRegistration class, bailing out here + // avoids setting up the timer that will only be able to perform no-ops. + return; + } + + // Keystone will asynchronously handle installation and registration as + // needed. + [ksr registerWithVersion:version + existenceCheckerType:kKSPathExistenceChecker + existenceCheckerString:[mainBundle bundlePath] + serverURLString:url]; + + // Set up hourly activity pings. + [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour + target:self + selector:@selector(markActive:) + userInfo:ksr + repeats:YES]; +} + ++ (void)markActive:(NSTimer*)timer { + KSRegistration* ksr = [timer userInfo]; + [ksr setActive]; +} + +@end |