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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1931793002: Stop using nested message loop for alert() and other JS dialogs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comment Created 4 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 return; 2116 return;
2117 } 2117 }
2118 2118
2119 Send(new FrameHostMsg_TextSurroundingSelectionResponse( 2119 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
2120 routing_id_, 2120 routing_id_,
2121 surroundingText.textContent(), 2121 surroundingText.textContent(),
2122 surroundingText.startOffsetInTextContent(), 2122 surroundingText.startOffsetInTextContent(),
2123 surroundingText.endOffsetInTextContent())); 2123 surroundingText.endOffsetInTextContent()));
2124 } 2124 }
2125 2125
2126 bool RenderFrameImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
2127 // Before Blink asks us to show an alert (etc.), it takes care of doing the
2128 // equivalent of WebView::willEnterModalLoop. In this case it is particularly
2129 // important that we do not call willEnterModalLoop as that would defer
2130 // resource loads for the dialog itself.
2131 if (RenderThreadImpl::current()) // Will be NULL during unit tests.
2132 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop();
2133
2134 message->EnableMessagePumping(); // Runs a nested message loop.
2135 return Send(message);
2136 }
2137
2138 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, 2126 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type,
2139 const base::string16& message, 2127 const base::string16& message,
2140 const base::string16& default_value, 2128 const base::string16& default_value,
2141 const GURL& frame_url, 2129 const GURL& frame_url,
2142 base::string16* result) { 2130 base::string16* result) {
2143 // Don't allow further dialogs if we are waiting to swap out, since the 2131 // Don't allow further dialogs if we are waiting to swap out, since the
2144 // ScopedPageLoadDeferrer in our stack prevents it. 2132 // ScopedPageLoadDeferrer in our stack prevents it.
2145 if (suppress_further_dialogs_) 2133 if (suppress_further_dialogs_)
2146 return false; 2134 return false;
2147 2135
2148 bool success = false; 2136 bool success = false;
2149 base::string16 result_temp; 2137 base::string16 result_temp;
2150 if (!result) 2138 if (!result)
2151 result = &result_temp; 2139 result = &result_temp;
2152 2140
2153 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( 2141 Send(new FrameHostMsg_RunJavaScriptMessage(
2154 routing_id_, message, default_value, frame_url, type, &success, result)); 2142 routing_id_, message, default_value, frame_url, type, &success, result));
2155 return success; 2143 return success;
2156 } 2144 }
2157 2145
2158 void RenderFrameImpl::LoadNavigationErrorPage( 2146 void RenderFrameImpl::LoadNavigationErrorPage(
2159 const WebURLRequest& failed_request, 2147 const WebURLRequest& failed_request,
2160 const WebURLError& error, 2148 const WebURLError& error,
2161 bool replace) { 2149 bool replace) {
2162 std::string error_html; 2150 std::string error_html;
2163 GetContentClient()->renderer()->GetNavigationErrorStrings( 2151 GetContentClient()->renderer()->GetNavigationErrorStrings(
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { 3610 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) {
3623 // Don't allow further dialogs if we are waiting to swap out, since the 3611 // Don't allow further dialogs if we are waiting to swap out, since the
3624 // ScopedPageLoadDeferrer in our stack prevents it. 3612 // ScopedPageLoadDeferrer in our stack prevents it.
3625 if (suppress_further_dialogs_) 3613 if (suppress_further_dialogs_)
3626 return false; 3614 return false;
3627 3615
3628 bool success = false; 3616 bool success = false;
3629 // This is an ignored return value, but is included so we can accept the same 3617 // This is an ignored return value, but is included so we can accept the same
3630 // response as RunJavaScriptMessage. 3618 // response as RunJavaScriptMessage.
3631 base::string16 ignored_result; 3619 base::string16 ignored_result;
3632 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( 3620 Send(new FrameHostMsg_RunBeforeUnloadConfirm(
3633 routing_id_, frame_->document().url(), is_reload, &success, 3621 routing_id_, frame_->document().url(), is_reload, &success,
3634 &ignored_result)); 3622 &ignored_result));
3635 return success; 3623 return success;
3636 } 3624 }
3637 3625
3638 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { 3626 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {
3639 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); 3627 ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
3640 blink::WebRect position_in_window(params.x, params.y, 0, 0); 3628 blink::WebRect position_in_window(params.x, params.y, 0, 0);
3641 GetRenderWidget()->convertViewportToWindow(&position_in_window); 3629 GetRenderWidget()->convertViewportToWindow(&position_in_window);
3642 params.x = position_in_window.x; 3630 params.x = position_in_window.x;
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
6020 int match_count, 6008 int match_count,
6021 int ordinal, 6009 int ordinal,
6022 const WebRect& selection_rect, 6010 const WebRect& selection_rect,
6023 bool final_status_update) { 6011 bool final_status_update) {
6024 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6012 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6025 selection_rect, ordinal, 6013 selection_rect, ordinal,
6026 final_status_update)); 6014 final_status_update));
6027 } 6015 }
6028 6016
6029 } // namespace content 6017 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698