summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-02 20:47:06 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-02 20:47:06 +0000
commitea8c745aa6a3be27b904060832fdf14bb11193bf (patch)
tree32ba371b6f4d59b7e8bcc987a2912aa645ba73a0 /chrome/browser/renderer_host
parentac8e3525fa24068878ef8a45f35aba681f852cc9 (diff)
downloadchromium_src-ea8c745aa6a3be27b904060832fdf14bb11193bf.zip
chromium_src-ea8c745aa6a3be27b904060832fdf14bb11193bf.tar.gz
chromium_src-ea8c745aa6a3be27b904060832fdf14bb11193bf.tar.bz2
Paste from the x clipboard into webkit.
Review URL: http://codereview.chromium.org/51008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-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
5 files changed, 34 insertions, 0 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.