summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/webplugin_delegate_pepper.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer/webplugin_delegate_pepper.h')
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h
new file mode 100644
index 0000000..bc59b2a
--- /dev/null
+++ b/chrome/renderer/webplugin_delegate_pepper.h
@@ -0,0 +1,134 @@
+// Copyright (c) 2006-2008 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 CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_
+#define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_
+
+#include "build/build_config.h"
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include "app/gfx/native_widget_types.h"
+#include "base/file_path.h"
+#include "base/gfx/rect.h"
+#include "base/ref_counted.h"
+#include "base/task.h"
+#include "chrome/common/transport_dib.h"
+#include "skia/ext/platform_canvas.h"
+#include "third_party/npapi/bindings/npapi.h"
+#include "webkit/glue/webcursor.h"
+#include "webkit/glue/webplugin_delegate.h"
+
+namespace NPAPI {
+class PluginInstance;
+}
+
+// An implementation of WebPluginDelegate for Pepper in-process plugins.
+class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate {
+ public:
+ static WebPluginDelegatePepper* Create(const FilePath& filename,
+ const std::string& mime_type, gfx::PluginWindowHandle containing_view);
+
+ static bool IsPluginDelegateWindow(gfx::NativeWindow window);
+ static bool GetPluginNameFromWindow(gfx::NativeWindow window,
+ std::wstring *plugin_name);
+
+ // Returns true if the window handle passed in is that of the dummy
+ // activation window for windowless plugins.
+ static bool IsDummyActivationWindow(gfx::NativeWindow window);
+
+ // 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(gfx::NativeDrawingContext context, const gfx::Rect& rect);
+ virtual void Print(gfx::NativeDrawingContext context);
+ virtual void SetFocus();
+ virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
+ WebKit::WebCursorInfo* cursor);
+ virtual NPObject* GetPluginScriptableObject();
+ virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason,
+ intptr_t notify_data);
+ virtual int GetProcessId();
+ virtual void SendJavaScriptStream(const GURL& url,
+ const std::string& result,
+ bool success, bool notify_needed,
+ intptr_t notify_data);
+ 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(
+ int resource_id,
+ const GURL& url,
+ bool notify_needed,
+ intptr_t notify_data,
+ intptr_t stream);
+ // End of WebPluginDelegate implementation.
+
+ bool IsWindowless() const { return true; }
+ gfx::Rect GetRect() const { return window_rect_; }
+ gfx::Rect GetClipRect() const { return clip_rect_; }
+
+ // Returns the path for the library implementing this plugin.
+ FilePath GetPluginPath();
+
+ private:
+ WebPluginDelegatePepper(gfx::PluginWindowHandle containing_view,
+ NPAPI::PluginInstance *instance);
+ ~WebPluginDelegatePepper();
+
+ //----------------------------
+ // used for windowless plugins
+ virtual NPError InitializeRenderContext(NPRenderType type,
+ NPRenderContext* context);
+ virtual NPError FlushRenderContext(NPRenderContext* context);
+
+ // Tells the plugin about the current state of the window.
+ // See NPAPI NPP_SetWindow for more information.
+ void WindowlessSetWindow(bool force_set_window);
+
+ //-----------------------------------------
+ // used for windowed and windowless plugins
+
+ NPAPI::PluginInstance* instance() { return instance_.get(); }
+
+ // Closes down and destroys our plugin instance.
+ void DestroyInstance();
+
+ webkit_glue::WebPlugin* plugin_;
+ scoped_refptr<NPAPI::PluginInstance> instance_;
+
+ gfx::PluginWindowHandle parent_;
+ NPWindow window_;
+ gfx::Rect window_rect_;
+ gfx::Rect clip_rect_;
+ std::vector<gfx::Rect> cutout_rects_;
+
+ // Plugin graphics context implementation
+ size_t buffer_size_;
+ TransportDIB* plugin_buffer_;
+ static uint32 next_buffer_id;
+ skia::PlatformCanvas* plugin_canvas_;
+ skia::PlatformCanvas* background_canvas_;
+
+ // The url with which the plugin was instantiated.
+ std::string plugin_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper);
+};
+
+#endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_