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

Side by Side Diff: chrome/browser/js_modal_dialog.cc

Issue 2827029: Merge 50561 - Fix a crash when we try to close a js dialog that wasn't shown.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/375/src/
Patch Set: Created 10 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/app_modal_dialog_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/js_modal_dialog.h" 5 #include "chrome/browser/js_modal_dialog.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 #include "chrome/common/notification_type.h" 10 #include "chrome/common/notification_type.h"
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 12
13 JavaScriptAppModalDialog::JavaScriptAppModalDialog( 13 JavaScriptAppModalDialog::JavaScriptAppModalDialog(
14 JavaScriptMessageBoxClient* client, 14 JavaScriptMessageBoxClient* client,
15 const std::wstring& title, 15 const std::wstring& title,
16 int dialog_flags, 16 int dialog_flags,
17 const std::wstring& message_text, 17 const std::wstring& message_text,
18 const std::wstring& default_prompt_text, 18 const std::wstring& default_prompt_text,
19 bool display_suppress_checkbox, 19 bool display_suppress_checkbox,
20 bool is_before_unload_dialog, 20 bool is_before_unload_dialog,
21 IPC::Message* reply_msg) 21 IPC::Message* reply_msg)
22 : AppModalDialog(client->AsTabContents(), title), 22 : AppModalDialog(client->AsTabContents(), title),
23 #if defined(OS_MACOSX)
24 dialog_(NULL),
25 #endif
23 client_(client), 26 client_(client),
24 extension_host_(client->AsExtensionHost()), 27 extension_host_(client->AsExtensionHost()),
25 dialog_flags_(dialog_flags), 28 dialog_flags_(dialog_flags),
26 message_text_(message_text), 29 message_text_(message_text),
27 default_prompt_text_(default_prompt_text), 30 default_prompt_text_(default_prompt_text),
28 display_suppress_checkbox_(display_suppress_checkbox), 31 display_suppress_checkbox_(display_suppress_checkbox),
29 is_before_unload_dialog_(is_before_unload_dialog), 32 is_before_unload_dialog_(is_before_unload_dialog),
30 reply_msg_(reply_msg) { 33 reply_msg_(reply_msg) {
31 DCHECK((tab_contents_ != NULL) != (extension_host_ != NULL)); 34 DCHECK((tab_contents_ != NULL) != (extension_host_ != NULL));
32 InitNotifications(); 35 InitNotifications();
(...skipping 11 matching lines...) Expand all
44 if (NotificationType::EXTENSION_HOST_DESTROYED == type && 47 if (NotificationType::EXTENSION_HOST_DESTROYED == type &&
45 Details<ExtensionHost>(extension_host_) != details) 48 Details<ExtensionHost>(extension_host_) != details)
46 return; 49 return;
47 50
48 // If we reach here, we know the notification is relevant to us, either 51 // If we reach here, we know the notification is relevant to us, either
49 // because we're only observing applicable sources or because we passed the 52 // because we're only observing applicable sources or because we passed the
50 // check above. Both of those indicate that we should ignore this dialog. 53 // check above. Both of those indicate that we should ignore this dialog.
51 // Also clear the client, since it's now invalid. 54 // Also clear the client, since it's now invalid.
52 skip_this_dialog_ = true; 55 skip_this_dialog_ = true;
53 client_ = NULL; 56 client_ = NULL;
54 CloseModalDialog(); 57 if (dialog_)
58 CloseModalDialog();
55 } 59 }
56 60
57 void JavaScriptAppModalDialog::InitNotifications() { 61 void JavaScriptAppModalDialog::InitNotifications() {
58 // Make sure we get relevant navigation notifications so we know when our 62 // Make sure we get relevant navigation notifications so we know when our
59 // parent contents will disappear or navigate to a different page. 63 // parent contents will disappear or navigate to a different page.
60 if (tab_contents_) { 64 if (tab_contents_) {
61 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 65 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
62 Source<NavigationController>(&tab_contents_->controller())); 66 Source<NavigationController>(&tab_contents_->controller()));
63 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 67 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
64 Source<TabContents>(tab_contents_)); 68 Source<TabContents>(tab_contents_));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // state, destroying the host. http://crbug.com/29355 120 // state, destroying the host. http://crbug.com/29355
117 #if !defined(OS_MACOSX) 121 #if !defined(OS_MACOSX)
118 else if (extension_host_) 122 else if (extension_host_)
119 extension_host_->OnMessageBoxClosed(reply_msg_, false, L""); 123 extension_host_->OnMessageBoxClosed(reply_msg_, false, L"");
120 else 124 else
121 NOTREACHED(); 125 NOTREACHED();
122 #endif 126 #endif
123 } 127 }
124 AppModalDialog::Cleanup(); 128 AppModalDialog::Cleanup();
125 } 129 }
126
OLDNEW
« no previous file with comments | « chrome/browser/app_modal_dialog_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698