Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Unified Diff: chrome/browser/ui/cocoa/notifications/balloon_controller.mm

Issue 6327017: Fix crash when notification disappears under popup menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/notifications/balloon_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/notifications/balloon_controller.mm
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
index a9270814c96d8d0beff442769beb096ca1c55d1e..bb7023966509686483bc3667ebca663fcf9edc42 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
+++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
@@ -121,10 +121,26 @@ const int kRightMargin = 2;
[[closeButton_ cell] setHighlighted:NO];
}
+- (void)closeBalloonNow:(bool)byUser {
+ if (!balloon_)
+ return;
+ [self close];
+ if (htmlContents_.get())
+ htmlContents_->Shutdown();
+ if (balloon_)
+ balloon_->OnClose(byUser);
+ balloon_ = NULL;
+}
+
- (IBAction)optionsButtonPressed:(id)sender {
+ optionMenuIsActive_ = YES;
[NSMenu popUpContextMenu:[menuController_ menu]
withEvent:[NSApp currentEvent]
forView:optionsButton_];
+ optionMenuIsActive_ = NO;
+ if (delayedClose_) {
John Gregg 2011/01/25 02:12:42 no { } necessary, more consistent with file
+ [self closeBalloonNow: false]; // always by script.
+ }
}
- (IBAction)permissionRevoked:(id)sender {
@@ -146,14 +162,14 @@ const int kRightMargin = 2;
}
- (void)closeBalloon:(bool)byUser {
- if (!balloon_)
+ // Keep alive while user is interacting with popup menu.
+ // Otherwise the script can close the notification and underlying balloon
+ // will be destroyed while user select a menu command.
+ if (!byUser && optionMenuIsActive_) {
+ delayedClose_ = YES;
return;
- [self close];
- if (htmlContents_.get())
- htmlContents_->Shutdown();
- if (balloon_)
- balloon_->OnClose(byUser);
- balloon_ = NULL;
+ }
+ [self closeBalloonNow: byUser];
}
- (void)updateContents {
« no previous file with comments | « chrome/browser/ui/cocoa/notifications/balloon_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698