| 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..33360e9cb4364d9cb924589c5d1be9404a287c02 100644
|
| --- a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
|
| @@ -121,10 +121,25 @@ 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_)
|
| + [self closeBalloonNow: false]; // always by script.
|
| }
|
|
|
| - (IBAction)permissionRevoked:(id)sender {
|
| @@ -146,14 +161,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 {
|
|
|