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

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: use infinite loop instead of 10 secs 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 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 return; 2122 return;
2123 } 2123 }
2124 2124
2125 Send(new FrameHostMsg_TextSurroundingSelectionResponse( 2125 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
2126 routing_id_, 2126 routing_id_,
2127 surroundingText.textContent(), 2127 surroundingText.textContent(),
2128 surroundingText.startOffsetInTextContent(), 2128 surroundingText.startOffsetInTextContent(),
2129 surroundingText.endOffsetInTextContent())); 2129 surroundingText.endOffsetInTextContent()));
2130 } 2130 }
2131 2131
2132 bool RenderFrameImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
2133 // Before Blink asks us to show an alert (etc.), it takes care of doing the
2134 // equivalent of WebView::willEnterModalLoop. In this case it is particularly
2135 // important that we do not call willEnterModalLoop as that would defer
2136 // resource loads for the dialog itself.
2137 if (RenderThreadImpl::current()) // Will be NULL during unit tests.
2138 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop();
2139
2140 message->EnableMessagePumping(); // Runs a nested message loop.
2141 return Send(message);
2142 }
2143
2144 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, 2132 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type,
2145 const base::string16& message, 2133 const base::string16& message,
2146 const base::string16& default_value, 2134 const base::string16& default_value,
2147 const GURL& frame_url, 2135 const GURL& frame_url,
2148 base::string16* result) { 2136 base::string16* result) {
2149 // Don't allow further dialogs if we are waiting to swap out, since the 2137 // Don't allow further dialogs if we are waiting to swap out, since the
2150 // ScopedPageLoadDeferrer in our stack prevents it. 2138 // ScopedPageLoadDeferrer in our stack prevents it.
2151 if (suppress_further_dialogs_) 2139 if (suppress_further_dialogs_)
2152 return false; 2140 return false;
2153 2141
2154 bool success = false; 2142 bool success = false;
2155 base::string16 result_temp; 2143 base::string16 result_temp;
2156 if (!result) 2144 if (!result)
2157 result = &result_temp; 2145 result = &result_temp;
2158 2146
2159 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( 2147 Send(new FrameHostMsg_RunJavaScriptMessage(
2160 routing_id_, message, default_value, frame_url, type, &success, result)); 2148 routing_id_, message, default_value, frame_url, type, &success, result));
2161 return success; 2149 return success;
2162 } 2150 }
2163 2151
2164 void RenderFrameImpl::LoadNavigationErrorPage( 2152 void RenderFrameImpl::LoadNavigationErrorPage(
2165 const WebURLRequest& failed_request, 2153 const WebURLRequest& failed_request,
2166 const WebURLError& error, 2154 const WebURLError& error,
2167 bool replace) { 2155 bool replace) {
2168 std::string error_html; 2156 std::string error_html;
2169 GetContentClient()->renderer()->GetNavigationErrorStrings( 2157 GetContentClient()->renderer()->GetNavigationErrorStrings(
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { 3616 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) {
3629 // Don't allow further dialogs if we are waiting to swap out, since the 3617 // Don't allow further dialogs if we are waiting to swap out, since the
3630 // ScopedPageLoadDeferrer in our stack prevents it. 3618 // ScopedPageLoadDeferrer in our stack prevents it.
3631 if (suppress_further_dialogs_) 3619 if (suppress_further_dialogs_)
3632 return false; 3620 return false;
3633 3621
3634 bool success = false; 3622 bool success = false;
3635 // This is an ignored return value, but is included so we can accept the same 3623 // This is an ignored return value, but is included so we can accept the same
3636 // response as RunJavaScriptMessage. 3624 // response as RunJavaScriptMessage.
3637 base::string16 ignored_result; 3625 base::string16 ignored_result;
3638 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( 3626 Send(new FrameHostMsg_RunBeforeUnloadConfirm(
3639 routing_id_, frame_->document().url(), is_reload, &success, 3627 routing_id_, frame_->document().url(), is_reload, &success,
3640 &ignored_result)); 3628 &ignored_result));
3641 return success; 3629 return success;
3642 } 3630 }
3643 3631
3644 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { 3632 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {
3645 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); 3633 ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
3646 blink::WebRect position_in_window(params.x, params.y, 0, 0); 3634 blink::WebRect position_in_window(params.x, params.y, 0, 0);
3647 GetRenderWidget()->convertViewportToWindow(&position_in_window); 3635 GetRenderWidget()->convertViewportToWindow(&position_in_window);
3648 params.x = position_in_window.x; 3636 params.x = position_in_window.x;
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
6033 int match_count, 6021 int match_count,
6034 int ordinal, 6022 int ordinal,
6035 const WebRect& selection_rect, 6023 const WebRect& selection_rect,
6036 bool final_status_update) { 6024 bool final_status_update) {
6037 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6025 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6038 selection_rect, ordinal, 6026 selection_rect, ordinal,
6039 final_status_update)); 6027 final_status_update));
6040 } 6028 }
6041 6029
6042 } // namespace content 6030 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698