diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 17:01:34 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 17:01:34 +0000 |
commit | 800b08d311a77748949ac4f0810a4df5d199d5da (patch) | |
tree | 9f372a5dadf80313c5aa1f7385676a63443bb91d /webkit/glue | |
parent | 1b74d2120db778a1809ddb5ca395e149d75e68f2 (diff) | |
download | chromium_src-800b08d311a77748949ac4f0810a4df5d199d5da.zip chromium_src-800b08d311a77748949ac4f0810a4df5d199d5da.tar.gz chromium_src-800b08d311a77748949ac4f0810a4df5d199d5da.tar.bz2 |
Add a private interface to the plugin and use it to know if the mouse is over a link.
Review URL: http://codereview.chromium.org/3562007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61658 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 27 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_webplugin_impl.cc | 11 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_webplugin_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/plugins/ppp_private.h | 20 |
5 files changed, 61 insertions, 2 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index 143d9c0..d9e60ae 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -54,6 +54,7 @@ #include "webkit/glue/plugins/pepper_string.h" #include "webkit/glue/plugins/pepper_url_loader.h" #include "webkit/glue/plugins/pepper_var.h" +#include "webkit/glue/plugins/ppp_private.h" using WebKit::WebBindings; using WebKit::WebCanvas; @@ -273,6 +274,7 @@ PluginInstance::PluginInstance(PluginDelegate* delegate, find_identifier_(-1), plugin_find_interface_(NULL), plugin_zoom_interface_(NULL), + plugin_private_interface_(NULL), #if defined (OS_LINUX) num_pages_(0), pdf_output_done_(false), @@ -587,6 +589,21 @@ string16 PluginInstance::GetSelectedText(bool html) { return UTF8ToUTF16(string->value()); } +string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { + if (!LoadPrivateInterface()) + return string16(); + + PP_Point p; + p.x = point.x(); + p.y = point.y(); + PP_Var rv = plugin_private_interface_->GetLinkAtPosition(GetPPInstance(), p); + scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); + Var::PluginReleasePPVar(rv); // Release the ref the plugin transfered to us. + if (!string) + return string16(); + return UTF8ToUTF16(string->value()); +} + void PluginInstance::Zoom(double factor, bool text_only) { if (!LoadZoomInterface()) return; @@ -637,6 +654,16 @@ bool PluginInstance::LoadZoomInterface() { return !!plugin_zoom_interface_; } +bool PluginInstance::LoadPrivateInterface() { + if (!plugin_private_interface_) { + plugin_private_interface_ = + reinterpret_cast<const PPP_Private*>(module_->GetPluginInterface( + PPP_PRIVATE_INTERFACE)); + } + + return !!plugin_private_interface_; +} + bool PluginInstance::PluginHasFocus() const { return has_webkit_focus_ && has_content_area_focus_; } diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index 97e026e..1604171 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -28,6 +28,7 @@ struct PPB_Fullscreen_Dev; struct PPB_Zoom_Dev; struct PPP_Find_Dev; struct PPP_Instance; +struct PPP_Private; struct PPP_Zoom_Dev; class SkBitmap; @@ -136,6 +137,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { gfx::Rect* clip); string16 GetSelectedText(bool html); + string16 GetLinkAtPosition(const gfx::Point& point); void Zoom(double factor, bool text_only); bool StartFind(const string16& search_text, bool case_sensitive, @@ -157,6 +159,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { private: bool LoadFindInterface(); bool LoadZoomInterface(); + bool LoadPrivateInterface(); // Determines if we think the plugin has focus, both content area and webkit // (see has_webkit_focus_ below). @@ -216,6 +219,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // The plugin find and zoom interfaces. const PPP_Find_Dev* plugin_find_interface_; const PPP_Zoom_Dev* plugin_zoom_interface_; + const PPP_Private* plugin_private_interface_; // This is only valid between a successful PrintBegin call and a PrintEnd // call. diff --git a/webkit/glue/plugins/pepper_webplugin_impl.cc b/webkit/glue/plugins/pepper_webplugin_impl.cc index 86fcd83..0e6e92f 100644 --- a/webkit/glue/plugins/pepper_webplugin_impl.cc +++ b/webkit/glue/plugins/pepper_webplugin_impl.cc @@ -9,6 +9,7 @@ #include "base/message_loop.h" #include "third_party/ppapi/c/pp_var.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" @@ -19,8 +20,10 @@ using WebKit::WebCanvas; using WebKit::WebPluginContainer; using WebKit::WebPluginParams; +using WebKit::WebPoint; using WebKit::WebRect; using WebKit::WebString; +using WebKit::WebURL; using WebKit::WebVector; using WebKit::WebView; @@ -161,14 +164,18 @@ bool WebPluginImpl::hasSelection() const { return !selectionAsText().isEmpty(); } -WebKit::WebString WebPluginImpl::selectionAsText() const { +WebString WebPluginImpl::selectionAsText() const { return instance_->GetSelectedText(false); } -WebKit::WebString WebPluginImpl::selectionAsMarkup() const { +WebString WebPluginImpl::selectionAsMarkup() const { return instance_->GetSelectedText(true); } +WebURL WebPluginImpl::linkAtPosition(const WebPoint& position) const { + return GURL(instance_->GetLinkAtPosition(position)); +} + void WebPluginImpl::setZoomLevel(double level, bool text_only) { instance_->Zoom(WebView::zoomLevelToZoomFactor(level), text_only); } diff --git a/webkit/glue/plugins/pepper_webplugin_impl.h b/webkit/glue/plugins/pepper_webplugin_impl.h index 17ce979..3023d95 100644 --- a/webkit/glue/plugins/pepper_webplugin_impl.h +++ b/webkit/glue/plugins/pepper_webplugin_impl.h @@ -63,6 +63,7 @@ class WebPluginImpl : public WebKit::WebPlugin { virtual bool hasSelection() const; virtual WebKit::WebString selectionAsText() const; virtual WebKit::WebString selectionAsMarkup() const; + virtual WebKit::WebURL linkAtPosition(const WebKit::WebPoint& position) const; virtual void setZoomLevel(double level, bool text_only); virtual bool startFind(const WebKit::WebString& search_text, bool case_sensitive, diff --git a/webkit/glue/plugins/ppp_private.h b/webkit/glue/plugins/ppp_private.h new file mode 100644 index 0000000..4bc3812 --- /dev/null +++ b/webkit/glue/plugins/ppp_private.h @@ -0,0 +1,20 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_ +#define WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_ + +#include "third_party/ppapi/c/pp_instance.h" +#include "third_party/ppapi/c/pp_point.h" +#include "third_party/ppapi/c/pp_var.h" + +#define PPP_PRIVATE_INTERFACE "PPP_Private;1" + +struct PPP_Private { + // Returns an absolute URL if the position is over a link. + PP_Var (*GetLinkAtPosition)(PP_Instance instance, + PP_Point point); +}; + +#endif // WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_ |