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

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

Issue 1849013004: Fix JavaScript alerts from frames with oopif on, after a cross-process click. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alertfix
Patch Set: cleaner re swapped out Created 4 years, 8 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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 push_messaging_dispatcher_(NULL), 1021 push_messaging_dispatcher_(NULL),
1022 presentation_dispatcher_(NULL), 1022 presentation_dispatcher_(NULL),
1023 blink_service_registry_(service_registry_.GetWeakPtr()), 1023 blink_service_registry_(service_registry_.GetWeakPtr()),
1024 screen_orientation_dispatcher_(NULL), 1024 screen_orientation_dispatcher_(NULL),
1025 manifest_manager_(NULL), 1025 manifest_manager_(NULL),
1026 accessibility_mode_(AccessibilityModeOff), 1026 accessibility_mode_(AccessibilityModeOff),
1027 renderer_accessibility_(NULL), 1027 renderer_accessibility_(NULL),
1028 media_player_delegate_(NULL), 1028 media_player_delegate_(NULL),
1029 is_using_lofi_(false), 1029 is_using_lofi_(false),
1030 is_pasting_(false), 1030 is_pasting_(false),
1031 suppress_further_dialogs_(false),
1031 blame_context_(nullptr), 1032 blame_context_(nullptr),
1032 weak_factory_(this) { 1033 weak_factory_(this) {
1033 std::pair<RoutingIDFrameMap::iterator, bool> result = 1034 std::pair<RoutingIDFrameMap::iterator, bool> result =
1034 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 1035 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
1035 CHECK(result.second) << "Inserting a duplicate item."; 1036 CHECK(result.second) << "Inserting a duplicate item.";
1036 1037
1037 RenderThread::Get()->AddRoute(routing_id_, this); 1038 RenderThread::Get()->AddRoute(routing_id_, this);
1038 1039
1039 render_view_->RegisterRenderFrame(this); 1040 render_view_->RegisterRenderFrame(this);
1040 1041
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) 1437 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent)
1437 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) 1438 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation)
1438 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, 1439 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks,
1439 OnGetSavableResourceLinks) 1440 OnGetSavableResourceLinks)
1440 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, 1441 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks,
1441 OnGetSerializedHtmlWithLocalLinks) 1442 OnGetSerializedHtmlWithLocalLinks)
1442 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) 1443 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML)
1443 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind) 1444 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind)
1444 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding) 1445 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding)
1445 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1446 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1447 IPC_MESSAGE_HANDLER(FrameMsg_SuppressFurtherDialogs,
1448 OnSuppressFurtherDialogs)
1446 #if defined(OS_ANDROID) 1449 #if defined(OS_ANDROID)
1447 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1450 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1448 OnActivateNearestFindResult) 1451 OnActivateNearestFindResult)
1449 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects) 1452 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects)
1450 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) 1453 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1451 #elif defined(OS_MACOSX) 1454 #elif defined(OS_MACOSX)
1452 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) 1455 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1453 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 1456 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
1454 #endif 1457 #endif
1455 IPC_END_MESSAGE_MAP() 1458 IPC_END_MESSAGE_MAP()
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 proxy->web_frame()->initializeFromFrame(frame_); 1570 proxy->web_frame()->initializeFromFrame(frame_);
1568 1571
1569 // Let WebKit know that this view is hidden so it can drop resources and 1572 // Let WebKit know that this view is hidden so it can drop resources and
1570 // stop compositing. 1573 // stop compositing.
1571 // TODO(creis): Support this for subframes as well. 1574 // TODO(creis): Support this for subframes as well.
1572 if (is_main_frame_) { 1575 if (is_main_frame_) {
1573 render_view_->webview()->setVisibilityState( 1576 render_view_->webview()->setVisibilityState(
1574 blink::WebPageVisibilityStateHidden, false); 1577 blink::WebPageVisibilityStateHidden, false);
1575 } 1578 }
1576 1579
1577 // It is now safe to show modal dialogs again.
1578 // TODO(creis): Deal with modal dialogs from subframes.
1579 if (is_main_frame_)
1580 render_view_->suppress_dialogs_until_swap_out_ = false;
Charlie Reis 2016/04/08 17:27:40 Yes, I agree with removing this. This RenderFrame
1581
1582 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1580 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1583 1581
1584 RenderViewImpl* render_view = render_view_.get(); 1582 RenderViewImpl* render_view = render_view_.get();
1585 bool is_main_frame = is_main_frame_; 1583 bool is_main_frame = is_main_frame_;
1586 int routing_id = GetRoutingID(); 1584 int routing_id = GetRoutingID();
1587 1585
1588 // Now that all of the cleanup is complete and the browser side is notified, 1586 // Now that all of the cleanup is complete and the browser side is notified,
1589 // start using the RenderFrameProxy, if one is created. 1587 // start using the RenderFrameProxy, if one is created.
1590 if (proxy) { 1588 if (proxy) {
1591 // The swap call deletes this RenderFrame via frameDetached. Do not access 1589 // The swap call deletes this RenderFrame via frameDetached. Do not access
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 message->EnableMessagePumping(); // Runs a nested message loop. 2141 message->EnableMessagePumping(); // Runs a nested message loop.
2144 return Send(message); 2142 return Send(message);
2145 } 2143 }
2146 2144
2147 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, 2145 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type,
2148 const base::string16& message, 2146 const base::string16& message,
2149 const base::string16& default_value, 2147 const base::string16& default_value,
2150 const GURL& frame_url, 2148 const GURL& frame_url,
2151 base::string16* result) { 2149 base::string16* result) {
2152 // Don't allow further dialogs if we are waiting to swap out, since the 2150 // Don't allow further dialogs if we are waiting to swap out, since the
2153 // PageGroupLoadDeferrer in our stack prevents it. 2151 // ScopedPageLoadDeferrer in our stack prevents it.
2154 if (render_view()->suppress_dialogs_until_swap_out_) 2152 if (suppress_further_dialogs_)
2155 return false; 2153 return false;
2156 2154
2157 bool success = false; 2155 bool success = false;
2158 base::string16 result_temp; 2156 base::string16 result_temp;
2159 if (!result) 2157 if (!result)
2160 result = &result_temp; 2158 result = &result_temp;
2161 2159
2162 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( 2160 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage(
2163 routing_id_, message, default_value, frame_url, type, &success, result)); 2161 routing_id_, message, default_value, frame_url, type, &success, result));
2164 return success; 2162 return success;
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3607 default_value, 3605 default_value,
3608 frame_->document().url(), 3606 frame_->document().url(),
3609 &result); 3607 &result);
3610 if (ok) 3608 if (ok)
3611 actual_value->assign(result); 3609 actual_value->assign(result);
3612 return ok; 3610 return ok;
3613 } 3611 }
3614 3612
3615 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { 3613 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) {
3616 // Don't allow further dialogs if we are waiting to swap out, since the 3614 // Don't allow further dialogs if we are waiting to swap out, since the
3617 // PageGroupLoadDeferrer in our stack prevents it. 3615 // ScopedPageLoadDeferrer in our stack prevents it.
3618 if (render_view()->suppress_dialogs_until_swap_out_) 3616 if (suppress_further_dialogs_)
3619 return false; 3617 return false;
3620 3618
3621 bool success = false; 3619 bool success = false;
3622 // This is an ignored return value, but is included so we can accept the same 3620 // This is an ignored return value, but is included so we can accept the same
3623 // response as RunJavaScriptMessage. 3621 // response as RunJavaScriptMessage.
3624 base::string16 ignored_result; 3622 base::string16 ignored_result;
3625 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( 3623 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm(
3626 routing_id_, frame_->document().url(), is_reload, &success, 3624 routing_id_, frame_->document().url(), is_reload, &success,
3627 &ignored_result)); 3625 &ignored_result));
3628 return success; 3626 return success;
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
5121 } 5119 }
5122 } 5120 }
5123 } 5121 }
5124 5122
5125 void RenderFrameImpl::OnEnableViewSourceMode() { 5123 void RenderFrameImpl::OnEnableViewSourceMode() {
5126 DCHECK(frame_); 5124 DCHECK(frame_);
5127 DCHECK(!frame_->parent()); 5125 DCHECK(!frame_->parent());
5128 frame_->enableViewSourceMode(true); 5126 frame_->enableViewSourceMode(true);
5129 } 5127 }
5130 5128
5129 void RenderFrameImpl::OnSuppressFurtherDialogs() {
5130 suppress_further_dialogs_ = true;
5131 }
5132
5131 #if defined(OS_ANDROID) 5133 #if defined(OS_ANDROID)
5132 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, 5134 void RenderFrameImpl::OnActivateNearestFindResult(int request_id,
5133 float x, 5135 float x,
5134 float y) { 5136 float y) {
5135 WebRect selection_rect; 5137 WebRect selection_rect;
5136 int ordinal = 5138 int ordinal =
5137 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); 5139 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect);
5138 if (ordinal == -1) { 5140 if (ordinal == -1) {
5139 // Something went wrong, so send a no-op reply (force the frame to report 5141 // Something went wrong, so send a no-op reply (force the frame to report
5140 // the current match count) in case the host is waiting for a response due 5142 // the current match count) in case the host is waiting for a response due
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
6041 int match_count, 6043 int match_count,
6042 int ordinal, 6044 int ordinal,
6043 const WebRect& selection_rect, 6045 const WebRect& selection_rect,
6044 bool final_status_update) { 6046 bool final_status_update) {
6045 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6047 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6046 selection_rect, ordinal, 6048 selection_rect, ordinal,
6047 final_status_update)); 6049 final_status_update));
6048 } 6050 }
6049 6051
6050 } // namespace content 6052 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698