summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.h5
-rw-r--r--webkit/glue/plugins/pepper_webplugin_delegate_impl.cc160
-rw-r--r--webkit/glue/plugins/pepper_webplugin_delegate_impl.h86
-rw-r--r--webkit/glue/plugins/pepper_webplugin_impl.cc124
-rw-r--r--webkit/glue/plugins/pepper_webplugin_impl.h75
-rw-r--r--webkit/glue/webkit_glue.gypi4
6 files changed, 205 insertions, 249 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h
index 6f54a91..870a032 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.h
+++ b/chrome/renderer/pepper_plugin_delegate_impl.h
@@ -6,11 +6,14 @@
#define CHROME_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
#include "base/basictypes.h"
+#include "base/weak_ptr.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
class RenderView;
-class PepperPluginDelegateImpl : public pepper::PluginDelegate {
+class PepperPluginDelegateImpl
+ : public pepper::PluginDelegate,
+ public base::SupportsWeakPtr<PepperPluginDelegateImpl> {
public:
explicit PepperPluginDelegateImpl(RenderView* render_view);
diff --git a/webkit/glue/plugins/pepper_webplugin_delegate_impl.cc b/webkit/glue/plugins/pepper_webplugin_delegate_impl.cc
deleted file mode 100644
index 473dd58..0000000
--- a/webkit/glue/plugins/pepper_webplugin_delegate_impl.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-// 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_delegate_impl.h"
-
-#include "base/logging.h"
-#include "base/ref_counted.h"
-#include "webkit/glue/plugins/pepper_device_context_2d.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_plugin_module.h"
-#include "webkit/glue/plugins/webplugin.h"
-
-namespace pepper {
-
-WebPluginDelegateImpl::WebPluginDelegateImpl(PluginInstance* instance)
- : instance_(instance),
- web_plugin_(NULL) {
-}
-
-WebPluginDelegateImpl::~WebPluginDelegateImpl() {
-}
-
-// static
-WebPluginDelegateImpl* WebPluginDelegateImpl::Create(PluginDelegate* delegate,
- const FilePath& filename) {
- scoped_refptr<PluginModule> module = PluginModule::CreateModule(filename);
- if (!module.get())
- return NULL;
-
- scoped_refptr<PluginInstance> instance = module->CreateInstance(delegate);
- return new WebPluginDelegateImpl(instance.get());
-}
-
-bool WebPluginDelegateImpl::Initialize(
- const GURL& url,
- const std::vector<std::string>& arg_names,
- const std::vector<std::string>& arg_values,
- webkit_glue::WebPlugin* plugin,
- bool load_manually) {
- web_plugin_ = plugin;
-
- if (!instance_->Initialize(arg_names, arg_values)) {
- LOG(WARNING) << "Plugin instance initialization failed.";
- return false;
- }
-
- // Declare we're in Windowless mode to WebKit.
- web_plugin_->SetWindow(0);
- return true;
-}
-
-void WebPluginDelegateImpl::PluginDestroyed() {
- // TODO(brettw) we may need something like in the NPAPI version that checks
- // for reentrancy and doesn't delete until later.
- instance_->Delete();
- delete this;
-}
-
-void WebPluginDelegateImpl::UpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect) {
- window_rect_ = window_rect;
- instance_->ViewChanged(window_rect, clip_rect);
-}
-
-void WebPluginDelegateImpl::Paint(WebKit::WebCanvas* canvas,
- const gfx::Rect& rect) {
- instance_->Paint(canvas, window_rect_, rect);
-}
-
-void WebPluginDelegateImpl::Print(gfx::NativeDrawingContext hdc) {
-}
-
-void WebPluginDelegateImpl::SetFocus(bool focused) {
-}
-
-bool WebPluginDelegateImpl::HandleInputEvent(const WebKit::WebInputEvent& event,
- WebKit::WebCursorInfo* cursor) {
- return instance_->HandleInputEvent(event, cursor);
-}
-
-NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() {
- return NULL;
-}
-
-void WebPluginDelegateImpl::DidFinishLoadWithReason(const GURL& url,
- NPReason reason,
- int notify_id) {
-}
-
-int WebPluginDelegateImpl::GetProcessId() {
- return -1; // TODO(brettw) work out what this should do.
-}
-
-void WebPluginDelegateImpl::SendJavaScriptStream(const GURL& url,
- const std::string& result,
- bool success,
- int notify_id) {
-}
-
-void WebPluginDelegateImpl::DidReceiveManualResponse(
- const GURL& url,
- const std::string& mime_type,
- const std::string& headers,
- uint32 expected_length,
- uint32 last_modified) {
-}
-
-void WebPluginDelegateImpl::DidReceiveManualData(const char* buffer,
- int length) {
-}
-
-void WebPluginDelegateImpl::DidFinishManualLoading() {
-}
-
-void WebPluginDelegateImpl::DidManualLoadFail() {
-}
-
-void WebPluginDelegateImpl::InstallMissingPlugin() {
-}
-
-webkit_glue::WebPluginResourceClient*
-WebPluginDelegateImpl::CreateResourceClient(unsigned long resource_id,
- const GURL& url,
- int notify_id) {
- return NULL;
-}
-
-webkit_glue::WebPluginResourceClient*
-WebPluginDelegateImpl::CreateSeekableResourceClient(unsigned long resource_id,
- int range_request_id) {
- return NULL;
-}
-
-bool WebPluginDelegateImpl::SupportsFind() {
- return false;
-}
-
-void WebPluginDelegateImpl::StartFind(const std::string& search_text,
- bool case_sensitive,
- int identifier) {
-}
-
-void WebPluginDelegateImpl::SelectFindResult(bool forward) {
-}
-
-void WebPluginDelegateImpl::StopFind() {
-}
-
-void WebPluginDelegateImpl::NumberOfFindResultsChanged(int total,
- bool final_result) {
-}
-
-void WebPluginDelegateImpl::SelectedFindResultChanged(int index) {
-}
-
-void WebPluginDelegateImpl::Zoom(int factor) {
-}
-
-} // namespace pepper
diff --git a/webkit/glue/plugins/pepper_webplugin_delegate_impl.h b/webkit/glue/plugins/pepper_webplugin_delegate_impl.h
deleted file mode 100644
index a4bb58a..0000000
--- a/webkit/glue/plugins/pepper_webplugin_delegate_impl.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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_PEPPER_WEBPLUGIN_DELEGATE_IMPL_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_DELEGATE_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
-#include "gfx/rect.h"
-#include "webkit/glue/plugins/webplugin_delegate.h"
-
-namespace pepper {
-
-class DeviceContext2D;
-class PluginDelegate;
-class PluginInstance;
-
-class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
- public:
- virtual ~WebPluginDelegateImpl();
-
- static WebPluginDelegateImpl* Create(PluginDelegate* delegate,
- const FilePath& filename);
-
- // webkit_glue::WebPluginDelegate implementation.
- virtual bool Initialize(const GURL& url,
- const std::vector<std::string>& arg_names,
- const std::vector<std::string>& arg_values,
- webkit_glue::WebPlugin* plugin,
- bool load_manually);
- virtual void PluginDestroyed();
- virtual void UpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect);
- virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect);
- virtual void Print(gfx::NativeDrawingContext hdc);
- virtual void SetFocus(bool focused);
- virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
- WebKit::WebCursorInfo* cursor);
- virtual NPObject* GetPluginScriptableObject();
- virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason,
- int notify_id);
- virtual int GetProcessId();
- virtual void SendJavaScriptStream(const GURL& url,
- const std::string& result,
- bool success,
- int notify_id);
- virtual void DidReceiveManualResponse(const GURL& url,
- const std::string& mime_type,
- const std::string& headers,
- uint32 expected_length,
- uint32 last_modified);
- virtual void DidReceiveManualData(const char* buffer, int length);
- virtual void DidFinishManualLoading();
- virtual void DidManualLoadFail();
- virtual void InstallMissingPlugin();
- virtual webkit_glue::WebPluginResourceClient* CreateResourceClient(
- unsigned long resource_id,
- const GURL& url,
- int notify_id);
- virtual webkit_glue::WebPluginResourceClient* CreateSeekableResourceClient(
- unsigned long resource_id, int range_request_id);
- virtual bool SupportsFind();
- virtual void StartFind(const std::string& search_text,
- bool case_sensitive,
- int identifier);
- virtual void SelectFindResult(bool forward);
- virtual void StopFind();
- virtual void NumberOfFindResultsChanged(int total, bool final_result);
- virtual void SelectedFindResultChanged(int index);
- virtual void Zoom(int factor);
-
- private:
- WebPluginDelegateImpl(PluginInstance* instance);
-
- scoped_refptr<PluginInstance> instance_;
- webkit_glue::WebPlugin* web_plugin_;
-
- gfx::Rect window_rect_;
-
- DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
-};
-
-} // namespace
-
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_DELEGATE_IMPL_H_
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
diff --git a/webkit/glue/plugins/pepper_webplugin_impl.h b/webkit/glue/plugins/pepper_webplugin_impl.h
new file mode 100644
index 0000000..5213cbb
--- /dev/null
+++ b/webkit/glue/plugins/pepper_webplugin_impl.h
@@ -0,0 +1,75 @@
+// 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_PEPPER_WEBPLUGIN_IMPL_H_
+#define WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_IMPL_H_
+
+#include <vector>
+
+#include "base/weak_ptr.h"
+#include "gfx/rect.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h"
+
+namespace WebKit {
+class WebFrame;
+struct WebPluginParams;
+}
+
+namespace pepper {
+
+class PluginDelegate;
+class PluginInstance;
+
+class WebPluginImpl : public WebKit::WebPlugin {
+ public:
+ WebPluginImpl(WebKit::WebFrame* frame,
+ const WebKit::WebPluginParams& params,
+ const base::WeakPtr<PluginDelegate>& plugin_delegate);
+ ~WebPluginImpl();
+
+ // WebKit::WebPlugin implementation.
+ virtual bool initialize(WebKit::WebPluginContainer* container);
+ virtual void destroy();
+ virtual NPObject* scriptableObject();
+ virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect);
+ virtual void updateGeometry(
+ const WebKit::WebRect& frame_rect,
+ const WebKit::WebRect& clip_rect,
+ const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects,
+ bool is_visible);
+ virtual void updateFocus(bool focused);
+ virtual void updateVisibility(bool visible);
+ virtual bool acceptsInputEvents();
+ virtual bool handleInputEvent(const WebKit::WebInputEvent& event,
+ WebKit::WebCursorInfo& cursor_info);
+ virtual void didReceiveResponse(const WebKit::WebURLResponse& response);
+ virtual void didReceiveData(const char* data, int data_length);
+ virtual void didFinishLoading();
+ virtual void didFailLoading(const WebKit::WebURLError&);
+ virtual void didFinishLoadingFrameRequest(const WebKit::WebURL& url,
+ void* notify_data);
+ virtual void didFailLoadingFrameRequest(const WebKit::WebURL& url,
+ void* notify_data,
+ const WebKit::WebURLError& error);
+
+ public:
+ base::WeakPtr<PluginDelegate> plugin_delegate_;
+
+ scoped_refptr<PluginInstance> instance_;
+
+ // Can be NULL.
+ WebKit::WebPluginContainer* container_;
+
+ // Holds the list of argument names and values passed to the plugin.
+ std::vector<std::string> arg_names_;
+ std::vector<std::string> arg_values_;
+
+ gfx::Rect plugin_rect_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebPluginImpl);
+};
+
+} // namespace pepper
+
+#endif // WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_IMPL_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 87f3d36..f357109 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -177,8 +177,8 @@
'plugins/pepper_resource.h',
'plugins/pepper_var.cc',
'plugins/pepper_var.h',
- 'plugins/pepper_webplugin_delegate_impl.cc',
- 'plugins/pepper_webplugin_delegate_impl.h',
+ 'plugins/pepper_webplugin_impl.cc',
+ 'plugins/pepper_webplugin_impl.h',
'plugins/plugin_constants_win.h',
'plugins/plugin_host.cc',
'plugins/plugin_host.h',