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

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

Issue 2803017: Fix a crash when we try to close a js dialog that wasn't shown. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 6 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
« 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 "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/notification_service.h" 10 #include "chrome/common/notification_service.h"
(...skipping 11 matching lines...) Expand all
22 JavaScriptAppModalDialog::JavaScriptAppModalDialog( 22 JavaScriptAppModalDialog::JavaScriptAppModalDialog(
23 JavaScriptMessageBoxClient* client, 23 JavaScriptMessageBoxClient* client,
24 const std::wstring& title, 24 const std::wstring& title,
25 int dialog_flags, 25 int dialog_flags,
26 const std::wstring& message_text, 26 const std::wstring& message_text,
27 const std::wstring& default_prompt_text, 27 const std::wstring& default_prompt_text,
28 bool display_suppress_checkbox, 28 bool display_suppress_checkbox,
29 bool is_before_unload_dialog, 29 bool is_before_unload_dialog,
30 IPC::Message* reply_msg) 30 IPC::Message* reply_msg)
31 : AppModalDialog(client->AsTabContents(), title), 31 : AppModalDialog(client->AsTabContents(), title),
32 #if defined(OS_MACOSX)
33 dialog_(NULL),
34 #endif
32 client_(client), 35 client_(client),
33 extension_host_(client->AsExtensionHost()), 36 extension_host_(client->AsExtensionHost()),
34 dialog_flags_(dialog_flags), 37 dialog_flags_(dialog_flags),
35 display_suppress_checkbox_(display_suppress_checkbox), 38 display_suppress_checkbox_(display_suppress_checkbox),
36 is_before_unload_dialog_(is_before_unload_dialog), 39 is_before_unload_dialog_(is_before_unload_dialog),
37 reply_msg_(reply_msg) { 40 reply_msg_(reply_msg) {
38 // We trim the various parts of the message dialog because otherwise we can 41 // We trim the various parts of the message dialog because otherwise we can
39 // overflow the message dialog (and crash/hang the GTK+ version). 42 // overflow the message dialog (and crash/hang the GTK+ version).
40 ElideString(message_text, kMessageTextMaxSize, &message_text_); 43 ElideString(message_text, kMessageTextMaxSize, &message_text_);
41 ElideString(default_prompt_text, kDefaultPromptTextSize, 44 ElideString(default_prompt_text, kDefaultPromptTextSize,
(...skipping 15 matching lines...) Expand all
57 if (NotificationType::EXTENSION_HOST_DESTROYED == type && 60 if (NotificationType::EXTENSION_HOST_DESTROYED == type &&
58 Details<ExtensionHost>(extension_host_) != details) 61 Details<ExtensionHost>(extension_host_) != details)
59 return; 62 return;
60 63
61 // If we reach here, we know the notification is relevant to us, either 64 // If we reach here, we know the notification is relevant to us, either
62 // because we're only observing applicable sources or because we passed the 65 // because we're only observing applicable sources or because we passed the
63 // check above. Both of those indicate that we should ignore this dialog. 66 // check above. Both of those indicate that we should ignore this dialog.
64 // Also clear the client, since it's now invalid. 67 // Also clear the client, since it's now invalid.
65 skip_this_dialog_ = true; 68 skip_this_dialog_ = true;
66 client_ = NULL; 69 client_ = NULL;
67 CloseModalDialog(); 70 if (dialog_)
71 CloseModalDialog();
68 } 72 }
69 73
70 void JavaScriptAppModalDialog::InitNotifications() { 74 void JavaScriptAppModalDialog::InitNotifications() {
71 // Make sure we get relevant navigation notifications so we know when our 75 // Make sure we get relevant navigation notifications so we know when our
72 // parent contents will disappear or navigate to a different page. 76 // parent contents will disappear or navigate to a different page.
73 if (tab_contents_) { 77 if (tab_contents_) {
74 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 78 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
75 Source<NavigationController>(&tab_contents_->controller())); 79 Source<NavigationController>(&tab_contents_->controller()));
76 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 80 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
77 Source<TabContents>(tab_contents_)); 81 Source<TabContents>(tab_contents_));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // state, destroying the host. http://crbug.com/29355 133 // state, destroying the host. http://crbug.com/29355
130 #if !defined(OS_MACOSX) 134 #if !defined(OS_MACOSX)
131 else if (extension_host_) 135 else if (extension_host_)
132 extension_host_->OnMessageBoxClosed(reply_msg_, false, L""); 136 extension_host_->OnMessageBoxClosed(reply_msg_, false, L"");
133 else 137 else
134 NOTREACHED(); 138 NOTREACHED();
135 #endif 139 #endif
136 } 140 }
137 AppModalDialog::Cleanup(); 141 AppModalDialog::Cleanup();
138 } 142 }
139
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