summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-16 02:46:15 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-16 02:46:15 +0000
commit44bf7009a31eacc334fbf2dd33b8a97924deff54 (patch)
tree1b6b610d4c4d06bfaedf853ad16843854bb51037 /content
parent0ef58fd2c529dd425c7e3beea4a88325983c870e (diff)
downloadchromium_src-44bf7009a31eacc334fbf2dd33b8a97924deff54.zip
chromium_src-44bf7009a31eacc334fbf2dd33b8a97924deff54.tar.gz
chromium_src-44bf7009a31eacc334fbf2dd33b8a97924deff54.tar.bz2
Add a contextual menu command for 'Paste and plain text' (or 'Paste and Match Style' on Mac)
MainMenu.xib details: - Change 'Paste and Match Style' to send the pasteAndMatchStyle: message. BUG=25238 TEST=In an editable field on a web page, right-click to 'Paste as plain text'. Review URL: http://codereview.chromium.org/8234006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_widget_host.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host.h1
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm21
-rw-r--r--content/common/view_messages.h1
-rw-r--r--content/renderer/render_view_impl.cc9
-rw-r--r--content/renderer/render_view_impl.h1
6 files changed, 27 insertions, 11 deletions
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
index 1aa93ca..43639bf 100644
--- a/content/browser/renderer_host/render_widget_host.cc
+++ b/content/browser/renderer_host/render_widget_host.cc
@@ -1377,6 +1377,11 @@ void RenderWidgetHost::Paste() {
UserMetrics::RecordAction(UserMetricsAction("Paste"));
}
+void RenderWidgetHost::PasteAndMatchStyle() {
+ Send(new ViewMsg_PasteAndMatchStyle(routing_id()));
+ UserMetrics::RecordAction(UserMetricsAction("PasteAndMatchStyle"));
+}
+
void RenderWidgetHost::Delete() {
Send(new ViewMsg_Delete(routing_id()));
UserMetrics::RecordAction(UserMetricsAction("DeleteSelection"));
diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h
index c31a16d..25cec88 100644
--- a/content/browser/renderer_host/render_widget_host.h
+++ b/content/browser/renderer_host/render_widget_host.h
@@ -419,6 +419,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener,
void Copy();
void CopyToFindPboard();
void Paste();
+ void PasteAndMatchStyle();
void Delete();
void SelectAll();
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 587f55a..b5dafbf 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1911,7 +1911,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
action == @selector(copy:) ||
action == @selector(copyToFindPboard:) ||
action == @selector(paste:) ||
- action == @selector(pasteAsPlainText:)) {
+ action == @selector(pasteAndMatchStyle:)) {
return renderWidgetHostView_->render_widget_host_->IsRenderView();
}
@@ -2566,50 +2566,49 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
- (void)undo:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- Undo();
+ Undo();
}
}
- (void)redo:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- Redo();
+ Redo();
}
}
- (void)cut:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- Cut();
+ Cut();
}
}
- (void)copy:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- Copy();
+ Copy();
}
}
- (void)copyToFindPboard:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- CopyToFindPboard();
+ CopyToFindPboard();
}
}
- (void)paste:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
- Paste();
+ Paste();
}
}
-- (void)pasteAsPlainText:(id)sender {
+- (void)pasteAndMatchStyle:(id)sender {
if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
- RenderWidgetHost* rwh = renderWidgetHostView_->render_widget_host_;
- rwh->Send(new ViewMsg_ExecuteEditCommand(
- rwh->routing_id(), "PasteAndMatchStyle", ""));
+ static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
+ PasteAndMatchStyle();
}
}
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index bba5d05..073b810 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -844,6 +844,7 @@ IPC_MESSAGE_ROUTED0(ViewMsg_Copy)
IPC_MESSAGE_ROUTED0(ViewMsg_CopyToFindPboard)
#endif
IPC_MESSAGE_ROUTED0(ViewMsg_Paste)
+IPC_MESSAGE_ROUTED0(ViewMsg_PasteAndMatchStyle)
// Replaces the selected region or a word around the cursor with the
// specified string.
IPC_MESSAGE_ROUTED1(ViewMsg_Replace,
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 7a87234..d3dfc1f 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -581,6 +581,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
#endif
IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
+ IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
@@ -942,6 +943,14 @@ void RenderViewImpl::OnPaste() {
webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste"));
}
+void RenderViewImpl::OnPasteAndMatchStyle() {
+ if (!webview())
+ return;
+
+ webview()->focusedFrame()->executeCommand(
+ WebString::fromUTF8("PasteAndMatchStyle"));
+}
+
void RenderViewImpl::OnReplace(const string16& text) {
if (!webview())
return;
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 72d8827..2ae0e9d 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -805,6 +805,7 @@ class RenderViewImpl : public RenderWidget,
void OnMoveOrResizeStarted();
CONTENT_EXPORT void OnNavigate(const ViewMsg_Navigate_Params& params);
void OnPaste();
+ void OnPasteAndMatchStyle();
#if defined(OS_MACOSX)
void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
#endif