Index: content/renderer/render_frame_impl.cc |
=================================================================== |
--- content/renderer/render_frame_impl.cc (revision 254898) |
+++ content/renderer/render_frame_impl.cc (working copy) |
@@ -7,6 +7,7 @@ |
#include <map> |
#include <string> |
+#include "base/auto_reset.h" |
#include "base/command_line.h" |
#include "base/debug/alias.h" |
#include "base/debug/dump_without_crashing.h" |
@@ -23,6 +24,7 @@ |
#include "content/child/service_worker/web_service_worker_provider_impl.h" |
#include "content/child/web_socket_stream_handle_impl.h" |
#include "content/common/frame_messages.h" |
+#include "content/common/input_messages.h" |
#include "content/common/socket_stream_handle_data.h" |
#include "content/common/swapped_out_messages.h" |
#include "content/common/view_messages.h" |
@@ -92,11 +94,13 @@ |
using blink::WebData; |
using blink::WebDataSource; |
using blink::WebDocument; |
+using blink::WebElement; |
using blink::WebFrame; |
using blink::WebHistoryItem; |
using blink::WebHTTPBody; |
using blink::WebNavigationPolicy; |
using blink::WebNavigationType; |
+using blink::WebNode; |
using blink::WebPluginParams; |
using blink::WebReferrerPolicy; |
using blink::WebSearchableFormData; |
@@ -356,10 +360,8 @@ |
return; |
GetRenderWidget()->UpdateTextInputType(); |
- if (render_view_->renderer_accessibility()) { |
- render_view_->renderer_accessibility()->FocusedNodeChanged( |
- blink::WebNode()); |
- } |
+ if (render_view_->renderer_accessibility()) |
+ render_view_->renderer_accessibility()->FocusedNodeChanged(WebNode()); |
} |
void RenderFrameImpl::PepperCaretPositionChanged( |
@@ -540,6 +542,9 @@ |
IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) |
IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, |
OnCustomContextMenuAction) |
+ IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
+ IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) |
+ IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) |
IPC_END_MESSAGE_MAP_EX() |
if (!msg_is_ok) { |
@@ -838,6 +843,26 @@ |
} |
} |
+void RenderFrameImpl::OnCut() { |
+ base::AutoReset<bool> handling_select_range( |
+ &render_view_->handling_select_range_, true); |
+ frame_->executeCommand(WebString::fromUTF8("Cut"), GetFocusedElement()); |
+} |
+ |
+void RenderFrameImpl::OnCopy() { |
+ base::AutoReset<bool> handling_select_range( |
+ &render_view_->handling_select_range_, true); |
+ WebNode current_node = render_view_->context_menu_node_.isNull() ? |
+ GetFocusedElement() : render_view_->context_menu_node_; |
+ frame_->executeCommand(WebString::fromUTF8("Copy"), current_node); |
+} |
+ |
+void RenderFrameImpl::OnPaste() { |
+ base::AutoReset<bool> handling_select_range( |
+ &render_view_->handling_select_range_, true); |
+ frame_->executeCommand(WebString::fromUTF8("Paste"), GetFocusedElement()); |
+} |
+ |
bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams( |
const base::string16& selection_text, |
size_t selection_text_offset, |
@@ -2315,6 +2340,14 @@ |
navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
} |
+WebElement RenderFrameImpl::GetFocusedElement() { |
+ WebDocument doc = frame_->document(); |
+ if (!doc.isNull()) |
+ return doc.focusedElement(); |
+ |
+ return WebElement(); |
+} |
+ |
void RenderFrameImpl::didStartLoading() { |
Send(new FrameHostMsg_DidStartLoading(routing_id_)); |
} |