Commit 50fe9d98 authored by mark@chromium.org's avatar mark@chromium.org

Make KeystoneGlue less antisocial.

Remove -clearRecentStatus which really tied KeystoneGlue too closely to
AboutWindowController.  If KeystoneGlue ever wound up with any other clients,
this relationship would have been harmful.  AboutWindowController now
maintains a static variable to handle what -clearRecentStatus had been used
for.

Remove -releaseDefaultKeystoneGlue, which was only intended to be used for
testing, as a workaround for test flake.  The test flake has been removed.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/333049

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30215 0039d316-1c4b-4281-b951-d872f2087c98
parent b2ea7062
...@@ -86,9 +86,6 @@ extern const NSString* const kAutoupdateStatusVersion; ...@@ -86,9 +86,6 @@ extern const NSString* const kAutoupdateStatusVersion;
// Accessor for recentNotification_. Returns an autoreleased NSNotification. // Accessor for recentNotification_. Returns an autoreleased NSNotification.
- (NSNotification*)recentNotification; - (NSNotification*)recentNotification;
// Clears the saved recentNotification_.
- (void)clearRecentNotification;
// Accessor for the kAutoupdateStatusStatus field of recentNotification_'s // Accessor for the kAutoupdateStatusStatus field of recentNotification_'s
// userInfo dictionary. // userInfo dictionary.
- (AutoupdateStatus)recentStatus; - (AutoupdateStatus)recentStatus;
...@@ -101,11 +98,6 @@ extern const NSString* const kAutoupdateStatusVersion; ...@@ -101,11 +98,6 @@ extern const NSString* const kAutoupdateStatusVersion;
@interface KeystoneGlue(ExposedForTesting) @interface KeystoneGlue(ExposedForTesting)
// Release the shared instance. Use this in tests to reset the shared
// instance in case strange things are done to it for testing purposes. Never
// call this from non-test code.
+ (void)releaseDefaultKeystoneGlue;
// Load any params we need for configuring Keystone. // Load any params we need for configuring Keystone.
- (void)loadParameters; - (void)loadParameters;
......
...@@ -110,11 +110,6 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked ...@@ -110,11 +110,6 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
return sDefaultKeystoneGlue; return sDefaultKeystoneGlue;
} }
+ (void)releaseDefaultKeystoneGlue {
[sDefaultKeystoneGlue release];
sDefaultKeystoneGlue = nil;
}
- (id)init { - (id)init {
if ((self = [super init])) { if ((self = [super init])) {
NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
...@@ -395,10 +390,6 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked ...@@ -395,10 +390,6 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
return [[recentNotification_ retain] autorelease]; return [[recentNotification_ retain] autorelease];
} }
- (void)clearRecentNotification {
recentNotification_.reset(nil);
}
- (AutoupdateStatus)recentStatus { - (AutoupdateStatus)recentStatus {
NSDictionary* dictionary = [recentNotification_ userInfo]; NSDictionary* dictionary = [recentNotification_ userInfo];
return static_cast<AutoupdateStatus>( return static_cast<AutoupdateStatus>(
......
...@@ -150,16 +150,12 @@ TEST_F(KeystoneGlueTest, BasicGlobalCreate) { ...@@ -150,16 +150,12 @@ TEST_F(KeystoneGlueTest, BasicGlobalCreate) {
Method loadMethod_ = class_getInstanceMethod([KeystoneGlue class], lks); Method loadMethod_ = class_getInstanceMethod([KeystoneGlue class], lks);
method_setImplementation(loadMethod_, newLoadImp_); method_setImplementation(loadMethod_, newLoadImp_);
// Dump any existing KeystoneGlue shared instance so that a new one can be
// created with the mocked methods.
[KeystoneGlue releaseDefaultKeystoneGlue];
KeystoneGlue *glue = [KeystoneGlue defaultKeystoneGlue]; KeystoneGlue *glue = [KeystoneGlue defaultKeystoneGlue];
ASSERT_TRUE(glue); ASSERT_TRUE(glue);
// Fix back up the class to the way we found it. // Fix back up the class to the way we found it.
method_setImplementation(infoMethod_, oldInfoImp_); method_setImplementation(infoMethod_, oldInfoImp_);
method_setImplementation(loadMethod_, oldLoadImp_); method_setImplementation(loadMethod_, oldLoadImp_);
[KeystoneGlue releaseDefaultKeystoneGlue];
} }
TEST_F(KeystoneGlueTest, BasicUse) { TEST_F(KeystoneGlueTest, BasicUse) {
......
...@@ -96,6 +96,15 @@ const NSString* const kUserClosedAboutNotification = ...@@ -96,6 +96,15 @@ const NSString* const kUserClosedAboutNotification =
[super dealloc]; [super dealloc];
} }
// YES when an About box is currently showing the kAutoupdateInstallFailed
// status, or if no About box is visible, if the most recent About box to be
// closed was closed while showing this status. When an About box opens, if
// the recent status is kAutoupdateInstallFailed and
// recentShownInstallFailedStatus is NO, the failure needs to be shown instead
// of launching a new update check. recentShownInstallFailedStatus is
// maintained by -updateStatus:.
static BOOL recentShownInstallFailedStatus = NO;
- (void)awakeFromNib { - (void)awakeFromNib {
NSBundle* bundle = mac_util::MainAppBundle(); NSBundle* bundle = mac_util::MainAppBundle();
NSString* chromeVersion = NSString* chromeVersion =
...@@ -142,7 +151,8 @@ const NSString* const kUserClosedAboutNotification = ...@@ -142,7 +151,8 @@ const NSString* const kUserClosedAboutNotification =
CGFloat updateShift; CGFloat updateShift;
if (keystoneGlue) { if (keystoneGlue) {
if ([keystoneGlue asyncOperationPending] || if ([keystoneGlue asyncOperationPending] ||
[keystoneGlue recentStatus] == kAutoupdateInstallFailed) { ([keystoneGlue recentStatus] == kAutoupdateInstallFailed &&
!recentShownInstallFailedStatus)) {
// If an asynchronous update operation is currently pending, such as a // If an asynchronous update operation is currently pending, such as a
// check for updates or an update installation attempt, set the status // check for updates or an update installation attempt, set the status
// up correspondingly without launching a new update check. // up correspondingly without launching a new update check.
...@@ -235,6 +245,8 @@ const NSString* const kUserClosedAboutNotification = ...@@ -235,6 +245,8 @@ const NSString* const kUserClosedAboutNotification =
} }
- (void)updateStatus:(NSNotification*)notification { - (void)updateStatus:(NSNotification*)notification {
recentShownInstallFailedStatus = NO;
NSDictionary* dictionary = [notification userInfo]; NSDictionary* dictionary = [notification userInfo];
AutoupdateStatus status = static_cast<AutoupdateStatus>( AutoupdateStatus status = static_cast<AutoupdateStatus>(
[[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
...@@ -271,7 +283,7 @@ const NSString* const kUserClosedAboutNotification = ...@@ -271,7 +283,7 @@ const NSString* const kUserClosedAboutNotification =
break; break;
case kAutoupdateInstalling: case kAutoupdateInstalling:
// Don't let someone click "Update Now" twice. // Don't let anyone click "Update Now" twice.
[updateNowButton_ setEnabled:NO]; [updateNowButton_ setEnabled:NO];
throbber = true; throbber = true;
...@@ -303,11 +315,7 @@ const NSString* const kUserClosedAboutNotification = ...@@ -303,11 +315,7 @@ const NSString* const kUserClosedAboutNotification =
break; break;
case kAutoupdateInstallFailed: case kAutoupdateInstallFailed:
// Since the installation failure will now be displayed in an About box, recentShownInstallFailedStatus = YES;
// the saved state can be cleared. If the About box is closed and then
// reopened, this will let it start out with a clean slate and not be
// affected by past failures.
[[KeystoneGlue defaultKeystoneGlue] clearRecentNotification];
// Allow another chance. // Allow another chance.
[updateNowButton_ setEnabled:YES]; [updateNowButton_ setEnabled:YES];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment