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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 while ((observer = it.GetNext()) != NULL) { | 676 while ((observer = it.GetNext()) != NULL) { |
677 if (observer->OnMessageReceived(msg)) | 677 if (observer->OnMessageReceived(msg)) |
678 return true; | 678 return true; |
679 } | 679 } |
680 | 680 |
681 bool handled = true; | 681 bool handled = true; |
682 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) | 682 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) |
683 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 683 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
684 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload) | 684 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload) |
685 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) | 685 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) |
686 IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped) | |
687 IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped, | |
688 OnCompositorFrameSwapped(msg)) | |
689 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) | |
690 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) | 686 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) |
691 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, | 687 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, |
692 OnCustomContextMenuAction) | 688 OnCustomContextMenuAction) |
693 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) | 689 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
694 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) | 690 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) |
695 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) | 691 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
696 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) | 692 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) |
697 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) | 693 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) |
698 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 694 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
699 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) | 695 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 // purposes of compositing and input events. | 958 // purposes of compositing and input events. |
963 if (frame_->parent()) | 959 if (frame_->parent()) |
964 frame_->setIsRemote(true); | 960 frame_->setIsRemote(true); |
965 | 961 |
966 // Replace the page with a blank dummy URL. The unload handler will not be | 962 // Replace the page with a blank dummy URL. The unload handler will not be |
967 // run a second time, thanks to a check in FrameLoader::stopLoading. | 963 // run a second time, thanks to a check in FrameLoader::stopLoading. |
968 // TODO(creis): Need to add a better way to do this that avoids running the | 964 // TODO(creis): Need to add a better way to do this that avoids running the |
969 // beforeunload handler. For now, we just run it a second time silently. | 965 // beforeunload handler. For now, we just run it a second time silently. |
970 render_view_->NavigateToSwappedOutURL(frame_); | 966 render_view_->NavigateToSwappedOutURL(frame_); |
971 | 967 |
972 if (frame_->parent()) | |
973 render_view_->RegisterSwappedOutChildFrame(this); | |
974 | |
975 // Let WebKit know that this view is hidden so it can drop resources and | 968 // Let WebKit know that this view is hidden so it can drop resources and |
976 // stop compositing. | 969 // stop compositing. |
977 // TODO(creis): Support this for subframes as well. | 970 // TODO(creis): Support this for subframes as well. |
978 if (!frame_->parent()) { | 971 if (!frame_->parent()) { |
979 render_view_->webview()->setVisibilityState( | 972 render_view_->webview()->setVisibilityState( |
980 blink::WebPageVisibilityStateHidden, false); | 973 blink::WebPageVisibilityStateHidden, false); |
981 } | 974 } |
982 } | 975 } |
983 | 976 |
984 // It is now safe to show modal dialogs again. | 977 // It is now safe to show modal dialogs again. |
985 // TODO(creis): Deal with modal dialogs from subframes. | 978 // TODO(creis): Deal with modal dialogs from subframes. |
986 if (!frame_->parent()) | 979 if (!frame_->parent()) |
987 render_view_->suppress_dialogs_until_swap_out_ = false; | 980 render_view_->suppress_dialogs_until_swap_out_ = false; |
988 | 981 |
989 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 982 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
990 | 983 |
991 // Now that all of the cleanup is complete and the browser side is notified, | 984 // Now that all of the cleanup is complete and the browser side is notified, |
992 // start using the RenderFrameProxy, if one is created. | 985 // start using the RenderFrameProxy, if one is created. |
993 if (proxy) | 986 if (proxy) |
994 set_render_frame_proxy(proxy); | 987 set_render_frame_proxy(proxy); |
995 } | 988 } |
996 | 989 |
997 void RenderFrameImpl::OnBuffersSwapped( | |
998 const FrameMsg_BuffersSwapped_Params& params) { | |
999 if (!compositing_helper_.get()) { | |
1000 compositing_helper_ = | |
1001 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( | |
1002 frame_, this, routing_id_); | |
1003 compositing_helper_->EnableCompositing(true); | |
1004 } | |
1005 compositing_helper_->OnBuffersSwapped( | |
1006 params.size, | |
1007 params.mailbox, | |
1008 params.gpu_route_id, | |
1009 params.gpu_host_id, | |
1010 render_view_->GetWebView()->deviceScaleFactor()); | |
1011 } | |
1012 | |
1013 void RenderFrameImpl::OnCompositorFrameSwapped(const IPC::Message& message) { | |
1014 FrameMsg_CompositorFrameSwapped::Param param; | |
1015 if (!FrameMsg_CompositorFrameSwapped::Read(&message, ¶m)) | |
1016 return; | |
1017 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | |
1018 param.a.frame.AssignTo(frame.get()); | |
1019 | |
1020 if (!compositing_helper_.get()) { | |
1021 compositing_helper_ = | |
1022 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( | |
1023 frame_, this, routing_id_); | |
1024 compositing_helper_->EnableCompositing(true); | |
1025 } | |
1026 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), | |
1027 param.a.producing_route_id, | |
1028 param.a.output_surface_id, | |
1029 param.a.producing_host_id, | |
1030 param.a.shared_memory_handle); | |
1031 } | |
1032 | |
1033 void RenderFrameImpl::OnContextMenuClosed( | 990 void RenderFrameImpl::OnContextMenuClosed( |
1034 const CustomContextMenuContext& custom_context) { | 991 const CustomContextMenuContext& custom_context) { |
1035 if (custom_context.request_id) { | 992 if (custom_context.request_id) { |
1036 // External request, should be in our map. | 993 // External request, should be in our map. |
1037 ContextMenuClient* client = | 994 ContextMenuClient* client = |
1038 pending_context_menus_.Lookup(custom_context.request_id); | 995 pending_context_menus_.Lookup(custom_context.request_id); |
1039 if (client) { | 996 if (client) { |
1040 client->OnMenuClosed(custom_context.request_id); | 997 client->OnMenuClosed(custom_context.request_id); |
1041 pending_context_menus_.Remove(custom_context.request_id); | 998 pending_context_menus_.Remove(custom_context.request_id); |
1042 } | 999 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 GetContentClient()->renderer()->GetNavigationErrorStrings( | 1227 GetContentClient()->renderer()->GetNavigationErrorStrings( |
1271 render_view(), frame_, failed_request, error, &error_html, NULL); | 1228 render_view(), frame_, failed_request, error, &error_html, NULL); |
1272 | 1229 |
1273 frame_->loadHTMLString(error_html, | 1230 frame_->loadHTMLString(error_html, |
1274 GURL(kUnreachableWebDataURL), | 1231 GURL(kUnreachableWebDataURL), |
1275 error.unreachableURL, | 1232 error.unreachableURL, |
1276 replace); | 1233 replace); |
1277 } | 1234 } |
1278 | 1235 |
1279 void RenderFrameImpl::DidCommitCompositorFrame() { | 1236 void RenderFrameImpl::DidCommitCompositorFrame() { |
1280 if (compositing_helper_) | |
1281 compositing_helper_->DidCommitCompositorFrame(); | |
1282 FOR_EACH_OBSERVER( | 1237 FOR_EACH_OBSERVER( |
1283 RenderFrameObserver, observers_, DidCommitCompositorFrame()); | 1238 RenderFrameObserver, observers_, DidCommitCompositorFrame()); |
1284 } | 1239 } |
1285 | 1240 |
1286 RenderView* RenderFrameImpl::GetRenderView() { | 1241 RenderView* RenderFrameImpl::GetRenderView() { |
1287 return render_view_.get(); | 1242 return render_view_.get(); |
1288 } | 1243 } |
1289 | 1244 |
1290 int RenderFrameImpl::GetRoutingID() { | 1245 int RenderFrameImpl::GetRoutingID() { |
1291 return routing_id_; | 1246 return routing_id_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 const blink::WebURLRequest& request, | 1303 const blink::WebURLRequest& request, |
1349 blink::WebNavigationPolicy policy) { | 1304 blink::WebNavigationPolicy policy) { |
1350 DCHECK(!frame_ || frame_ == frame); | 1305 DCHECK(!frame_ || frame_ == frame); |
1351 loadURLExternally(frame, request, policy, WebString()); | 1306 loadURLExternally(frame, request, policy, WebString()); |
1352 } | 1307 } |
1353 | 1308 |
1354 void RenderFrameImpl::ExecuteJavaScript(const base::string16& javascript) { | 1309 void RenderFrameImpl::ExecuteJavaScript(const base::string16& javascript) { |
1355 OnJavaScriptExecuteRequest(javascript, 0, false); | 1310 OnJavaScriptExecuteRequest(javascript, 0, false); |
1356 } | 1311 } |
1357 | 1312 |
1358 void RenderFrameImpl::OnChildFrameProcessGone() { | |
1359 if (compositing_helper_) | |
1360 compositing_helper_->ChildFrameGone(); | |
1361 } | |
1362 | |
1363 // blink::WebFrameClient implementation ---------------------------------------- | 1313 // blink::WebFrameClient implementation ---------------------------------------- |
1364 | 1314 |
1365 blink::WebPlugin* RenderFrameImpl::createPlugin( | 1315 blink::WebPlugin* RenderFrameImpl::createPlugin( |
1366 blink::WebLocalFrame* frame, | 1316 blink::WebLocalFrame* frame, |
1367 const blink::WebPluginParams& params) { | 1317 const blink::WebPluginParams& params) { |
1368 DCHECK_EQ(frame_, frame); | 1318 DCHECK_EQ(frame_, frame); |
1369 blink::WebPlugin* plugin = NULL; | 1319 blink::WebPlugin* plugin = NULL; |
1370 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 1320 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
1371 this, frame, params, &plugin)) { | 1321 this, frame, params, &plugin)) { |
1372 return plugin; | 1322 return plugin; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 // NOTE: This function is called on the frame that is being detached and not | 1497 // NOTE: This function is called on the frame that is being detached and not |
1548 // the parent frame. This is different from createChildFrame() which is | 1498 // the parent frame. This is different from createChildFrame() which is |
1549 // called on the parent frame. | 1499 // called on the parent frame. |
1550 CHECK(!is_detaching_); | 1500 CHECK(!is_detaching_); |
1551 DCHECK(!frame_ || frame_ == frame); | 1501 DCHECK(!frame_ || frame_ == frame); |
1552 | 1502 |
1553 bool is_subframe = !!frame->parent(); | 1503 bool is_subframe = !!frame->parent(); |
1554 | 1504 |
1555 Send(new FrameHostMsg_Detach(routing_id_)); | 1505 Send(new FrameHostMsg_Detach(routing_id_)); |
1556 | 1506 |
1557 render_view_->UnregisterSwappedOutChildFrame(this); | |
1558 | |
1559 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be | 1507 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
1560 // sent before setting |is_detaching_| to true. In contrast, Observers | 1508 // sent before setting |is_detaching_| to true. In contrast, Observers |
1561 // should only be notified afterwards so they cannot call back into here and | 1509 // should only be notified afterwards so they cannot call back into here and |
1562 // have IPCs fired off. | 1510 // have IPCs fired off. |
1563 is_detaching_ = true; | 1511 is_detaching_ = true; |
1564 | 1512 |
1565 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 1513 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
1566 FrameDetached(frame)); | 1514 FrameDetached(frame)); |
1567 | 1515 |
1568 // We need to clean up subframes by removing them from the map and deleting | 1516 // We need to clean up subframes by removing them from the map and deleting |
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3593 | 3541 |
3594 #if defined(ENABLE_BROWSER_CDMS) | 3542 #if defined(ENABLE_BROWSER_CDMS) |
3595 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3543 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3596 if (!cdm_manager_) | 3544 if (!cdm_manager_) |
3597 cdm_manager_ = new RendererCdmManager(this); | 3545 cdm_manager_ = new RendererCdmManager(this); |
3598 return cdm_manager_; | 3546 return cdm_manager_; |
3599 } | 3547 } |
3600 #endif // defined(ENABLE_BROWSER_CDMS) | 3548 #endif // defined(ENABLE_BROWSER_CDMS) |
3601 | 3549 |
3602 } // namespace content | 3550 } // namespace content |
OLD | NEW |