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 { |