summaryrefslogtreecommitdiffstats
path: root/webkit
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 /webkit
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 'webkit')
-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
4 files changed, 41 insertions, 1 deletions
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();