Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 1021 geolocation_dispatcher_(NULL), | 1021 geolocation_dispatcher_(NULL), |
| 1022 push_messaging_dispatcher_(NULL), | 1022 push_messaging_dispatcher_(NULL), |
| 1023 presentation_dispatcher_(NULL), | 1023 presentation_dispatcher_(NULL), |
| 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_dialogs_until_swap_out_(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 Loading... | |
| 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_SuppressDialogsUntilSwapOut, | |
| 1448 OnSuppressDialogsUntilSwapOut) | |
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. | 1580 // It is now safe to show modal dialogs again. |
| 1578 // TODO(creis): Deal with modal dialogs from subframes. | 1581 suppress_dialogs_until_swap_out_ = false; |
|
nasko
2016/04/04 22:00:16
Is it safe? This RenderFrame is about to be booted
Avi (use Gerrit)
2016/04/05 01:31:18
This particular switch is to make sure that a fram
Avi (use Gerrit)
2016/04/06 22:20:43
Is being swapped out a guarantee that the frame is
| |
| 1579 if (is_main_frame_) | |
| 1580 render_view_->suppress_dialogs_until_swap_out_ = false; | |
| 1581 | 1582 |
| 1582 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1583 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
| 1583 | 1584 |
| 1584 RenderViewImpl* render_view = render_view_.get(); | 1585 RenderViewImpl* render_view = render_view_.get(); |
| 1585 bool is_main_frame = is_main_frame_; | 1586 bool is_main_frame = is_main_frame_; |
| 1586 int routing_id = GetRoutingID(); | 1587 int routing_id = GetRoutingID(); |
| 1587 | 1588 |
| 1588 // Now that all of the cleanup is complete and the browser side is notified, | 1589 // Now that all of the cleanup is complete and the browser side is notified, |
| 1589 // start using the RenderFrameProxy, if one is created. | 1590 // start using the RenderFrameProxy, if one is created. |
| 1590 if (proxy) { | 1591 if (proxy) { |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2143 return Send(message); | 2144 return Send(message); |
| 2144 } | 2145 } |
| 2145 | 2146 |
| 2146 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2147 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| 2147 const base::string16& message, | 2148 const base::string16& message, |
| 2148 const base::string16& default_value, | 2149 const base::string16& default_value, |
| 2149 const GURL& frame_url, | 2150 const GURL& frame_url, |
| 2150 base::string16* result) { | 2151 base::string16* result) { |
| 2151 // Don't allow further dialogs if we are waiting to swap out, since the | 2152 // Don't allow further dialogs if we are waiting to swap out, since the |
| 2152 // PageGroupLoadDeferrer in our stack prevents it. | 2153 // PageGroupLoadDeferrer in our stack prevents it. |
| 2153 if (render_view()->suppress_dialogs_until_swap_out_) | 2154 if (suppress_dialogs_until_swap_out_) |
| 2154 return false; | 2155 return false; |
| 2155 | 2156 |
| 2156 bool success = false; | 2157 bool success = false; |
| 2157 base::string16 result_temp; | 2158 base::string16 result_temp; |
| 2158 if (!result) | 2159 if (!result) |
| 2159 result = &result_temp; | 2160 result = &result_temp; |
| 2160 | 2161 |
| 2161 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( | 2162 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( |
| 2162 routing_id_, message, default_value, frame_url, type, &success, result)); | 2163 routing_id_, message, default_value, frame_url, type, &success, result)); |
| 2163 return success; | 2164 return success; |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3612 frame_->document().url(), | 3613 frame_->document().url(), |
| 3613 &result); | 3614 &result); |
| 3614 if (ok) | 3615 if (ok) |
| 3615 actual_value->assign(result); | 3616 actual_value->assign(result); |
| 3616 return ok; | 3617 return ok; |
| 3617 } | 3618 } |
| 3618 | 3619 |
| 3619 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { | 3620 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { |
| 3620 // Don't allow further dialogs if we are waiting to swap out, since the | 3621 // Don't allow further dialogs if we are waiting to swap out, since the |
| 3621 // PageGroupLoadDeferrer in our stack prevents it. | 3622 // PageGroupLoadDeferrer in our stack prevents it. |
| 3622 if (render_view()->suppress_dialogs_until_swap_out_) | 3623 if (suppress_dialogs_until_swap_out_) |
| 3623 return false; | 3624 return false; |
| 3624 | 3625 |
| 3625 bool success = false; | 3626 bool success = false; |
| 3626 // This is an ignored return value, but is included so we can accept the same | 3627 // This is an ignored return value, but is included so we can accept the same |
| 3627 // response as RunJavaScriptMessage. | 3628 // response as RunJavaScriptMessage. |
| 3628 base::string16 ignored_result; | 3629 base::string16 ignored_result; |
| 3629 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( | 3630 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( |
| 3630 routing_id_, frame_->document().url(), is_reload, &success, | 3631 routing_id_, frame_->document().url(), is_reload, &success, |
| 3631 &ignored_result)); | 3632 &ignored_result)); |
| 3632 return success; | 3633 return success; |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5125 } | 5126 } |
| 5126 } | 5127 } |
| 5127 } | 5128 } |
| 5128 | 5129 |
| 5129 void RenderFrameImpl::OnEnableViewSourceMode() { | 5130 void RenderFrameImpl::OnEnableViewSourceMode() { |
| 5130 DCHECK(frame_); | 5131 DCHECK(frame_); |
| 5131 DCHECK(!frame_->parent()); | 5132 DCHECK(!frame_->parent()); |
| 5132 frame_->enableViewSourceMode(true); | 5133 frame_->enableViewSourceMode(true); |
| 5133 } | 5134 } |
| 5134 | 5135 |
| 5136 void RenderFrameImpl::OnSuppressDialogsUntilSwapOut() { | |
| 5137 // Don't show any more dialogs until we finish OnSwapOut. | |
| 5138 suppress_dialogs_until_swap_out_ = true; | |
| 5139 } | |
| 5140 | |
| 5135 #if defined(OS_ANDROID) | 5141 #if defined(OS_ANDROID) |
| 5136 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, | 5142 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, |
| 5137 float x, | 5143 float x, |
| 5138 float y) { | 5144 float y) { |
| 5139 WebRect selection_rect; | 5145 WebRect selection_rect; |
| 5140 int ordinal = | 5146 int ordinal = |
| 5141 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); | 5147 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); |
| 5142 if (ordinal == -1) { | 5148 if (ordinal == -1) { |
| 5143 // Something went wrong, so send a no-op reply (force the frame to report | 5149 // Something went wrong, so send a no-op reply (force the frame to report |
| 5144 // the current match count) in case the host is waiting for a response due | 5150 // the current match count) in case the host is waiting for a response due |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6041 int match_count, | 6047 int match_count, |
| 6042 int ordinal, | 6048 int ordinal, |
| 6043 const WebRect& selection_rect, | 6049 const WebRect& selection_rect, |
| 6044 bool final_status_update) { | 6050 bool final_status_update) { |
| 6045 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6051 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6046 selection_rect, ordinal, | 6052 selection_rect, ordinal, |
| 6047 final_status_update)); | 6053 final_status_update)); |
| 6048 } | 6054 } |
| 6049 | 6055 |
| 6050 } // namespace content | 6056 } // namespace content |
| OLD | NEW |