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

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, 7 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 698 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
699 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) 699 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest)
700 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, 700 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest,
701 OnJavaScriptExecuteRequest) 701 OnJavaScriptExecuteRequest)
702 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, 702 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets,
703 OnSetEditableSelectionOffsets) 703 OnSetEditableSelectionOffsets)
704 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, 704 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText,
705 OnSetCompositionFromExistingText) 705 OnSetCompositionFromExistingText)
706 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, 706 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete,
707 OnExtendSelectionAndDelete) 707 OnExtendSelectionAndDelete)
708 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
709 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
710 OnTextSurroundingSelectionRequest)
708 #if defined(OS_MACOSX) 711 #if defined(OS_MACOSX)
709 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 712 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
710 #endif 713 #endif
711 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
712 IPC_END_MESSAGE_MAP() 714 IPC_END_MESSAGE_MAP()
713 715
714 return handled; 716 return handled;
715 } 717 }
716 718
717 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 719 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
718 MaybeHandleDebugURL(params.url); 720 MaybeHandleDebugURL(params.url);
719 if (!render_view_->webview()) 721 if (!render_view_->webview())
720 return; 722 return;
721 723
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 frame_->setCompositionFromExistingText(start, end, underlines); 1182 frame_->setCompositionFromExistingText(start, end, underlines);
1181 } 1183 }
1182 1184
1183 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { 1185 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) {
1184 if (!GetRenderWidget()->ShouldHandleImeEvent()) 1186 if (!GetRenderWidget()->ShouldHandleImeEvent())
1185 return; 1187 return;
1186 ImeEventGuard guard(GetRenderWidget()); 1188 ImeEventGuard guard(GetRenderWidget());
1187 frame_->extendSelectionAndDelete(before, after); 1189 frame_->extendSelectionAndDelete(before, after);
1188 } 1190 }
1189 1191
1190
1191 void RenderFrameImpl::OnReload(bool ignore_cache) { 1192 void RenderFrameImpl::OnReload(bool ignore_cache) {
1192 frame_->reload(ignore_cache); 1193 frame_->reload(ignore_cache);
1193 } 1194 }
1194 1195
1196 void RenderFrameImpl::OnTextSurroundingSelectionRequest(unsigned max_length) {
1197 unsigned start_offset, end_offset;
1198 base::string16 content =
1199 frame_->textSurroundingSelection(max_length, &start_offset, &end_offset);
1200
1201 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
1202 routing_id_, content, start_offset, end_offset));
1203 }
1204
1195 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( 1205 bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
1196 const base::string16& selection_text, 1206 const base::string16& selection_text,
1197 size_t selection_text_offset, 1207 size_t selection_text_offset,
1198 const gfx::Range& selection_range, 1208 const gfx::Range& selection_range,
1199 const ContextMenuParams& params) { 1209 const ContextMenuParams& params) {
1200 base::string16 trimmed_selection_text; 1210 base::string16 trimmed_selection_text;
1201 if (!selection_text.empty() && !selection_range.is_empty()) { 1211 if (!selection_text.empty() && !selection_range.is_empty()) {
1202 const int start = selection_range.GetMin() - selection_text_offset; 1212 const int start = selection_range.GetMin() - selection_text_offset;
1203 const size_t length = selection_range.length(); 1213 const size_t length = selection_range.length();
1204 if (start >= 0 && start + length <= selection_text.length()) { 1214 if (start >= 0 && start + length <= selection_text.length()) {
(...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 weak_factory_.GetWeakPtr(), 3500 weak_factory_.GetWeakPtr(),
3491 render_view_->media_player_manager_, 3501 render_view_->media_player_manager_,
3492 stream_texture_factory, 3502 stream_texture_factory,
3493 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), 3503 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(),
3494 new RenderMediaLog()); 3504 new RenderMediaLog());
3495 } 3505 }
3496 3506
3497 #endif 3507 #endif
3498 3508
3499 } // namespace content 3509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698