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

Side by Side Diff: chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc

Issue 24436003: Don't leave renderer process frozen when canceling JavaScript dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clear callback after calling. Created 7 years, 2 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 | « no previous file | chrome/browser/ui/browser_browsertest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 5 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_shutdown.h" 8 #include "chrome/browser/browser_shutdown.h"
9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { 102 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() {
103 return true; 103 return true;
104 } 104 }
105 105
106 void JavaScriptAppModalDialog::Invalidate() { 106 void JavaScriptAppModalDialog::Invalidate() {
107 if (!IsValid()) 107 if (!IsValid())
108 return; 108 return;
109 109
110 AppModalDialog::Invalidate(); 110 AppModalDialog::Invalidate();
111 callback_.Reset(); 111 if (!callback_.is_null()) {
112 callback_.Run(false, string16());
113 callback_.Reset();
114 }
112 if (native_dialog()) 115 if (native_dialog())
113 CloseModalDialog(); 116 CloseModalDialog();
114 } 117 }
115 118
116 void JavaScriptAppModalDialog::OnCancel(bool suppress_js_messages) { 119 void JavaScriptAppModalDialog::OnCancel(bool suppress_js_messages) {
117 // If we are shutting down and this is an onbeforeunload dialog, cancel the 120 // If we are shutting down and this is an onbeforeunload dialog, cancel the
118 // shutdown. 121 // shutdown.
119 // TODO(sammc): Remove this when kEnableBatchedShutdown becomes mandatory. 122 // TODO(sammc): Remove this when kEnableBatchedShutdown becomes mandatory.
120 if (is_before_unload_dialog_ && 123 if (is_before_unload_dialog_ &&
121 !CommandLine::ForCurrentProcess()->HasSwitch( 124 !CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 override_prompt_text_ = override_prompt_text; 157 override_prompt_text_ = override_prompt_text;
155 use_override_prompt_text_ = true; 158 use_override_prompt_text_ = true;
156 } 159 }
157 160
158 void JavaScriptAppModalDialog::NotifyDelegate(bool success, 161 void JavaScriptAppModalDialog::NotifyDelegate(bool success,
159 const string16& user_input, 162 const string16& user_input,
160 bool suppress_js_messages) { 163 bool suppress_js_messages) {
161 if (!IsValid()) 164 if (!IsValid())
162 return; 165 return;
163 166
164 callback_.Run(success, user_input); 167 if (!callback_.is_null()) {
168 callback_.Run(success, user_input);
169 callback_.Reset();
170 }
165 171
166 // The callback_ above may delete web_contents_, thus removing the extra 172 // The callback_ above may delete web_contents_, thus removing the extra
167 // data from the map owned by ChromeJavaScriptDialogManager. Make sure 173 // data from the map owned by ChromeJavaScriptDialogManager. Make sure
168 // to only use the data if still present. http://crbug.com/236476 174 // to only use the data if still present. http://crbug.com/236476
169 ExtraDataMap::iterator extra_data = extra_data_map_->find(web_contents()); 175 ExtraDataMap::iterator extra_data = extra_data_map_->find(web_contents());
170 if (extra_data != extra_data_map_->end()) { 176 if (extra_data != extra_data_map_->end()) {
171 extra_data->second.last_javascript_message_dismissal_ = 177 extra_data->second.last_javascript_message_dismissal_ =
172 base::TimeTicks::Now(); 178 base::TimeTicks::Now();
173 extra_data->second.suppress_javascript_messages_ = suppress_js_messages; 179 extra_data->second.suppress_javascript_messages_ = suppress_js_messages;
174 } 180 }
175 181
176 // On Views, we can end up coming through this code path twice :(. 182 // On Views, we can end up coming through this code path twice :(.
177 // See crbug.com/63732. 183 // See crbug.com/63732.
178 AppModalDialog::Invalidate(); 184 AppModalDialog::Invalidate();
179 } 185 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698