summaryrefslogtreecommitdiffstats
path: root/chrome/app
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 21:33:32 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 21:33:32 +0000
commitab5704c7e77a7ac38d26c44d9226eda2223903e9 (patch)
treee3e2ebc2f5005482b77c122338ae34e6f2a9b4b4 /chrome/app
parent49d8436a2b84d7bd90fc76c17b723ad5c89772a7 (diff)
downloadchromium_src-ab5704c7e77a7ac38d26c44d9226eda2223903e9.zip
chromium_src-ab5704c7e77a7ac38d26c44d9226eda2223903e9.tar.gz
chromium_src-ab5704c7e77a7ac38d26c44d9226eda2223903e9.tar.bz2
Make the About box display existing pending operations instead of firing off
a new update check even when an existing update check or installation attempt is in progress. Remove the check that validates that the Update button is disabled after being clicked. This test has become very fragile now that the Update button reliably enables itself as soon as an update installation attempt fails. BUG=13165 TEST=Get the About box to offer you the opportunity to install an update. Click "Install Now". Close the About box and quickly reopen it. The update status should be "Installing new version..." and not "Checking for updates..." Review URL: http://codereview.chromium.org/339010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r--chrome/app/keystone_glue.h18
-rw-r--r--chrome/app/keystone_glue.mm19
2 files changed, 34 insertions, 3 deletions
diff --git a/chrome/app/keystone_glue.h b/chrome/app/keystone_glue.h
index f8d2a53..604e4e2 100644
--- a/chrome/app/keystone_glue.h
+++ b/chrome/app/keystone_glue.h
@@ -11,10 +11,14 @@
// Possible outcomes of -checkForUpdate and -installUpdate. A version may
// accompany some of these, but beware: a version is never required. For
// statuses that can be accompanied by a version, the comment indicates what
-// version is referenced.
+// version is referenced. A notification posted containing an asynchronous
+// status will always be followed by a notification with a terminal status.
enum AutoupdateStatus {
- kAutoupdateCurrent = 0, // version of the running application
+ kAutoupdateNone = 0, // no version (initial state only)
+ kAutoupdateChecking, // no version (asynchronous operation in progress)
+ kAutoupdateCurrent, // version of the running application
kAutoupdateAvailable, // version of the update that is available
+ kAutoupdateInstalling, // no version (asynchronous operation in progress)
kAutoupdateInstalled, // version of the update that was installed
kAutoupdateCheckFailed, // no version
kAutoupdateInstallFailed // no version
@@ -75,7 +79,7 @@ extern const NSString* const kAutoupdateStatusVersion;
// -checkForUpdate launches a check for updates, and -installUpdate begins
// installing an available update. For each, status will be communicated via
// a kAutoupdateStatusNotification notification, and will also be available
-// through -recentUpdateStatus.
+// through -recentNotification.
- (void)checkForUpdate;
- (void)installUpdate;
@@ -85,6 +89,14 @@ extern const NSString* const kAutoupdateStatusVersion;
// Clears the saved recentNotification_.
- (void)clearRecentNotification;
+// Accessor for the kAutoupdateStatusStatus field of recentNotification_'s
+// userInfo dictionary.
+- (AutoupdateStatus)recentStatus;
+
+// Returns YES if an asynchronous operation is pending: if an update check or
+// installation attempt is currently in progress.
+- (BOOL)asyncOperationPending;
+
@end // @interface KeystoneGlue
@interface KeystoneGlue(ExposedForTesting)
diff --git a/chrome/app/keystone_glue.mm b/chrome/app/keystone_glue.mm
index 689cfdb..6a91b9c 100644
--- a/chrome/app/keystone_glue.mm
+++ b/chrome/app/keystone_glue.mm
@@ -241,11 +241,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
}
- (void)checkForUpdate {
+ DCHECK(![self asyncOperationPending]);
+
if (!registration_) {
[self updateStatus:kAutoupdateCheckFailed version:nil];
return;
}
+ [self updateStatus:kAutoupdateChecking version:nil];
+
[registration_ checkForUpdate];
// Upon completion, KSRegistrationCheckForUpdateNotification will be posted,
@@ -271,11 +275,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
}
- (void)installUpdate {
+ DCHECK(![self asyncOperationPending]);
+
if (!registration_) {
[self updateStatus:kAutoupdateInstallFailed version:nil];
return;
}
+ [self updateStatus:kAutoupdateInstalling version:nil];
+
[registration_ startUpdate];
// Upon completion, KSRegistrationStartUpdateNotification will be posted,
@@ -391,4 +399,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
recentNotification_.reset(nil);
}
+- (AutoupdateStatus)recentStatus {
+ NSDictionary* dictionary = [recentNotification_ userInfo];
+ return static_cast<AutoupdateStatus>(
+ [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
+}
+
+- (BOOL)asyncOperationPending {
+ AutoupdateStatus status = [self recentStatus];
+ return status == kAutoupdateChecking || status == kAutoupdateInstalling;
+}
+
@end // @implementation KeystoneGlue