summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mac
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 15:44:10 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 15:44:10 +0000
commita2d67740c562caea523f3650c063d75ee4c0a8ac (patch)
treed496c57a3b4d5dfd6b58989becc768b83609095c /chrome/browser/mac
parent4d99be5a3d20c3a3654f282328065f9ff54d6f39 (diff)
downloadchromium_src-a2d67740c562caea523f3650c063d75ee4c0a8ac.zip
chromium_src-a2d67740c562caea523f3650c063d75ee4c0a8ac.tar.gz
chromium_src-a2d67740c562caea523f3650c063d75ee4c0a8ac.tar.bz2
Set the Keystone Glue to the "needs promotion" state when on a system ticket
but no system Keystone is present. Fix the "needs promotion" logic in the About window to actually display the promotion button. This seems to have broken when the promotion button moved into the update block instead of being a separate block below it. BUG=100632, 100633 TEST=Per http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=1367288 put Chrome on a system Keystone ticket, run sudo /Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/Resources/install.py --uninstall and then launch Chrome. The "Google Chrome may not be able to keep itself updated." infobar should be displayed unless suppressed by "Don't ask again" or superseded by another infobar such as the default browser infobar. The About window should also display "Google Chrome may not be able to keep itself updated." (regardless of whether the infobar was suppressed) and the "Set Up Automatic Updates for All Users" button should be present and clickable. Clicking this button or the "Set up automatic updates" button in the infobar should display an authorization dialog for promotion. Upon promotion, if the About window is open, it should perform an update check, and the "Set Up Automatic Updates for All Users" button should disappear. Review URL: http://codereview.chromium.org/8318030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mac')
-rw-r--r--chrome/browser/mac/keystone_glue.h1
-rw-r--r--chrome/browser/mac/keystone_glue.mm64
2 files changed, 56 insertions, 9 deletions
diff --git a/chrome/browser/mac/keystone_glue.h b/chrome/browser/mac/keystone_glue.h
index 65bdc70..c57219b 100644
--- a/chrome/browser/mac/keystone_glue.h
+++ b/chrome/browser/mac/keystone_glue.h
@@ -35,6 +35,7 @@ enum AutoupdateStatus {
kAutoupdateCheckFailed, // no version
kAutoupdateInstallFailed, // no version
kAutoupdatePromoteFailed, // no version
+ kAutoupdateNeedsPromotion, // no version
};
// kAutoupdateStatusNotification is the name of the notification posted when
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index 9013703..b6ded95 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -158,6 +158,17 @@ class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> {
// of Keystone being used), returns NO.
- (BOOL)isUserTicket;
+// Returns YES if Keystone is definitely installed at the system level,
+// determined by the presence of an executable ksadmin program at the expected
+// system location.
+- (BOOL)isSystemKeystone;
+
+// Returns YES if on a system ticket but system Keystone is not present.
+// Returns NO otherwise. The "doomed" condition will result in the
+// registration framework appearing to have registered Chrome, but no updates
+// ever actually taking place.
+- (BOOL)isSystemTicketDoomed;
+
// Called when ticket promotion completes.
- (void)promotionComplete:(NSNotification*)notification;
@@ -490,7 +501,11 @@ NSString* const kVersionKey = @"KSVersion";
- (void)registrationComplete:(NSNotification*)notification {
NSDictionary* userInfo = [notification userInfo];
if ([[userInfo objectForKey:ksr::KSRegistrationStatusKey] boolValue]) {
- [self updateStatus:kAutoupdateRegistered version:nil];
+ if ([self isSystemTicketDoomed]) {
+ [self updateStatus:kAutoupdateNeedsPromotion version:nil];
+ } else {
+ [self updateStatus:kAutoupdateRegistered version:nil];
+ }
} else {
// Dump registration_?
[self updateStatus:kAutoupdateRegisterFailed version:nil];
@@ -669,6 +684,26 @@ NSString* const kVersionKey = @"KSVersion";
return [registration_ ticketType] == ksr::kKSRegistrationUserTicket;
}
+- (BOOL)isSystemKeystone {
+ struct stat statbuf;
+ if (stat("/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/"
+ "Contents/MacOS/ksadmin",
+ &statbuf) != 0) {
+ return NO;
+ }
+
+ if (!(statbuf.st_mode & S_IXUSR)) {
+ return NO;
+ }
+
+ return YES;
+}
+
+- (BOOL)isSystemTicketDoomed {
+ BOOL isSystemTicket = ![self isUserTicket];
+ return isSystemTicket && ![self isSystemKeystone];
+}
+
- (BOOL)isOnReadOnlyFilesystem {
const char* appPathC = [appPath_ fileSystemRepresentation];
struct statfs statfsBuf;
@@ -683,7 +718,20 @@ NSString* const kVersionKey = @"KSVersion";
}
- (BOOL)needsPromotion {
- if (![self isUserTicket] || [self isOnReadOnlyFilesystem]) {
+ // Don't promote when on a read-only filesystem.
+ if ([self isOnReadOnlyFilesystem]) {
+ return NO;
+ }
+
+ // Promotion is required when a system ticket is present but system Keystone
+ // is not.
+ if ([self isSystemTicketDoomed]) {
+ return YES;
+ }
+
+ // If on a system ticket and system Keystone is present, promotion is not
+ // required.
+ if (![self isUserTicket]) {
return NO;
}
@@ -704,17 +752,15 @@ NSString* const kVersionKey = @"KSVersion";
}
- (BOOL)wantsPromotion {
- // -needsPromotion checks these too, but this method doesn't necessarily
- // return NO just becuase -needsPromotion returns NO, so another check is
- // needed here.
- if (![self isUserTicket] || [self isOnReadOnlyFilesystem]) {
- return NO;
- }
-
if ([self needsPromotion]) {
return YES;
}
+ // These are the same unpromotable cases as in -needsPromotion.
+ if ([self isOnReadOnlyFilesystem] || ![self isUserTicket]) {
+ return NO;
+ }
+
return [appPath_ hasPrefix:@"/Applications/"];
}