| 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/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
| 12 #include "base/debug/dump_without_crashing.h" | 13 #include "base/debug/dump_without_crashing.h" |
| 13 #include "base/i18n/char_iterator.h" | 14 #include "base/i18n/char_iterator.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/process/kill.h" | 16 #include "base/process/kill.h" |
| 16 #include "base/process/process.h" | 17 #include "base/process/process.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "content/child/appcache/appcache_dispatcher.h" | 20 #include "content/child/appcache/appcache_dispatcher.h" |
| 20 #include "content/child/plugin_messages.h" | 21 #include "content/child/plugin_messages.h" |
| 21 #include "content/child/quota_dispatcher.h" | 22 #include "content/child/quota_dispatcher.h" |
| 22 #include "content/child/request_extra_data.h" | 23 #include "content/child/request_extra_data.h" |
| 23 #include "content/child/service_worker/service_worker_network_provider.h" | 24 #include "content/child/service_worker/service_worker_network_provider.h" |
| 24 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 25 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 25 #include "content/child/web_socket_stream_handle_impl.h" | 26 #include "content/child/web_socket_stream_handle_impl.h" |
| 26 #include "content/common/frame_messages.h" | 27 #include "content/common/frame_messages.h" |
| 28 #include "content/common/input_messages.h" |
| 27 #include "content/common/service_worker/service_worker_types.h" | 29 #include "content/common/service_worker/service_worker_types.h" |
| 28 #include "content/common/socket_stream_handle_data.h" | 30 #include "content/common/socket_stream_handle_data.h" |
| 29 #include "content/common/swapped_out_messages.h" | 31 #include "content/common/swapped_out_messages.h" |
| 30 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
| 31 #include "content/public/common/bindings_policy.h" | 33 #include "content/public/common/bindings_policy.h" |
| 32 #include "content/public/common/content_constants.h" | 34 #include "content/public/common/content_constants.h" |
| 33 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 34 #include "content/public/common/context_menu_params.h" | 36 #include "content/public/common/context_menu_params.h" |
| 35 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
| 36 #include "content/public/common/url_utils.h" | 38 #include "content/public/common/url_utils.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #endif | 89 #endif |
| 88 | 90 |
| 89 #if defined(ENABLE_WEBRTC) | 91 #if defined(ENABLE_WEBRTC) |
| 90 #include "content/renderer/media/rtc_peer_connection_handler.h" | 92 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 91 #endif | 93 #endif |
| 92 | 94 |
| 93 using blink::WebContextMenuData; | 95 using blink::WebContextMenuData; |
| 94 using blink::WebData; | 96 using blink::WebData; |
| 95 using blink::WebDataSource; | 97 using blink::WebDataSource; |
| 96 using blink::WebDocument; | 98 using blink::WebDocument; |
| 99 using blink::WebElement; |
| 97 using blink::WebFrame; | 100 using blink::WebFrame; |
| 98 using blink::WebHistoryItem; | 101 using blink::WebHistoryItem; |
| 99 using blink::WebHTTPBody; | 102 using blink::WebHTTPBody; |
| 100 using blink::WebNavigationPolicy; | 103 using blink::WebNavigationPolicy; |
| 101 using blink::WebNavigationType; | 104 using blink::WebNavigationType; |
| 105 using blink::WebNode; |
| 102 using blink::WebPluginParams; | 106 using blink::WebPluginParams; |
| 103 using blink::WebReferrerPolicy; | 107 using blink::WebReferrerPolicy; |
| 104 using blink::WebSearchableFormData; | 108 using blink::WebSearchableFormData; |
| 105 using blink::WebSecurityOrigin; | 109 using blink::WebSecurityOrigin; |
| 106 using blink::WebSecurityPolicy; | 110 using blink::WebSecurityPolicy; |
| 107 using blink::WebServiceWorkerProvider; | 111 using blink::WebServiceWorkerProvider; |
| 108 using blink::WebStorageQuotaCallbacks; | 112 using blink::WebStorageQuotaCallbacks; |
| 109 using blink::WebString; | 113 using blink::WebString; |
| 110 using blink::WebURL; | 114 using blink::WebURL; |
| 111 using blink::WebURLError; | 115 using blink::WebURLError; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 PepperPluginInstanceImpl* instance) { | 355 PepperPluginInstanceImpl* instance) { |
| 352 render_view_->set_pepper_last_mouse_event_target(instance); | 356 render_view_->set_pepper_last_mouse_event_target(instance); |
| 353 } | 357 } |
| 354 | 358 |
| 355 void RenderFrameImpl::PepperTextInputTypeChanged( | 359 void RenderFrameImpl::PepperTextInputTypeChanged( |
| 356 PepperPluginInstanceImpl* instance) { | 360 PepperPluginInstanceImpl* instance) { |
| 357 if (instance != render_view_->focused_pepper_plugin()) | 361 if (instance != render_view_->focused_pepper_plugin()) |
| 358 return; | 362 return; |
| 359 | 363 |
| 360 GetRenderWidget()->UpdateTextInputType(); | 364 GetRenderWidget()->UpdateTextInputType(); |
| 361 if (render_view_->renderer_accessibility()) { | 365 if (render_view_->renderer_accessibility()) |
| 362 render_view_->renderer_accessibility()->FocusedNodeChanged( | 366 render_view_->renderer_accessibility()->FocusedNodeChanged(WebNode()); |
| 363 blink::WebNode()); | |
| 364 } | |
| 365 } | 367 } |
| 366 | 368 |
| 367 void RenderFrameImpl::PepperCaretPositionChanged( | 369 void RenderFrameImpl::PepperCaretPositionChanged( |
| 368 PepperPluginInstanceImpl* instance) { | 370 PepperPluginInstanceImpl* instance) { |
| 369 if (instance != render_view_->focused_pepper_plugin()) | 371 if (instance != render_view_->focused_pepper_plugin()) |
| 370 return; | 372 return; |
| 371 GetRenderWidget()->UpdateSelectionBounds(); | 373 GetRenderWidget()->UpdateSelectionBounds(); |
| 372 } | 374 } |
| 373 | 375 |
| 374 void RenderFrameImpl::PepperCancelComposition( | 376 void RenderFrameImpl::PepperCancelComposition( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameImpl, msg, msg_is_ok) | 537 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameImpl, msg, msg_is_ok) |
| 536 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 538 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
| 537 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) | 539 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) |
| 538 IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped) | 540 IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped) |
| 539 IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped, | 541 IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped, |
| 540 OnCompositorFrameSwapped(msg)) | 542 OnCompositorFrameSwapped(msg)) |
| 541 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) | 543 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) |
| 542 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) | 544 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) |
| 543 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, | 545 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, |
| 544 OnCustomContextMenuAction) | 546 OnCustomContextMenuAction) |
| 547 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
| 548 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) |
| 549 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) |
| 545 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) | 550 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 546 IPC_END_MESSAGE_MAP_EX() | 551 IPC_END_MESSAGE_MAP_EX() |
| 547 | 552 |
| 548 if (!msg_is_ok) { | 553 if (!msg_is_ok) { |
| 549 // The message had a handler, but its deserialization failed. | 554 // The message had a handler, but its deserialization failed. |
| 550 // Kill the renderer to avoid potential spoofing attacks. | 555 // Kill the renderer to avoid potential spoofing attacks. |
| 551 CHECK(false) << "Unable to deserialize message in RenderFrameImpl."; | 556 CHECK(false) << "Unable to deserialize message in RenderFrameImpl."; |
| 552 } | 557 } |
| 553 | 558 |
| 554 return handled; | 559 return handled; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 ContextMenuClient* client = | 839 ContextMenuClient* client = |
| 835 pending_context_menus_.Lookup(custom_context.request_id); | 840 pending_context_menus_.Lookup(custom_context.request_id); |
| 836 if (client) | 841 if (client) |
| 837 client->OnMenuAction(custom_context.request_id, action); | 842 client->OnMenuAction(custom_context.request_id, action); |
| 838 } else { | 843 } else { |
| 839 // Internal request, forward to WebKit. | 844 // Internal request, forward to WebKit. |
| 840 render_view_->webview()->performCustomContextMenuAction(action); | 845 render_view_->webview()->performCustomContextMenuAction(action); |
| 841 } | 846 } |
| 842 } | 847 } |
| 843 | 848 |
| 849 void RenderFrameImpl::OnCut() { |
| 850 base::AutoReset<bool> handling_select_range( |
| 851 &render_view_->handling_select_range_, true); |
| 852 frame_->executeCommand(WebString::fromUTF8("Cut"), GetFocusedElement()); |
| 853 } |
| 854 |
| 855 void RenderFrameImpl::OnCopy() { |
| 856 base::AutoReset<bool> handling_select_range( |
| 857 &render_view_->handling_select_range_, true); |
| 858 WebNode current_node = render_view_->context_menu_node_.isNull() ? |
| 859 GetFocusedElement() : render_view_->context_menu_node_; |
| 860 frame_->executeCommand(WebString::fromUTF8("Copy"), current_node); |
| 861 } |
| 862 |
| 863 void RenderFrameImpl::OnPaste() { |
| 864 base::AutoReset<bool> handling_select_range( |
| 865 &render_view_->handling_select_range_, true); |
| 866 frame_->executeCommand(WebString::fromUTF8("Paste"), GetFocusedElement()); |
| 867 } |
| 868 |
| 844 void RenderFrameImpl::OnCSSInsertRequest(const std::string& css) { | 869 void RenderFrameImpl::OnCSSInsertRequest(const std::string& css) { |
| 845 frame_->document().insertStyleSheet(WebString::fromUTF8(css)); | 870 frame_->document().insertStyleSheet(WebString::fromUTF8(css)); |
| 846 } | 871 } |
| 847 | 872 |
| 848 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( | 873 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( |
| 849 const base::string16& selection_text, | 874 const base::string16& selection_text, |
| 850 size_t selection_text_offset, | 875 size_t selection_text_offset, |
| 851 const gfx::Range& selection_range, | 876 const gfx::Range& selection_range, |
| 852 const ContextMenuParams& params) { | 877 const ContextMenuParams& params) { |
| 853 base::string16 trimmed_selection_text; | 878 base::string16 trimmed_selection_text; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1125 |
| 1101 // |frame| is invalid after here. | 1126 // |frame| is invalid after here. |
| 1102 frame->close(); | 1127 frame->close(); |
| 1103 | 1128 |
| 1104 if (is_subframe) { | 1129 if (is_subframe) { |
| 1105 delete this; | 1130 delete this; |
| 1106 // Object is invalid after this point. | 1131 // Object is invalid after this point. |
| 1107 } | 1132 } |
| 1108 } | 1133 } |
| 1109 | 1134 |
| 1135 void RenderFrameImpl::frameFocused() { |
| 1136 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
| 1137 } |
| 1138 |
| 1110 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 1139 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
| 1111 DCHECK(!frame_ || frame_ == frame); | 1140 DCHECK(!frame_ || frame_ == frame); |
| 1112 // Call back to RenderViewImpl for observers to be notified. | 1141 // Call back to RenderViewImpl for observers to be notified. |
| 1113 // TODO(nasko): Remove once we have RenderFrameObserver. | 1142 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 1114 render_view_->willClose(frame); | 1143 render_view_->willClose(frame); |
| 1115 } | 1144 } |
| 1116 | 1145 |
| 1117 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, | 1146 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, |
| 1118 const blink::WebString& name) { | 1147 const blink::WebString& name) { |
| 1119 DCHECK(!frame_ || frame_ == frame); | 1148 DCHECK(!frame_ || frame_ == frame); |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 | 2390 |
| 2362 render_view_->last_page_id_sent_to_browser_ = | 2391 render_view_->last_page_id_sent_to_browser_ = |
| 2363 std::max(render_view_->last_page_id_sent_to_browser_, | 2392 std::max(render_view_->last_page_id_sent_to_browser_, |
| 2364 render_view_->page_id_); | 2393 render_view_->page_id_); |
| 2365 | 2394 |
| 2366 // If we end up reusing this WebRequest (for example, due to a #ref click), | 2395 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 2367 // we don't want the transition type to persist. Just clear it. | 2396 // we don't want the transition type to persist. Just clear it. |
| 2368 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); | 2397 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
| 2369 } | 2398 } |
| 2370 | 2399 |
| 2400 WebElement RenderFrameImpl::GetFocusedElement() { |
| 2401 WebDocument doc = frame_->document(); |
| 2402 if (!doc.isNull()) |
| 2403 return doc.focusedElement(); |
| 2404 |
| 2405 return WebElement(); |
| 2406 } |
| 2407 |
| 2371 void RenderFrameImpl::didStartLoading() { | 2408 void RenderFrameImpl::didStartLoading() { |
| 2372 Send(new FrameHostMsg_DidStartLoading(routing_id_)); | 2409 Send(new FrameHostMsg_DidStartLoading(routing_id_)); |
| 2373 } | 2410 } |
| 2374 | 2411 |
| 2375 void RenderFrameImpl::didStopLoading() { | 2412 void RenderFrameImpl::didStopLoading() { |
| 2376 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 2413 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 2377 } | 2414 } |
| 2378 | 2415 |
| 2379 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 2416 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
| 2380 RenderFrame* render_frame, | 2417 RenderFrame* render_frame, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 policy == blink::WebNavigationPolicyNewForegroundTab || | 2665 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 2629 policy == blink::WebNavigationPolicyNewWindow || | 2666 policy == blink::WebNavigationPolicyNewWindow || |
| 2630 policy == blink::WebNavigationPolicyNewPopup) { | 2667 policy == blink::WebNavigationPolicyNewPopup) { |
| 2631 WebUserGestureIndicator::consumeUserGesture(); | 2668 WebUserGestureIndicator::consumeUserGesture(); |
| 2632 } | 2669 } |
| 2633 | 2670 |
| 2634 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 2671 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 2635 } | 2672 } |
| 2636 | 2673 |
| 2637 } // namespace content | 2674 } // namespace content |
| OLD | NEW |