| 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 #ifndef CHROME_APP_KEYSTONE_GLUE_H_ | 5 #ifndef CHROME_BROWSER_COCOA_KEYSTONE_GLUE_H_ |
| 6 #define CHROME_APP_KEYSTONE_GLUE_H_ | 6 #define CHROME_BROWSER_COCOA_KEYSTONE_GLUE_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #import <base/scoped_nsobject.h> | 9 #import <base/scoped_nsobject.h> |
| 10 | 10 |
| 11 // Possible outcomes of -checkForUpdate and -installUpdate. A version may | 11 #include "chrome/browser/cocoa/scoped_authorizationref.h" |
| 12 // accompany some of these, but beware: a version is never required. For | 12 |
| 13 // statuses that can be accompanied by a version, the comment indicates what | 13 // Possible outcomes of various operations. A version may accompany some of |
| 14 // version is referenced. A notification posted containing an asynchronous | 14 // these, but beware: a version is never required. For statuses that can be |
| 15 // status will always be followed by a notification with a terminal status. | 15 // accompanied by a version, the comment indicates what version is referenced. |
| 16 // A notification posted containing an asynchronous status will always be |
| 17 // followed by a notification with a terminal status. |
| 16 enum AutoupdateStatus { | 18 enum AutoupdateStatus { |
| 17 kAutoupdateNone = 0, // no version (initial state only) | 19 kAutoupdateNone = 0, // no version (initial state only) |
| 18 kAutoupdateChecking, // no version (asynchronous operation in progress) | 20 kAutoupdateRegistering, // no version (asynchronous operation in progress) |
| 19 kAutoupdateCurrent, // version of the running application | 21 kAutoupdateRegistered, // no version |
| 20 kAutoupdateAvailable, // version of the update that is available | 22 kAutoupdateChecking, // no version (asynchronous operation in progress) |
| 21 kAutoupdateInstalling, // no version (asynchronous operation in progress) | 23 kAutoupdateCurrent, // version of the running application |
| 22 kAutoupdateInstalled, // version of the update that was installed | 24 kAutoupdateAvailable, // version of the update that is available |
| 23 kAutoupdateCheckFailed, // no version | 25 kAutoupdateInstalling, // no version (asynchronous operation in progress) |
| 24 kAutoupdateInstallFailed // no version | 26 kAutoupdateInstalled, // version of the update that was installed |
| 27 kAutoupdatePromoting, // no version (asynchronous operation in progress) |
| 28 kAutoupdatePromoted, // no version |
| 29 kAutoupdateRegisterFailed, // no version |
| 30 kAutoupdateCheckFailed, // no version |
| 31 kAutoupdateInstallFailed, // no version |
| 32 kAutoupdatePromoteFailed, // no version |
| 25 }; | 33 }; |
| 26 | 34 |
| 27 // kAutoupdateStatusNotification is the name of the notification posted when | 35 // kAutoupdateStatusNotification is the name of the notification posted when |
| 28 // -checkForUpdate and -installUpdate complete. This notification will be | 36 // -checkForUpdate and -installUpdate complete. This notification will be |
| 29 // sent with with its sender object set to the KeystoneGlue instance sending | 37 // sent with with its sender object set to the KeystoneGlue instance sending |
| 30 // the notification. Its userInfo dictionary will contain an AutoupdateStatus | 38 // the notification. Its userInfo dictionary will contain an AutoupdateStatus |
| 31 // value as an intValue at key kAutoupdateStatusStatus. If a version is | 39 // value as an intValue at key kAutoupdateStatusStatus. If a version is |
| 32 // available (see AutoupdateStatus), it will be present at key | 40 // available (see AutoupdateStatus), it will be present at key |
| 33 // kAutoupdateStatusVersion. | 41 // kAutoupdateStatusVersion. |
| 34 extern const NSString* const kAutoupdateStatusNotification; | 42 extern const NSString* const kAutoupdateStatusNotification; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 // requires that the KSUpdateURL key be set in the application's Info.plist, | 54 // requires that the KSUpdateURL key be set in the application's Info.plist, |
| 47 // and that it contain a string identifying the update URL to be used by | 55 // and that it contain a string identifying the update URL to be used by |
| 48 // Keystone. | 56 // Keystone. |
| 49 | 57 |
| 50 @class KSRegistration; | 58 @class KSRegistration; |
| 51 | 59 |
| 52 @interface KeystoneGlue : NSObject { | 60 @interface KeystoneGlue : NSObject { |
| 53 @protected | 61 @protected |
| 54 | 62 |
| 55 // Data for Keystone registration | 63 // Data for Keystone registration |
| 64 NSString* productID_; |
| 65 NSString* appPath_; |
| 56 NSString* url_; | 66 NSString* url_; |
| 57 NSString* productID_; | |
| 58 NSString* version_; | 67 NSString* version_; |
| 59 NSString* channel_; // Logically: Dev, Beta, or Stable. | 68 NSString* channel_; // Logically: Dev, Beta, or Stable. |
| 60 | 69 |
| 61 // And the Keystone registration itself, with the active timer | 70 // And the Keystone registration itself, with the active timer |
| 62 KSRegistration* registration_; // strong | 71 KSRegistration* registration_; // strong |
| 63 NSTimer* timer_; // strong | 72 NSTimer* timer_; // strong |
| 64 | 73 |
| 65 // The most recent kAutoupdateStatusNotification notification posted. | 74 // The most recent kAutoupdateStatusNotification notification posted. |
| 66 scoped_nsobject<NSNotification> recentNotification_; | 75 scoped_nsobject<NSNotification> recentNotification_; |
| 67 | 76 |
| 77 // The authorization object, when it needs to persist because it's being |
| 78 // carried across threads. |
| 79 scoped_AuthorizationRef authorization_; |
| 80 |
| 68 // YES if an update was ever successfully installed by -installUpdate. | 81 // YES if an update was ever successfully installed by -installUpdate. |
| 69 BOOL updateSuccessfullyInstalled_; | 82 BOOL updateSuccessfullyInstalled_; |
| 70 } | 83 } |
| 71 | 84 |
| 72 // Return the default Keystone Glue object. | 85 // Return the default Keystone Glue object. |
| 73 + (id)defaultKeystoneGlue; | 86 + (id)defaultKeystoneGlue; |
| 74 | 87 |
| 75 // Load KeystoneRegistration.framework if present, call into it to register | 88 // Load KeystoneRegistration.framework if present, call into it to register |
| 76 // with Keystone, and set up periodic activity pings. | 89 // with Keystone, and set up periodic activity pings. |
| 77 - (void)registerWithKeystone; | 90 - (void)registerWithKeystone; |
| 78 | 91 |
| 79 // -checkForUpdate launches a check for updates, and -installUpdate begins | 92 // -checkForUpdate launches a check for updates, and -installUpdate begins |
| 80 // installing an available update. For each, status will be communicated via | 93 // installing an available update. For each, status will be communicated via |
| 81 // a kAutoupdateStatusNotification notification, and will also be available | 94 // a kAutoupdateStatusNotification notification, and will also be available |
| 82 // through -recentNotification. | 95 // through -recentNotification. |
| 83 - (void)checkForUpdate; | 96 - (void)checkForUpdate; |
| 84 - (void)installUpdate; | 97 - (void)installUpdate; |
| 85 | 98 |
| 86 // Accessor for recentNotification_. Returns an autoreleased NSNotification. | 99 // Accessor for recentNotification_. Returns an autoreleased NSNotification. |
| 87 - (NSNotification*)recentNotification; | 100 - (NSNotification*)recentNotification; |
| 88 | 101 |
| 89 // Accessor for the kAutoupdateStatusStatus field of recentNotification_'s | 102 // Accessor for the kAutoupdateStatusStatus field of recentNotification_'s |
| 90 // userInfo dictionary. | 103 // userInfo dictionary. |
| 91 - (AutoupdateStatus)recentStatus; | 104 - (AutoupdateStatus)recentStatus; |
| 92 | 105 |
| 93 // Returns YES if an asynchronous operation is pending: if an update check or | 106 // Returns YES if an asynchronous operation is pending: if an update check or |
| 94 // installation attempt is currently in progress. | 107 // installation attempt is currently in progress. |
| 95 - (BOOL)asyncOperationPending; | 108 - (BOOL)asyncOperationPending; |
| 96 | 109 |
| 110 // Returns YES if the application is running from a read-only filesystem, |
| 111 // such as a disk image. |
| 112 - (BOOL)isOnReadOnlyFilesystem; |
| 113 |
| 114 // -needsPromotion is YES if the application needs its ticket promoted to |
| 115 // a system ticket. This will be YES when the application is on a user |
| 116 // ticket and determines that the current user does not have sufficient |
| 117 // permission to perform the update. |
| 118 // |
| 119 // -wantsPromotion is YES if the application wants its ticket promoted to |
| 120 // a system ticket, even if it doesn't need it as determined by |
| 121 // -needsPromotion. -wantsPromotion will always be YES if -needsPromotion is, |
| 122 // and it will additionally be YES when the application is on a user ticket |
| 123 // and appears to be installed in a system-wide location such as |
| 124 // /Applications. |
| 125 // |
| 126 // Use -needsPromotion to decide whether to show any update UI at all. If |
| 127 // it's YES, there's no sense in asking the user to "update now" because it |
| 128 // will fail given the rights and permissions involved. On the other hand, |
| 129 // when -needsPromotion is YES, the application can encourage the user to |
| 130 // promote the ticket so that updates will work properly. |
| 131 // |
| 132 // Use -wantsPromotion to decide whether to allow the user to promote. The |
| 133 // user shouldn't be nagged about promotion on the basis of -wantsPromotion, |
| 134 // but if it's YES, the user should be allowed to promote the ticket. |
| 135 - (BOOL)needsPromotion; |
| 136 - (BOOL)wantsPromotion; |
| 137 |
| 138 // Requests authorization and promotes the Keystone ticket into the system |
| 139 // store. System Keystone will be installed if necessary. |
| 140 - (void)promoteTicket; |
| 141 |
| 97 @end // @interface KeystoneGlue | 142 @end // @interface KeystoneGlue |
| 98 | 143 |
| 99 @interface KeystoneGlue(ExposedForTesting) | 144 @interface KeystoneGlue(ExposedForTesting) |
| 100 | 145 |
| 101 // Load any params we need for configuring Keystone. | 146 // Load any params we need for configuring Keystone. |
| 102 - (void)loadParameters; | 147 - (void)loadParameters; |
| 103 | 148 |
| 104 // Load the Keystone registration object. | 149 // Load the Keystone registration object. |
| 105 // Return NO on failure. | 150 // Return NO on failure. |
| 106 - (BOOL)loadKeystoneRegistration; | 151 - (BOOL)loadKeystoneRegistration; |
| 107 | 152 |
| 108 - (void)stopTimer; | 153 - (void)stopTimer; |
| 109 | 154 |
| 110 // Called when a checkForUpdate: notification completes. | 155 // Called when a checkForUpdate: notification completes. |
| 111 - (void)checkForUpdateComplete:(NSNotification*)notification; | 156 - (void)checkForUpdateComplete:(NSNotification*)notification; |
| 112 | 157 |
| 113 // Called when an installUpdate: notification completes. | 158 // Called when an installUpdate: notification completes. |
| 114 - (void)installUpdateComplete:(NSNotification*)notification; | 159 - (void)installUpdateComplete:(NSNotification*)notification; |
| 115 | 160 |
| 116 @end // @interface KeystoneGlue(ExposedForTesting) | 161 @end // @interface KeystoneGlue(ExposedForTesting) |
| 117 | 162 |
| 118 #endif // CHROME_APP_KEYSTONE_GLUE_H_ | 163 #endif // CHROME_BROWSER_COCOA_KEYSTONE_GLUE_H_ |
| OLD | NEW |