summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 23:45:03 +0000
committerwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 23:45:03 +0000
commit92c85519988f8b53cd8b630468d4c47102e6d92e (patch)
treee960469b6581baea5dcb3f944bea541843e3c5ee
parent9fbb44c3c924152df427cbca4014994e3969d4cd (diff)
downloadchromium_src-92c85519988f8b53cd8b630468d4c47102e6d92e.zip
chromium_src-92c85519988f8b53cd8b630468d4c47102e6d92e.tar.gz
chromium_src-92c85519988f8b53cd8b630468d4c47102e6d92e.tar.bz2
add find hookup
BUG=none TEST=compiles Review URL: http://codereview.chromium.org/2896009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52151 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--webkit/glue/plugins/pepper_plugin_instance.cc58
-rw-r--r--webkit/glue/plugins/pepper_plugin_instance.h9
-rw-r--r--webkit/glue/plugins/pepper_plugin_module.cc5
4 files changed, 68 insertions, 6 deletions
diff --git a/DEPS b/DEPS
index df81bb5..8fd1b95 100644
--- a/DEPS
+++ b/DEPS
@@ -158,7 +158,7 @@ deps = {
Var("libvpx_revision"),
"src/third_party/ppapi":
- "http://ppapi.googlecode.com/svn/trunk@153",
+ "http://ppapi.googlecode.com/svn/trunk@155",
"src/third_party/libjingle/source":
"http://libjingle.googlecode.com/svn/branches/nextsnap@" +
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc
index ca284c7..3666b4b 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.cc
+++ b/webkit/glue/plugins/pepper_plugin_instance.cc
@@ -13,7 +13,9 @@
#include "third_party/ppapi/c/pp_rect.h"
#include "third_party/ppapi/c/pp_resource.h"
#include "third_party/ppapi/c/pp_var.h"
+#include "third_party/ppapi/c/ppb_find.h"
#include "third_party/ppapi/c/ppb_instance.h"
+#include "third_party/ppapi/c/ppp_find.h"
#include "third_party/ppapi/c/ppp_instance.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
@@ -159,6 +161,34 @@ const PPB_Instance ppb_instance = {
&SetCursor,
};
+void NumberOfFindResultsChanged(PP_Instance instance_id,
+ int32_t total,
+ bool final_result) {
+ PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
+ if (!instance)
+ return;
+
+ DCHECK_NE(instance->find_identifier(), -1);
+ instance->delegate()->DidChangeNumberOfFindResults(
+ instance->find_identifier(), total, final_result);
+}
+
+void SelectedFindResultChanged(PP_Instance instance_id,
+ int32_t index) {
+ PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
+ if (!instance)
+ return;
+
+ DCHECK_NE(instance->find_identifier(), -1);
+ instance->delegate()->DidChangeSelectedFindResult(
+ instance->find_identifier(), index);
+}
+
+const PPB_Find ppb_find = {
+ &NumberOfFindResultsChanged,
+ &SelectedFindResultChanged,
+};
+
} // namespace
PluginInstance::PluginInstance(PluginDelegate* delegate,
@@ -190,6 +220,11 @@ PluginInstance* PluginInstance::FromPPInstance(PP_Instance instance) {
return reinterpret_cast<PluginInstance*>(instance);
}
+// static
+const PPB_Find* PluginInstance::GetFindInterface() {
+ return &ppb_find;
+}
+
PP_Instance PluginInstance::GetPPInstance() {
return reinterpret_cast<intptr_t>(this);
}
@@ -351,18 +386,33 @@ void PluginInstance::Zoom(float factor, bool text_only) {
bool PluginInstance::StartFind(const string16& search_text,
bool case_sensitive,
int identifier) {
+ if (!plugin_find_interface_) {
+ plugin_find_interface_ =
+ reinterpret_cast<const PPP_Find*>(module_->GetPluginInterface(
+ PPP_FIND_INTERFACE));
+ }
+
+ if (plugin_find_interface_)
+ return false;
+
find_identifier_ = identifier;
- return false;
- // TODO: implement me
+ return plugin_find_interface_->StartFind(
+ GetPPInstance(),
+ reinterpret_cast<const char*>(search_text.c_str()),
+ case_sensitive);
}
void PluginInstance::SelectFindResult(bool forward) {
- // TODO: implement me
+ DCHECK(plugin_find_interface_);
+
+ plugin_find_interface_->SelectFindResult(GetPPInstance(), forward);
}
void PluginInstance::StopFind() {
+ DCHECK(plugin_find_interface_);
+
find_identifier_ = -1;
- // TODO: implement me
+ plugin_find_interface_->StopFind(GetPPInstance());
}
} // namespace pepper
diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h
index 0f836f0..716eca0 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.h
+++ b/webkit/glue/plugins/pepper_plugin_instance.h
@@ -16,6 +16,8 @@
#include "third_party/ppapi/c/pp_cursor_type.h"
#include "third_party/ppapi/c/pp_instance.h"
#include "third_party/ppapi/c/pp_resource.h"
+#include "third_party/ppapi/c/ppb_find.h"
+#include "third_party/ppapi/c/ppp_find.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h"
typedef struct _pp_Var PP_Var;
@@ -51,6 +53,10 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// Converts the given instance ID to an actual instance object.
static PluginInstance* FromPPInstance(PP_Instance instance);
+ // Returns a pointer to the interface implementing PPB_Find that is
+ // exposed to the plugin.
+ static const PPB_Find* GetFindInterface();
+
PluginDelegate* delegate() const { return delegate_; }
PluginModule* module() const { return module_.get(); }
@@ -135,6 +141,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// The id of the current find operation, or -1 if none is in process.
int find_identifier_;
+ // The plugin find interface.
+ const PPP_Find* plugin_find_interface_;
+
// Containes the cursor if it's set by the plugin.
scoped_ptr<WebKit::WebCursorInfo> cursor_;
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc
index f4059e5..22b9e98 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/glue/plugins/pepper_plugin_module.cc
@@ -19,8 +19,9 @@
#include "third_party/ppapi/c/ppb_file_io_trusted.h"
#include "third_party/ppapi/c/ppb_file_system.h"
#include "third_party/ppapi/c/ppb_image_data.h"
-#include "third_party/ppapi/c/ppb_font.h"
#include "third_party/ppapi/c/ppb_instance.h"
+#include "third_party/ppapi/c/ppb_find.h"
+#include "third_party/ppapi/c/ppb_font.h"
#include "third_party/ppapi/c/ppb_scrollbar.h"
#include "third_party/ppapi/c/ppb_testing.h"
#include "third_party/ppapi/c/ppb_url_loader.h"
@@ -185,6 +186,8 @@ const void* GetInterface(const char* name) {
return Scrollbar::GetInterface();
if (strcmp(name, PPB_FONT_INTERFACE) == 0)
return Font::GetInterface();
+ if (strcmp(name, PPB_FIND_INTERFACE) == 0)
+ return PluginInstance::GetFindInterface();
// Only support the testing interface when the command line switch is
// specified. This allows us to prevent people from (ab)using this interface