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

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: rebase - use int 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
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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 710 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
711 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) 711 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest)
712 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, 712 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest,
713 OnJavaScriptExecuteRequest) 713 OnJavaScriptExecuteRequest)
714 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, 714 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets,
715 OnSetEditableSelectionOffsets) 715 OnSetEditableSelectionOffsets)
716 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, 716 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText,
717 OnSetCompositionFromExistingText) 717 OnSetCompositionFromExistingText)
718 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, 718 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete,
719 OnExtendSelectionAndDelete) 719 OnExtendSelectionAndDelete)
720 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
721 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
722 OnTextSurroundingSelectionRequest)
720 #if defined(OS_MACOSX) 723 #if defined(OS_MACOSX)
721 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 724 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
722 #endif 725 #endif
723 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
724 IPC_END_MESSAGE_MAP() 726 IPC_END_MESSAGE_MAP()
725 727
726 return handled; 728 return handled;
727 } 729 }
728 730
729 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 731 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
730 MaybeHandleDebugURL(params.url); 732 MaybeHandleDebugURL(params.url);
731 if (!render_view_->webview()) 733 if (!render_view_->webview())
732 return; 734 return;
733 735
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 frame_->setCompositionFromExistingText(start, end, underlines); 1194 frame_->setCompositionFromExistingText(start, end, underlines);
1193 } 1195 }
1194 1196
1195 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { 1197 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) {
1196 if (!GetRenderWidget()->ShouldHandleImeEvent()) 1198 if (!GetRenderWidget()->ShouldHandleImeEvent())
1197 return; 1199 return;
1198 ImeEventGuard guard(GetRenderWidget()); 1200 ImeEventGuard guard(GetRenderWidget());
1199 frame_->extendSelectionAndDelete(before, after); 1201 frame_->extendSelectionAndDelete(before, after);
1200 } 1202 }
1201 1203
1202
1203 void RenderFrameImpl::OnReload(bool ignore_cache) { 1204 void RenderFrameImpl::OnReload(bool ignore_cache) {
1204 frame_->reload(ignore_cache); 1205 frame_->reload(ignore_cache);
1205 } 1206 }
1206 1207
1208 void RenderFrameImpl::OnTextSurroundingSelectionRequest(int max_length) {
1209 int start_offset, end_offset;
1210 base::string16 content =
1211 frame_->textSurroundingSelection(max_length, &start_offset, &end_offset);
1212
1213 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
1214 routing_id_, content, start_offset, end_offset));
1215 }
1216
1207 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( 1217 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
1208 const base::string16& selection_text, 1218 const base::string16& selection_text,
1209 size_t selection_text_offset, 1219 size_t selection_text_offset,
1210 const gfx::Range& selection_range, 1220 const gfx::Range& selection_range,
1211 const ContextMenuParams& params) { 1221 const ContextMenuParams& params) {
1212 base::string16 trimmed_selection_text; 1222 base::string16 trimmed_selection_text;
1213 if (!selection_text.empty() && !selection_range.is_empty()) { 1223 if (!selection_text.empty() && !selection_range.is_empty()) {
1214 const int start = selection_range.GetMin() - selection_text_offset; 1224 const int start = selection_range.GetMin() - selection_text_offset;
1215 const size_t length = selection_range.length(); 1225 const size_t length = selection_range.length();
1216 if (start >= 0 && start + length <= selection_text.length()) { 1226 if (start >= 0 && start + length <= selection_text.length()) {
(...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3547 3557
3548 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3558 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3549 if (!cdm_manager_) 3559 if (!cdm_manager_)
3550 cdm_manager_ = new RendererCdmManager(this); 3560 cdm_manager_ = new RendererCdmManager(this);
3551 return cdm_manager_; 3561 return cdm_manager_;
3552 } 3562 }
3553 3563
3554 #endif // defined(OS_ANDROID) 3564 #endif // defined(OS_ANDROID)
3555 3565
3556 } // namespace content 3566 } // namespace content
OLDNEW
« content/browser/android/content_view_core_impl.cc ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698