summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authordimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 03:07:37 +0000
committerdimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 03:07:37 +0000
commit80aa386b578497761cfcd0d84d935146c264d717 (patch)
treeaae4e0886954134b638dd1bc1ba143ce1d4b3e91 /chrome/browser/ui
parent29f97e640739f7cb62c3ae742e689dae7cbe081a (diff)
downloadchromium_src-80aa386b578497761cfcd0d84d935146c264d717.zip
chromium_src-80aa386b578497761cfcd0d84d935146c264d717.tar.gz
chromium_src-80aa386b578497761cfcd0d84d935146c264d717.tar.bz2
Fix crash when notification disappears under popup menu.
BUG=67101 Review URL: http://codereview.chromium.org/6327017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_controller.h4
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_controller.mm29
2 files changed, 26 insertions, 7 deletions
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.h b/chrome/browser/ui/cocoa/notifications/balloon_controller.h
index fadd35a..e346f42 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_controller.h
+++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.h
@@ -52,6 +52,10 @@ class NotificationOptionsMenuModel;
// The host for the renderer of the HTML contents.
scoped_ptr<BalloonViewHost> htmlContents_;
+
+ // Variables to delay close requested by script while showing modal menu.
+ BOOL optionMenuIsActive_;
+ BOOL delayedClose_;
}
// Initialize with a balloon object containing the notification data.
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
index 9b1b5a0..eef62d3 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 {