#include "config.h"
#include "Plugin.h"
#include "LayerTreeContext.h"
#include "PluginController.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/IntPoint.h>
#include <wtf/SetForScope.h>
#if PLATFORM(COCOA)
#include "LayerHostingContext.h"
#endif
namespace WebKit {
using namespace WebCore;
void Plugin::Parameters::encode(IPC::Encoder& encoder) const
{
encoder << url.string();
encoder << names;
encoder << values;
encoder << mimeType;
encoder << isFullFramePlugin;
encoder << shouldUseManualLoader;
#if PLATFORM(COCOA)
encoder << layerHostingMode;
#endif
}
bool Plugin::Parameters::decode(IPC::Decoder& decoder, Parameters& parameters)
{
String urlString;
if (!decoder.decode(urlString))
return false;
parameters.url = URL({ }, urlString);
if (!decoder.decode(parameters.names))
return false;
if (!decoder.decode(parameters.values))
return false;
if (!decoder.decode(parameters.mimeType))
return false;
if (!decoder.decode(parameters.isFullFramePlugin))
return false;
if (!decoder.decode(parameters.shouldUseManualLoader))
return false;
#if PLATFORM(COCOA)
if (!decoder.decode(parameters.layerHostingMode))
return false;
#endif
if (parameters.names.size() != parameters.values.size()) {
decoder.markInvalid();
return false;
}
return true;
}
Plugin::Plugin(PluginType type)
: m_type(type)
{
}
Plugin::~Plugin() = default;
bool Plugin::initialize(PluginController& pluginController, const Parameters& parameters)
{
ASSERT(!m_pluginController);
m_pluginController = makeWeakPtr(pluginController);
return initialize(parameters);
}
void Plugin::destroyPlugin()
{
ASSERT(!m_isBeingDestroyed);
SetForScope<bool> scope { m_isBeingDestroyed, true };
destroy();
m_pluginController = nullptr;
}
void Plugin::updateControlTints(GraphicsContext&)
{
}
IntPoint Plugin::convertToRootView(const IntPoint&) const
{
ASSERT_NOT_REACHED();
return IntPoint();
}
PluginController* Plugin::controller()
{
return m_pluginController.get();
}
const PluginController* Plugin::controller() const
{
return m_pluginController.get();
}
}