summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_modal_dialog_mac.mm
diff options
context:
space:
mode:
authorfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-22 22:08:51 +0000
committerfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-22 22:08:51 +0000
commit7c0d9cb3bae28fb0c91a25076b4aec4413ea4c44 (patch)
tree966852aa1d3d824735c2ed3b04afc58c7a2e4c42 /chrome/browser/app_modal_dialog_mac.mm
parent753e9197e646adb1904e5d564a66454ea22a270b (diff)
downloadchromium_src-7c0d9cb3bae28fb0c91a25076b4aec4413ea4c44.zip
chromium_src-7c0d9cb3bae28fb0c91a25076b4aec4413ea4c44.tar.gz
chromium_src-7c0d9cb3bae28fb0c91a25076b4aec4413ea4c44.tar.bz2
Fix js alert crasher when window is closed by js
There was a problem with pages that call window.close() then immediately open a js alert. The problem was that the TabContents would get destroyed, but the alert would stick around, and when you closed the alert, it would try to call back to the tab contents' js, crashing chrome. The other OSs got around this by closing the alert immediately, but mac didn't implement the CloseModalDialog method. This CL implements that. BUG=29580 TEST=Run the html attached to the bug Review URL: http://codereview.chromium.org/549126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_modal_dialog_mac.mm')
-rw-r--r--chrome/browser/app_modal_dialog_mac.mm13
1 files changed, 12 insertions, 1 deletions
diff --git a/chrome/browser/app_modal_dialog_mac.mm b/chrome/browser/app_modal_dialog_mac.mm
index c0343be..3b64a87 100644
--- a/chrome/browser/app_modal_dialog_mac.mm
+++ b/chrome/browser/app_modal_dialog_mac.mm
@@ -70,6 +70,13 @@
bridge->OnCancel();
break;
}
+ case NSRunStoppedResponse: { // Window was closed underneath us
+ // Need to call OnCancel() because there is some cleanup that needs
+ // to be done. It won't call back to the javascript since the
+ // AppModalDialog knows that the TabContents was destroyed.
+ bridge->OnCancel();
+ break;
+ }
default: {
NOTREACHED();
}
@@ -117,6 +124,7 @@ void AppModalDialog::CreateAndShowDialog() {
// Show the modal dialog.
NSAlert* alert = [helper alert];
+ dialog_ = alert;
NSTextField* field = nil;
if (text_field) {
field = [helper textField];
@@ -149,7 +157,10 @@ void AppModalDialog::ActivateModalDialog() {
}
void AppModalDialog::CloseModalDialog() {
- NOTIMPLEMENTED();
+ NSAlert* alert = dialog_;
+ DCHECK([alert isKindOfClass:[NSAlert class]]);
+ [NSApp endSheet:[alert window]];
+ dialog_ = nil;
}
int AppModalDialog::GetDialogButtons() {