OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "KeystoneGlue.h" | 5 #import "KeystoneGlue.h" |
6 | 6 |
7 // Provide declarations of the Keystone registration bits needed here. From | 7 // Provide declarations of the Keystone registration bits needed here. From |
8 // KSRegistration.h. | 8 // KSRegistration.h. |
9 typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType; | 9 typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType; |
10 @interface KSRegistration : NSObject | 10 @interface KSRegistration : NSObject |
11 + (id)registrationWithProductID:(NSString*)productID; | 11 + (id)registrationWithProductID:(NSString*)productID; |
12 - (BOOL)registerWithVersion:(NSString*)version | 12 - (BOOL)registerWithVersion:(NSString*)version |
13 existenceCheckerType:(KSExistenceCheckerType)xctype | 13 existenceCheckerType:(KSExistenceCheckerType)xctype |
14 existenceCheckerString:(NSString*)xc | 14 existenceCheckerString:(NSString*)xc |
15 serverURLString:(NSString*)serverURLString; | 15 serverURLString:(NSString*)serverURLString; |
16 - (void)setActive; | 16 - (void)setActive; |
17 @end | 17 @end |
18 | 18 |
19 @implementation KeystoneGlue | 19 @implementation KeystoneGlue |
20 | 20 |
| 21 // TODO(mmentovai): Determine if the app is writable, and don't register for |
| 22 // updates if not - but keep the periodic activity pings. |
21 + (void)registerWithKeystone { | 23 + (void)registerWithKeystone { |
22 // Figure out who we are. | 24 // Figure out who we are. |
23 NSBundle* mainBundle = [NSBundle mainBundle]; | 25 NSBundle* mainBundle = [NSBundle mainBundle]; |
24 NSString* bundleIdentifier = [mainBundle bundleIdentifier]; | 26 NSString* bundleIdentifier = [mainBundle bundleIdentifier]; |
25 NSDictionary* infoDictionary = [mainBundle infoDictionary]; | 27 NSDictionary* infoDictionary = [mainBundle infoDictionary]; |
26 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; | 28 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; |
27 NSString* version = [infoDictionary objectForKey:(id)kCFBundleVersionKey]; | 29 // TODO(mmentovai): The svn version serves our purposes for now, but it will |
| 30 // likely be replaced. The key problem is that it does not monotonically |
| 31 // increase for releases when considering svn branches and tags. For the |
| 32 // purposes of TestShell, though, which will likely only ever survive in |
| 33 // auto-updatable form in builds straight from the trunk, this is fine. |
| 34 NSString* version = [infoDictionary objectForKey:@"SVNRevision"]; |
28 if (!bundleIdentifier || !url || !version) { | 35 if (!bundleIdentifier || !url || !version) { |
29 // If parameters required for Keystone are missing, don't use it. | 36 // If parameters required for Keystone are missing, don't use it. |
30 return; | 37 return; |
31 } | 38 } |
32 | 39 |
33 // Load the KeystoneRegistration framework bundle. | 40 // Load the KeystoneRegistration framework bundle. |
34 NSString* ksrPath = | 41 NSString* ksrPath = |
35 [[mainBundle privateFrameworksPath] | 42 [[mainBundle privateFrameworksPath] |
36 stringByAppendingPathComponent:@"KeystoneRegistration.framework"]; | 43 stringByAppendingPathComponent:@"KeystoneRegistration.framework"]; |
37 NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath]; | 44 NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath]; |
(...skipping 24 matching lines...) Expand all Loading... |
62 userInfo:ksr | 69 userInfo:ksr |
63 repeats:YES]; | 70 repeats:YES]; |
64 } | 71 } |
65 | 72 |
66 + (void)markActive:(NSTimer*)timer { | 73 + (void)markActive:(NSTimer*)timer { |
67 KSRegistration* ksr = [timer userInfo]; | 74 KSRegistration* ksr = [timer userInfo]; |
68 [ksr setActive]; | 75 [ksr setActive]; |
69 } | 76 } |
70 | 77 |
71 @end | 78 @end |
OLD | NEW |