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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 96 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
97 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 97 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
98 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 98 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
99 #include "third_party/WebKit/public/web/WebPlugin.h" | 99 #include "third_party/WebKit/public/web/WebPlugin.h" |
100 #include "third_party/WebKit/public/web/WebPluginParams.h" | 100 #include "third_party/WebKit/public/web/WebPluginParams.h" |
101 #include "third_party/WebKit/public/web/WebRange.h" | 101 #include "third_party/WebKit/public/web/WebRange.h" |
102 #include "third_party/WebKit/public/web/WebScriptSource.h" | 102 #include "third_party/WebKit/public/web/WebScriptSource.h" |
103 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 103 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
104 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 104 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
105 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 105 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 106 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
106 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 107 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
107 #include "third_party/WebKit/public/web/WebView.h" | 108 #include "third_party/WebKit/public/web/WebView.h" |
108 #include "webkit/child/weburlresponse_extradata_impl.h" | 109 #include "webkit/child/weburlresponse_extradata_impl.h" |
109 | 110 |
110 #if defined(ENABLE_PLUGINS) | 111 #if defined(ENABLE_PLUGINS) |
111 #include "content/renderer/npapi/webplugin_impl.h" | 112 #include "content/renderer/npapi/webplugin_impl.h" |
112 #include "content/renderer/pepper/pepper_browser_connection.h" | 113 #include "content/renderer/pepper/pepper_browser_connection.h" |
113 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 114 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
114 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 115 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
115 #include "content/renderer/pepper/plugin_module.h" | 116 #include "content/renderer/pepper/plugin_module.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) | 716 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) |
716 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) | 717 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) |
717 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, | 718 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, |
718 OnJavaScriptExecuteRequest) | 719 OnJavaScriptExecuteRequest) |
719 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, | 720 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, |
720 OnSetEditableSelectionOffsets) | 721 OnSetEditableSelectionOffsets) |
721 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, | 722 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, |
722 OnSetCompositionFromExistingText) | 723 OnSetCompositionFromExistingText) |
723 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, | 724 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, |
724 OnExtendSelectionAndDelete) | 725 OnExtendSelectionAndDelete) |
| 726 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) |
| 727 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, |
| 728 OnTextSurroundingSelectionRequest) |
725 #if defined(OS_MACOSX) | 729 #if defined(OS_MACOSX) |
726 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 730 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
727 #endif | 731 #endif |
728 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) | |
729 IPC_END_MESSAGE_MAP() | 732 IPC_END_MESSAGE_MAP() |
730 | 733 |
731 return handled; | 734 return handled; |
732 } | 735 } |
733 | 736 |
734 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { | 737 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { |
735 MaybeHandleDebugURL(params.url); | 738 MaybeHandleDebugURL(params.url); |
736 if (!render_view_->webview()) | 739 if (!render_view_->webview()) |
737 return; | 740 return; |
738 | 741 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 frame_->setCompositionFromExistingText(start, end, underlines); | 1200 frame_->setCompositionFromExistingText(start, end, underlines); |
1198 } | 1201 } |
1199 | 1202 |
1200 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { | 1203 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { |
1201 if (!GetRenderWidget()->ShouldHandleImeEvent()) | 1204 if (!GetRenderWidget()->ShouldHandleImeEvent()) |
1202 return; | 1205 return; |
1203 ImeEventGuard guard(GetRenderWidget()); | 1206 ImeEventGuard guard(GetRenderWidget()); |
1204 frame_->extendSelectionAndDelete(before, after); | 1207 frame_->extendSelectionAndDelete(before, after); |
1205 } | 1208 } |
1206 | 1209 |
1207 | |
1208 void RenderFrameImpl::OnReload(bool ignore_cache) { | 1210 void RenderFrameImpl::OnReload(bool ignore_cache) { |
1209 frame_->reload(ignore_cache); | 1211 frame_->reload(ignore_cache); |
1210 } | 1212 } |
1211 | 1213 |
| 1214 void RenderFrameImpl::OnTextSurroundingSelectionRequest(int max_length) { |
| 1215 blink::WebSurroundingText surroundingText; |
| 1216 surroundingText.initialize(frame_->selectionRange(), max_length); |
| 1217 |
| 1218 if (surroundingText.isNull()) { |
| 1219 // |surroundingText| might not be correctly initialized in some edge cases, |
| 1220 // we shouldn't call any method in that case. |
| 1221 Send(new FrameHostMsg_TextSurroundingSelectionResponse( |
| 1222 routing_id_, base::string16(), 0, 0)); |
| 1223 return; |
| 1224 } |
| 1225 |
| 1226 Send(new FrameHostMsg_TextSurroundingSelectionResponse( |
| 1227 routing_id_, |
| 1228 surroundingText.textContent(), |
| 1229 surroundingText.startOffsetInTextContent(), |
| 1230 surroundingText.endOffsetInTextContent())); |
| 1231 } |
| 1232 |
1212 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( | 1233 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( |
1213 const base::string16& selection_text, | 1234 const base::string16& selection_text, |
1214 size_t selection_text_offset, | 1235 size_t selection_text_offset, |
1215 const gfx::Range& selection_range, | 1236 const gfx::Range& selection_range, |
1216 const ContextMenuParams& params) { | 1237 const ContextMenuParams& params) { |
1217 base::string16 trimmed_selection_text; | 1238 base::string16 trimmed_selection_text; |
1218 if (!selection_text.empty() && !selection_range.is_empty()) { | 1239 if (!selection_text.empty() && !selection_range.is_empty()) { |
1219 const int start = selection_range.GetMin() - selection_text_offset; | 1240 const int start = selection_range.GetMin() - selection_text_offset; |
1220 const size_t length = selection_range.length(); | 1241 const size_t length = selection_range.length(); |
1221 if (start >= 0 && start + length <= selection_text.length()) { | 1242 if (start >= 0 && start + length <= selection_text.length()) { |
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 | 3594 |
3574 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3595 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3575 if (!cdm_manager_) | 3596 if (!cdm_manager_) |
3576 cdm_manager_ = new RendererCdmManager(this); | 3597 cdm_manager_ = new RendererCdmManager(this); |
3577 return cdm_manager_; | 3598 return cdm_manager_; |
3578 } | 3599 } |
3579 | 3600 |
3580 #endif // defined(OS_ANDROID) | 3601 #endif // defined(OS_ANDROID) |
3581 | 3602 |
3582 } // namespace content | 3603 } // namespace content |
OLD | NEW |