+2010-07-08 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add a Plugin abstract base class and a DummyPlugin that implements it
+ https://bugs.webkit.org/show_bug.cgi?id=41885
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add files.
+
+ * WebProcess/Plugins/DummyPlugin.cpp: Added.
+ (WebKit::DummyPlugin::paint):
+ Paint a red rectangle.
+
+ * WebProcess/Plugins/Plugin.cpp: Added.
+ * WebProcess/Plugins/Plugin.h: Added.
+ Add Plugin, an abstract baseclass.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::PluginView):
+ (WebKit::PluginView::~PluginView):
+ (WebKit::PluginView::paint):
+ (WebKit::PluginView::viewGeometryDidChange):
+ * WebProcess/Plugins/PluginView.h:
+ (WebKit::PluginView::create):
+ Add a Plugin member function and forward PluginView calls to it.
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::createPlugin):
+ Make a DummyPlugin and pass it to the PluginView.
+
+ * win/WebKit2.vcproj:
+ Add files.
+
2010-07-08 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
1A6FA31611E3923600DB1371 /* WebKitMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA31511E3923600DB1371 /* WebKitMain.cpp */; };
1A6FB7AE11E64B6800DB1371 /* PluginView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FB7AC11E64B6800DB1371 /* PluginView.cpp */; };
1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FB7AD11E64B6800DB1371 /* PluginView.h */; };
+ 1A6FB7D211E651E200DB1371 /* Plugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FB7D011E651E200DB1371 /* Plugin.cpp */; };
+ 1A6FB7D311E651E200DB1371 /* Plugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FB7D111E651E200DB1371 /* Plugin.h */; };
+ 1A6FB7E611E6530500DB1371 /* DummyPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FB7E411E6530500DB1371 /* DummyPlugin.h */; };
+ 1A6FB7E711E6530500DB1371 /* DummyPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FB7E511E6530500DB1371 /* DummyPlugin.cpp */; };
1AA1CC5D100FA1A10078DEBC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
1AA1CD07100FA1BA0078DEBC /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
1A6FA01F11E1528700DB1371 /* WebProcessMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessMain.h; sourceTree = "<group>"; };
1A6FA31011E3921E00DB1371 /* MainMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MainMac.cpp; path = mac/MainMac.cpp; sourceTree = "<group>"; };
1A6FA31511E3923600DB1371 /* WebKitMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitMain.cpp; sourceTree = "<group>"; };
- 1A6FB7AC11E64B6800DB1371 /* PluginView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginView.cpp; path = Plugins/PluginView.cpp; sourceTree = "<group>"; };
- 1A6FB7AD11E64B6800DB1371 /* PluginView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PluginView.h; path = Plugins/PluginView.h; sourceTree = "<group>"; };
+ 1A6FB7AC11E64B6800DB1371 /* PluginView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginView.cpp; sourceTree = "<group>"; };
+ 1A6FB7AD11E64B6800DB1371 /* PluginView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginView.h; sourceTree = "<group>"; };
+ 1A6FB7D011E651E200DB1371 /* Plugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Plugin.cpp; sourceTree = "<group>"; };
+ 1A6FB7D111E651E200DB1371 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Plugin.h; sourceTree = "<group>"; };
+ 1A6FB7E411E6530500DB1371 /* DummyPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DummyPlugin.h; sourceTree = "<group>"; };
+ 1A6FB7E511E6530500DB1371 /* DummyPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DummyPlugin.cpp; sourceTree = "<group>"; };
1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
1A6FB7AA11E64B4900DB1371 /* Plugins */ = {
isa = PBXGroup;
children = (
+ 1A6FB7E511E6530500DB1371 /* DummyPlugin.cpp */,
+ 1A6FB7E411E6530500DB1371 /* DummyPlugin.h */,
+ 1A6FB7D011E651E200DB1371 /* Plugin.cpp */,
+ 1A6FB7D111E651E200DB1371 /* Plugin.h */,
1A6FB7AC11E64B6800DB1371 /* PluginView.cpp */,
1A6FB7AD11E64B6800DB1371 /* PluginView.h */,
);
- name = Plugins;
+ path = Plugins;
sourceTree = "<group>";
};
1A7E814E1152D2240003695B /* mac */ = {
BC72B9FB11E6476B001EB4EA /* WebBackForwardListProxy.h in Headers */,
BC72BA1E11E64907001EB4EA /* WebBackForwardList.h in Headers */,
1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */,
+ 1A6FB7D311E651E200DB1371 /* Plugin.h in Headers */,
+ 1A6FB7E611E6530500DB1371 /* DummyPlugin.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BC72B9FA11E6476B001EB4EA /* WebBackForwardListProxy.cpp in Sources */,
BC72BA1D11E64907001EB4EA /* WebBackForwardList.cpp in Sources */,
1A6FB7AE11E64B6800DB1371 /* PluginView.cpp in Sources */,
+ 1A6FB7D211E651E200DB1371 /* Plugin.cpp in Sources */,
+ 1A6FB7E711E6530500DB1371 /* DummyPlugin.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DummyPlugin.h"
+
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DummyPlugin::DummyPlugin()
+{
+}
+
+void DummyPlugin::initialize(const String& mimeType, const KURL&, bool loadManually)
+{
+}
+
+void DummyPlugin::destroy()
+{
+}
+
+void DummyPlugin::paint(GraphicsContext* context, const IntRect& dirtyRect)
+{
+#if PLATFORM(MAC)
+ CGContextRef cgContext = context->platformContext();
+ CGContextSaveGState(cgContext);
+
+ CGColorRef redColor = CGColorCreateGenericRGB(1, 0, 0, 1);
+ CGContextSetFillColorWithColor(cgContext, redColor);
+ CGContextFillRect(cgContext, dirtyRect);
+ CGColorRelease(redColor);
+#endif
+}
+
+void DummyPlugin::geometryDidChange(const IntRect& frameRect)
+{
+}
+
+} // namespace WebKit
--- /dev/null
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DummyPlugin_h
+#define DummyPlugin_h
+
+#include "Plugin.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class DummyPlugin : public Plugin {
+public:
+ static PassRefPtr<DummyPlugin> create()
+ {
+ return adoptRef(new DummyPlugin);
+ }
+
+private:
+ DummyPlugin();
+
+ // Plugin
+ virtual void initialize(const WebCore::String& mimeType, const WebCore::KURL&, bool loadManually);
+ virtual void destroy();
+ virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
+ virtual void geometryDidChange(const WebCore::IntRect& frameRect);
+}
+
+} // namespace WebKit
+
+#endif // DummyPlugin_h
--- /dev/null
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Plugin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Plugin::Plugin()
+{
+}
+
+Plugin::~Plugin()
+{
+}
+
+} // namespace WebKit
--- /dev/null
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Plugin_h
+#define Plugin_h
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+ class GraphicsContext;
+ class IntRect;
+ class KURL;
+ class String;
+}
+
+namespace WebKit {
+
+class Plugin : public RefCounted<Plugin> {
+public:
+ virtual ~Plugin();
+
+ virtual void initialize(const WebCore::String& mimeType, const WebCore::KURL&, bool loadManually) = 0;
+ virtual void destroy() = 0;
+ virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect) = 0;
+ virtual void geometryDidChange(const WebCore::IntRect& frameRect) = 0;
+
+protected:
+ Plugin();
+};
+
+} // namespace WebKit
+
+#endif // Plugin_h
namespace WebKit {
-PluginView::PluginView()
+PluginView::PluginView(PassRefPtr<Plugin> plugin)
+ : m_plugin(plugin)
{
}
PluginView::~PluginView()
{
+ m_plugin->destroy();
}
void PluginView::setFrameRect(const WebCore::IntRect& rect)
if (paintRect.isEmpty())
return;
-#if PLATFORM(MAC)
- CGContextRef cgContext = context->platformContext();
- CGContextSaveGState(cgContext);
-
- CGColorRef redColor = CGColorCreateGenericRGB(1, 0, 0, 1);
- CGContextSetFillColorWithColor(cgContext, redColor);
- CGContextFillRect(cgContext, paintRect);
- CGColorRelease(redColor);
-#endif
+ m_plugin->paint(context, paintRect);
}
void PluginView::viewGeometryDidChange()
{
+ m_plugin->geometryDidChange(frameRect());
}
void PluginView::invalidateRect(const IntRect&)
class PluginView : public WebCore::Widget {
public:
- static PassRefPtr<PluginView> create()
+ static PassRefPtr<PluginView> create(PassRefPtr<Plugin> plugin)
{
- return adoptRef(new PluginView());
+ return adoptRef(new PluginView(plugin));
}
private:
- PluginView();
+ PluginView(PassRefPtr<Plugin>);
virtual ~PluginView();
void viewGeometryDidChange();
virtual void setFrameRect(const WebCore::IntRect&);
virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
virtual void invalidateRect(const WebCore::IntRect&);
+
+ RefPtr<Plugin> m_plugin;
};
} // namespace WebKit
#include "WebFrameLoaderClient.h"
+#include "DummyPlugin.h"
#include "NotImplemented.h"
#include "PluginView.h"
#include "WebCoreArgumentCoders.h"
PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually)
{
notImplemented();
- return PluginView::create();
+
+ RefPtr<DummyPlugin> plugin = DummyPlugin::create();
+
+ return PluginView::create(plugin.release());
}
void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
<Filter\r
Name="Plugins"\r
>\r
+ <File\r
+ RelativePath="..\WebProcess\Plugins\DummyPlugin.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\WebProcess\Plugins\DummyPlugin.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\WebProcess\Plugins\Plugin.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\WebProcess\Plugins\Plugin.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\WebProcess\Plugins\PluginView.cpp"\r
>\r