summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc7
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc14
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.h7
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/render_view.cc9
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--webkit/glue/webview.h4
-rw-r--r--webkit/glue/webview_delegate.h8
-rw-r--r--webkit/glue/webview_impl.cc29
-rw-r--r--webkit/glue/webview_impl.h1
12 files changed, 95 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index cd08a0c..84994bb 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -772,6 +772,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnRemoveAutofillEntry)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFeedList, OnMsgUpdateFeedList)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_PasteFromSelectionClipboard,
+ OnPasteFromSelectionClipboard)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP_EX()
@@ -1364,3 +1366,8 @@ void RenderViewHost::SendExtensionResponse(int callback_id,
const std::string& response) {
Send(new ViewMsg_ExtensionResponse(routing_id(), callback_id, response));
}
+
+void RenderViewHost::OnPasteFromSelectionClipboard() {
+ if (view())
+ view()->PasteFromSelectionClipboard();
+}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 6cfe2b2..c150259 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -565,6 +565,8 @@ class RenderViewHost : public RenderWidgetHost {
void OnExtensionRequest(const std::string& name, const std::string& args,
int callback_id);
+ void OnPasteFromSelectionClipboard();
+
// Helper function to send a navigation message. If a cross-site request is
// in progress, we may be suspended while waiting for the onbeforeunload
// handler, so this function might buffer the message rather than sending it.
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 7d24eec..255f6644 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -112,6 +112,10 @@ class RenderWidgetHostView {
// the page has changed.
virtual void SetTooltipText(const std::wstring& tooltip_text) = 0;
+ // Tells the View to get the text from the selection clipboard and send it
+ // back to the renderer asynchronously.
+ virtual void PasteFromSelectionClipboard() { }
+
// Allocate a backing store for this view
virtual BackingStore* AllocBackingStore(const gfx::Size& size) = 0;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
index a0328aa..21b45d1 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/common/native_web_keyboard_event.h"
+#include "chrome/common/render_messages.h"
#include "chrome/common/x11_util.h"
#include "chrome/browser/renderer_host/backing_store.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
@@ -320,6 +321,11 @@ BackingStore* RenderWidgetHostViewGtk::AllocBackingStore(
use_render, use_shared_memory);
}
+void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() {
+ GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this);
+}
+
void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) {
BackingStore* backing_store = host_->GetBackingStore();
@@ -380,3 +386,11 @@ void RenderWidgetHostViewGtk::ShowCurrentCursor() {
if (gdk_cursor)
gdk_cursor_unref(gdk_cursor);
}
+
+void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard,
+ const gchar* text, gpointer userdata) {
+ RenderWidgetHostViewGtk* host_view =
+ reinterpret_cast<RenderWidgetHostViewGtk*>(userdata);
+ host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(),
+ UTF8ToUTF16(text)));
+}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
index 6a7a792..f3fc7ba 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
@@ -14,6 +14,8 @@
class RenderWidgetHost;
+typedef struct _GtkClipboard GtkClipboard;
+
// -----------------------------------------------------------------------------
// See comments in render_widget_host_view.h about this class and its members.
// -----------------------------------------------------------------------------
@@ -56,6 +58,7 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView {
void RenderViewGone();
void Destroy();
void SetTooltipText(const std::wstring& tooltip_text);
+ void PasteFromSelectionClipboard();
BackingStore* AllocBackingStore(const gfx::Size& size);
// ---------------------------------------------------------------------------
@@ -67,6 +70,10 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView {
// Update the display cursor for the render view.
void ShowCurrentCursor();
+ static void ReceivedSelectionText(GtkClipboard* clipboard,
+ const gchar* text,
+ gpointer userdata);
+
// The model object.
RenderWidgetHost *const host_;
// The native UI widget.
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 5a32a0b..5e664c3 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -254,6 +254,10 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_ROUTED1(ViewMsg_Zoom,
int /* One of PageZoom::Function */)
+ // Insert text in the currently focused input area.
+ IPC_MESSAGE_ROUTED1(ViewMsg_InsertText,
+ string16 /* text */)
+
// Change encoding of page in the renderer.
IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding,
std::wstring /*new encoding name*/)
@@ -803,6 +807,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32 /* page_id */,
GURL /* url of the favicon */)
+ // Request that the browser get the text from the selection clipboard and send
+ // it back to the renderer via ViewMsg_SelectionClipboardResponse.
+ IPC_MESSAGE_ROUTED0(ViewHostMsg_PasteFromSelectionClipboard)
+
// Used to tell the parent that the user right clicked on an area of the
// content area, and a context menu should be shown for it. The params
// object contains information about the node(s) that were selected when the
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d2c052c..1011647 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -358,6 +358,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
+ IPC_MESSAGE_HANDLER(ViewMsg_InsertText, OnInsertText)
IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
IPC_MESSAGE_HANDLER(ViewMsg_InspectElement, OnInspectElement)
IPC_MESSAGE_HANDLER(ViewMsg_ShowJavaScriptConsole, OnShowJavaScriptConsole)
@@ -2362,6 +2363,10 @@ void RenderView::OnZoom(int function) {
}
}
+void RenderView::OnInsertText(const string16& text) {
+ webview()->InsertText(text);
+}
+
void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) {
webview()->SetPageEncoding(encoding_name);
}
@@ -2425,6 +2430,10 @@ WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() {
return devtools_agent_;
}
+void RenderView::PasteFromSelectionClipboard() {
+ Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_));
+}
+
WebFrame* RenderView::GetChildFrame(const std::wstring& frame_xpath) const {
WebFrame* web_frame;
if (frame_xpath.empty()) {
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index d6bf327..7f20d60 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -285,6 +285,8 @@ class RenderView : public RenderWidget,
virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate();
+ virtual void PasteFromSelectionClipboard();
+
virtual void OnPasswordFormsSeen(WebView* webview,
const std::vector<PasswordForm>& forms);
@@ -487,6 +489,7 @@ class RenderView : public RenderWidget,
void OnCancelDownload(int32 download_id);
void OnFind(const WebKit::WebFindInPageRequest& request);
void OnZoom(int function);
+ void OnInsertText(const string16& text);
void OnSetPageEncoding(const std::wstring& encoding_name);
void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index fb557e9..344dd26 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/string16.h"
#include "webkit/glue/webwidget.h"
struct WebDropData;
@@ -157,6 +158,9 @@ class WebView : public WebWidget {
virtual void ZoomOut(bool text_only) = 0;
virtual void ResetZoom() = 0;
+ // Insert text into the current editor.
+ virtual void InsertText(const string16& text) = 0;
+
// Copy to the clipboard the image located at a particular point in the
// WebView (if there is such an image)
virtual void CopyImageAt(int x, int y) = 0;
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index a99e102..cf6abaf0 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -753,6 +753,14 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // Selection clipboard -----------------------------------------------------
+
+ // Request the text on the selection clipboard be sent back to the webview
+ // so it can be inserted into the current focus area. In response to this call
+ // the delegate should get the text and send it to the WebView via
+ // InsertText().
+ virtual void PasteFromSelectionClipboard() { }
+
// Editor Client -----------------------------------------------------------
// Returns true if the word is spelled correctly. The word may begin or end
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 15da11f..a79c63c 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -457,7 +457,7 @@ void WebViewImpl::MouseDown(const WebMouseEvent& event) {
if (clicked_node.get() && clicked_node == GetFocusedNode()) {
// Focus has not changed, show the autocomplete popup.
static_cast<EditorClientImpl*>(page_->editorClient())->
- ShowAutofillForNode(clicked_node.get());
+ ShowAutofillForNode(clicked_node.get());
}
// Dispatch the contextmenu event regardless of if the click was swallowed.
@@ -472,6 +472,21 @@ void WebViewImpl::MouseDown(const WebMouseEvent& event) {
if (event.button == WebMouseEvent::ButtonRight)
MouseContextMenu(event);
#endif
+
+#if defined(OS_LINUX)
+ // If the event was a middle click, attempt to copy text into the focused
+ // frame.
+ if (event.button == WebMouseEvent::ButtonMiddle) {
+ Frame* focused = GetFocusedWebCoreFrame();
+ if (!focused)
+ return;
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return;
+
+ delegate_->PasteFromSelectionClipboard();
+ }
+#endif
}
void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) {
@@ -1481,6 +1496,18 @@ void WebViewImpl::ResetZoom() {
main_frame()->frame()->isZoomFactorTextOnly());
}
+void WebViewImpl::InsertText(const string16& text) {
+ Frame* focused = GetFocusedWebCoreFrame();
+ if (!focused)
+ return;
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return;
+
+ editor->insertTextWithoutSendingTextEvent(
+ webkit_glue::String16ToString(text), false, NULL);
+}
+
void WebViewImpl::CopyImageAt(int x, int y) {
if (!page_.get())
return;
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index d080909..2baf9de 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -93,6 +93,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void ZoomIn(bool text_only);
virtual void ZoomOut(bool text_only);
virtual void ResetZoom();
+ virtual void InsertText(const string16& text);
virtual void CopyImageAt(int x, int y);
virtual void InspectElement(int x, int y);
virtual void ShowJavaScriptConsole();