This source file includes following definitions.
- create
- initialize
- reallyDestroy
- destroy
- getPlugin
#include "config.h"
#include "WebHelperPluginImpl.h"
#include "WebFrameImpl.h"
#include "WebPlugin.h"
#include "WebPluginContainerImpl.h"
#include "core/html/HTMLObjectElement.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
using namespace WebCore;
namespace blink {
DEFINE_TYPE_CASTS(WebHelperPluginImpl, WebHelperPlugin, plugin, true, true);
WebHelperPlugin* WebHelperPlugin::create(const WebString& pluginType, WebLocalFrame* frame)
{
OwnPtr<WebHelperPlugin> plugin = adoptPtr<WebHelperPlugin>(new WebHelperPluginImpl());
if (!toWebHelperPluginImpl(plugin.get())->initialize(pluginType, toWebFrameImpl(frame)))
return 0;
return plugin.leakPtr();
}
WebHelperPluginImpl::WebHelperPluginImpl()
: m_destructionTimer(this, &WebHelperPluginImpl::reallyDestroy)
{
}
WebHelperPluginImpl::~WebHelperPluginImpl()
{
}
bool WebHelperPluginImpl::initialize(const String& pluginType, WebFrameImpl* frame)
{
ASSERT(!m_objectElement && !m_pluginContainer);
if (!frame->frame()->loader().client())
return false;
m_objectElement = HTMLObjectElement::create(*frame->frame()->document(), 0, false);
Vector<String> attributeNames;
Vector<String> attributeValues;
ASSERT(frame->frame()->document()->url().isValid());
m_pluginContainer = adoptRef(toWebPluginContainerImpl(frame->frame()->loader().client()->createPlugin(
m_objectElement.get(),
frame->frame()->document()->url(),
attributeNames,
attributeValues,
pluginType,
false,
FrameLoaderClient::AllowDetachedPlugin).leakRef()));
if (!m_pluginContainer)
return false;
return !getPlugin()->isPlaceholder();
}
void WebHelperPluginImpl::reallyDestroy(Timer<WebHelperPluginImpl>*)
{
delete this;
}
void WebHelperPluginImpl::destroy()
{
m_destructionTimer.startOneShot(0, FROM_HERE);
}
WebPlugin* WebHelperPluginImpl::getPlugin()
{
ASSERT(m_pluginContainer);
ASSERT(m_pluginContainer->plugin());
return m_pluginContainer->plugin();
}
}