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

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

Issue 292113008: Plumbing for browser process to access text surrounding selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adb_install_humans
Patch Set: Created 6 years, 6 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 722 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
722 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) 723 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest)
723 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, 724 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest,
724 OnJavaScriptExecuteRequest) 725 OnJavaScriptExecuteRequest)
725 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, 726 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets,
726 OnSetEditableSelectionOffsets) 727 OnSetEditableSelectionOffsets)
727 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, 728 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText,
728 OnSetCompositionFromExistingText) 729 OnSetCompositionFromExistingText)
729 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, 730 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete,
730 OnExtendSelectionAndDelete) 731 OnExtendSelectionAndDelete)
732 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
733 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
734 OnTextSurroundingSelectionRequest)
731 #if defined(OS_MACOSX) 735 #if defined(OS_MACOSX)
732 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 736 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
733 #endif 737 #endif
734 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
735 IPC_END_MESSAGE_MAP() 738 IPC_END_MESSAGE_MAP()
736 739
737 return handled; 740 return handled;
738 } 741 }
739 742
740 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 743 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
741 MaybeHandleDebugURL(params.url); 744 MaybeHandleDebugURL(params.url);
742 if (!render_view_->webview()) 745 if (!render_view_->webview())
743 return; 746 return;
744 747
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 frame_->setCompositionFromExistingText(start, end, underlines); 1207 frame_->setCompositionFromExistingText(start, end, underlines);
1205 } 1208 }
1206 1209
1207 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { 1210 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) {
1208 if (!GetRenderWidget()->ShouldHandleImeEvent()) 1211 if (!GetRenderWidget()->ShouldHandleImeEvent())
1209 return; 1212 return;
1210 ImeEventGuard guard(GetRenderWidget()); 1213 ImeEventGuard guard(GetRenderWidget());
1211 frame_->extendSelectionAndDelete(before, after); 1214 frame_->extendSelectionAndDelete(before, after);
1212 } 1215 }
1213 1216
1214
1215 void RenderFrameImpl::OnReload(bool ignore_cache) { 1217 void RenderFrameImpl::OnReload(bool ignore_cache) {
1216 frame_->reload(ignore_cache); 1218 frame_->reload(ignore_cache);
1217 } 1219 }
1218 1220
1221 void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) {
1222 blink::WebSurroundingText surroundingText;
1223 surroundingText.initialize(frame_->selectionRange(), max_length);
1224
1225 if (surroundingText.isNull()) {
1226 // |surroundingText| might not be correctly initialized, for example if
1227 // |frame_->selectionRange().isNull()|, in other words, if there was no
1228 // selection.
1229 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
1230 routing_id_, base::string16(), 0, 0));
1231 return;
1232 }
1233
1234 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
1235 routing_id_,
1236 surroundingText.textContent(),
1237 surroundingText.startOffsetInTextContent(),
1238 surroundingText.endOffsetInTextContent()));
1239 }
1240
1219 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( 1241 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
1220 const base::string16& selection_text, 1242 const base::string16& selection_text,
1221 size_t selection_text_offset, 1243 size_t selection_text_offset,
1222 const gfx::Range& selection_range, 1244 const gfx::Range& selection_range,
1223 const ContextMenuParams& params) { 1245 const ContextMenuParams& params) {
1224 base::string16 trimmed_selection_text; 1246 base::string16 trimmed_selection_text;
1225 if (!selection_text.empty() && !selection_range.is_empty()) { 1247 if (!selection_text.empty() && !selection_range.is_empty()) {
1226 const int start = selection_range.GetMin() - selection_text_offset; 1248 const int start = selection_range.GetMin() - selection_text_offset;
1227 const size_t length = selection_range.length(); 1249 const size_t length = selection_range.length();
1228 if (start >= 0 && start + length <= selection_text.length()) { 1250 if (start >= 0 && start + length <= selection_text.length()) {
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 3603
3582 #if defined(ENABLE_BROWSER_CDMS) 3604 #if defined(ENABLE_BROWSER_CDMS)
3583 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3605 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3584 if (!cdm_manager_) 3606 if (!cdm_manager_)
3585 cdm_manager_ = new RendererCdmManager(this); 3607 cdm_manager_ = new RendererCdmManager(this);
3586 return cdm_manager_; 3608 return cdm_manager_;
3587 } 3609 }
3588 #endif // defined(ENABLE_BROWSER_CDMS) 3610 #endif // defined(ENABLE_BROWSER_CDMS)
3589 3611
3590 } // namespace content 3612 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698