summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_webplugin_impl.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 05:29:03 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 05:29:03 +0000
commitbd1b93d983c6cbf8e32458bd36a3aadf7490a770 (patch)
tree4670a311dfa2faf487a9b1810ca2eda6df64e8e6 /webkit/glue/plugins/pepper_webplugin_impl.cc
parentbeaafbaf7a599c92912702bc2b5b3e770849a74a (diff)
downloadchromium_src-bd1b93d983c6cbf8e32458bd36a3aadf7490a770.zip
chromium_src-bd1b93d983c6cbf8e32458bd36a3aadf7490a770.tar.gz
chromium_src-bd1b93d983c6cbf8e32458bd36a3aadf7490a770.tar.bz2
Implement a version of WebPlugin for Pepper to bypass the current NPAPI
WebPluginImpl. We don't need most of that NPAPI cruft and can remove this extra layer of abstraction to keep our code simpler. TEST=none BUG=none Review URL: http://codereview.chromium.org/2001014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/pepper_webplugin_impl.cc')
-rw-r--r--webkit/glue/plugins/pepper_webplugin_impl.cc124
1 files changed, 124 insertions, 0 deletions
diff --git a/webkit/glue/plugins/pepper_webplugin_impl.cc b/webkit/glue/plugins/pepper_webplugin_impl.cc
new file mode 100644
index 0000000..fa20107
--- /dev/null
+++ b/webkit/glue/plugins/pepper_webplugin_impl.cc
@@ -0,0 +1,124 @@
+// 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.
+
+#include "webkit/glue/plugins/pepper_webplugin_impl.h"
+
+#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
+#include "webkit/glue/plugins/pepper_plugin_instance.h"
+#include "webkit/glue/plugins/pepper_plugin_module.h"
+
+using WebKit::WebCanvas;
+using WebKit::WebPluginContainer;
+using WebKit::WebPluginParams;
+using WebKit::WebRect;
+using WebKit::WebVector;
+
+namespace pepper {
+
+WebPluginImpl::WebPluginImpl(
+ WebKit::WebFrame* frame,
+ const WebPluginParams& params,
+ const base::WeakPtr<PluginDelegate>& plugin_delegate)
+ : plugin_delegate_(plugin_delegate),
+ container_(NULL) {
+ for (size_t i = 0; i < params.attributeNames.size(); ++i) {
+ arg_names_.push_back(params.attributeNames[i].utf8());
+ arg_values_.push_back(params.attributeValues[i].utf8());
+ }
+}
+
+WebPluginImpl::~WebPluginImpl() {
+}
+
+bool WebPluginImpl::initialize(WebPluginContainer* container) {
+ // TODO(brettw) don't hardcode this!
+ scoped_refptr<PluginModule> module = PluginModule::CreateModule(
+ FilePath(FILE_PATH_LITERAL(
+ "/usr/local/google/home/src3/src/out/Debug/lib.target/libppapi_example.so")));
+ if (!module.get())
+ return false;
+
+ if (!plugin_delegate_)
+ return false;
+ instance_ = module->CreateInstance(plugin_delegate_);
+ bool success = instance_->Initialize(arg_names_, arg_values_);
+ if (!success) {
+ instance_->Delete();
+ instance_ = NULL;
+ return false;
+ }
+
+ container_ = container;
+ return true;
+}
+
+void WebPluginImpl::destroy() {
+ container_ = NULL;
+
+ instance_->Delete();
+ instance_ = NULL;
+
+ MessageLoop::current()->DeleteSoon(FROM_HERE, this);
+}
+
+NPObject* WebPluginImpl::scriptableObject() {
+ // TODO(brettw): implement getting this from the plugin instance.
+ return NULL;
+}
+
+void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) {
+ instance_->Paint(canvas, plugin_rect_, rect);
+}
+
+void WebPluginImpl::updateGeometry(
+ const WebRect& window_rect,
+ const WebRect& clip_rect,
+ const WebVector<WebRect>& cut_outs_rects,
+ bool is_visible) {
+ plugin_rect_ = window_rect;
+ instance_->ViewChanged(plugin_rect_, clip_rect);
+}
+
+void WebPluginImpl::updateFocus(bool focused) {
+}
+
+void WebPluginImpl::updateVisibility(bool visible) {
+}
+
+bool WebPluginImpl::acceptsInputEvents() {
+ return true;
+}
+
+bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
+ WebKit::WebCursorInfo& cursor_info) {
+ return instance_->HandleInputEvent(event, &cursor_info);
+}
+
+void WebPluginImpl::didReceiveResponse(
+ const WebKit::WebURLResponse& response) {
+}
+
+void WebPluginImpl::didReceiveData(const char* data, int data_length) {
+}
+
+void WebPluginImpl::didFinishLoading() {
+}
+
+void WebPluginImpl::didFailLoading(const WebKit::WebURLError&) {
+}
+
+void WebPluginImpl::didFinishLoadingFrameRequest(const WebKit::WebURL& url,
+ void* notify_data) {
+}
+
+void WebPluginImpl::didFailLoadingFrameRequest(
+ const WebKit::WebURL& url,
+ void* notify_data,
+ const WebKit::WebURLError& error) {
+}
+
+} // namespace pepper