本文整理汇总了C++中PluginView::getNPObject方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginView::getNPObject方法的具体用法?C++ PluginView::getNPObject怎么用?C++ PluginView::getNPObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginView
的用法示例。
在下文中一共展示了PluginView::getNPObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pluginScriptableObject
NPObject* PlatformBridge::pluginScriptableObject(Widget* widget)
{
#if USE(V8)
if (!widget->isPluginView())
return 0;
PluginView* pluginView = static_cast<PluginView*>(widget);
return pluginView->getNPObject();
#else
return 0;
#endif
}
示例2: createScriptInstanceForWidget
PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widget)
{
ASSERT(widget);
#if PLATFORM(CHROMIUM)
if (widget->isFrameView())
return 0;
NPObject* npObject = ChromiumBridge::pluginScriptableObject(widget);
if (!npObject)
return 0;
#elif PLATFORM(ANDROID)
if (!widget->isPluginView())
return 0;
PluginView* pluginView = static_cast<PluginView*>(widget);
NPObject* npObject = pluginView->getNPObject();
if (!npObject)
return 0;
#endif
// Frame Memory Management for NPObjects
// -------------------------------------
// NPObjects are treated differently than other objects wrapped by JS.
// NPObjects can be created either by the browser (e.g. the main
// window object) or by the plugin (the main plugin object
// for a HTMLEmbedElement). Further, unlike most DOM Objects, the frame
// is especially careful to ensure NPObjects terminate at frame teardown because
// if a plugin leaks a reference, it could leak its objects (or the browser's objects).
//
// The Frame maintains a list of plugin objects (m_pluginObjects)
// which it can use to quickly find the wrapped embed object.
//
// Inside the NPRuntime, we've added a few methods for registering
// wrapped NPObjects. The purpose of the registration is because
// javascript garbage collection is non-deterministic, yet we need to
// be able to tear down the plugin objects immediately. When an object
// is registered, javascript can use it. When the object is destroyed,
// or when the object's "owning" object is destroyed, the object will
// be un-registered, and the javascript engine must not use it.
//
// Inside the javascript engine, the engine can keep a reference to the
// NPObject as part of its wrapper. However, before accessing the object
// it must consult the _NPN_Registry.
v8::Local<v8::Object> wrapper = createV8ObjectForNPObject(npObject, 0);
// Track the plugin object. We've been given a reference to the object.
m_pluginObjects.set(widget, npObject);
return V8ScriptInstance::create(wrapper);
}