2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
4 * Copyright (C) 2010 Girish Ramakrishnan <girish@forwardbias.in>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "PluginView.h"
32 #include "BridgeJSC.h"
35 #include "CookieJar.h"
37 #include "DocumentLoader.h"
39 #include "FocusController.h"
41 #include "FrameLoader.h"
42 #include "FrameLoaderClient.h"
43 #include "FrameTree.h"
44 #include "FrameView.h"
45 #include "GraphicsContext.h"
46 #include "HTMLNames.h"
47 #include "HTMLPlugInElement.h"
49 #include "KeyboardEvent.h"
50 #include "MIMETypeRegistry.h"
51 #include "MouseEvent.h"
52 #include "NotImplemented.h"
54 #include "PlatformMouseEvent.h"
55 #include "PluginDatabase.h"
56 #include "PluginDebug.h"
57 #include "PluginMainThreadScheduler.h"
58 #include "PluginPackage.h"
59 #include "ProxyServer.h"
60 #include "RenderBox.h"
61 #include "RenderObject.h"
62 #include "ScriptValue.h"
63 #include "SecurityOrigin.h"
65 #include "npruntime_impl.h"
66 #include <wtf/ASCIICType.h>
68 #if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
69 #include "PluginMessageThrottlerWin.h"
73 #include "JSDOMBinding.h"
74 #include "JSDOMWindow.h"
75 #include "c_instance.h"
76 #include "runtime_root.h"
77 #include <runtime/JSLock.h>
78 #include <runtime/JSValue.h>
87 #if ENABLE(NETSCAPE_PLUGIN_API)
95 using namespace HTMLNames;
97 static int s_callingPlugin;
99 typedef HashMap<NPP, PluginView*> InstanceMap;
101 static InstanceMap& instanceMap()
103 static InstanceMap& map = *new InstanceMap;
107 static String scriptStringIfJavaScriptURL(const KURL& url)
109 if (!protocolIsJavaScript(url))
112 // This returns an unescaped string
113 return decodeURLEscapeSequences(url.string().substring(11));
116 PluginView* PluginView::s_currentPluginView = 0;
118 void PluginView::popPopupsStateTimerFired(Timer<PluginView>*)
120 popPopupsEnabledState();
123 #if ENABLE(TIZEN_SUPPORT_PLUGINS)
124 IntRect PluginView::windowClipRect() const
126 // Start by clipping to our bounds.
127 IntRect clipRect(m_windowRect);
129 // Take our element and get the clip rect from the enclosing layer and frame view.
130 //RenderLayer* layer = m_element->renderer()->enclosingLayer(); // comment out unused variable by dw1106.park
132 FrameView* parentView = m_element->document()->view();
135 //going throught frame tree to get main frame and its scale factor
136 //in current implementation every frames except main have alway scale factor = 1.0
137 Frame *l_mainFrame = parentView->frame();
138 Frame *l_parentFrame = l_mainFrame->tree()->parent();
139 while(l_parentFrame != NULL) {
140 l_mainFrame = l_parentFrame;
141 l_parentFrame = l_parentFrame->tree()->parent();
143 #if ENABLE(TIZEN_CAIRO_SCALE_PATCH)
144 float zoomRatio = l_mainFrame->view()->scaleFactor(); ///<
145 IntRect frameRect = parentView->contentsToWindow(parentView->visibleContentRect(false));
147 //because of wrong scale factors in frames in webkit x, y must be multiplied by zoom ratio
148 //and sizes: width, height must be multiplied by zoom ratio for main frame and by power 2 for iframes
149 frameRect.scale(zoomRatio);
151 // This code affects wrong dimension of clipRect.
152 /*if(parentFrame()) {
153 frameRect.setWidth(frameRect.width() * zoomRatio);
154 frameRect.setHeight(frameRect.height() * zoomRatio);
157 clipRect.intersect(frameRect);
162 IntRect PluginView::windowClipRect() const
164 // Start by clipping to our bounds.
165 IntRect clipRect(m_windowRect);
167 // Take our element and get the clip rect from the enclosing layer and frame view.
168 RenderLayer* layer = m_element->renderer()->enclosingLayer();
169 FrameView* parentView = m_element->document()->view();
170 clipRect.intersect(parentView->windowClipRectForLayer(layer, true));
176 void PluginView::setFrameRect(const IntRect& rect)
178 if (m_element->document()->printing())
181 if (rect != frameRect())
182 Widget::setFrameRect(rect);
184 updatePluginWidget();
187 // On Windows always call plugin to change geometry.
188 setNPWindowRect(rect);
189 #elif defined(XP_UNIX)
190 // On Unix, multiple calls to setNPWindow() in windowed mode causes Flash to crash
191 if (m_mode == NP_FULL || !m_isWindowed)
192 setNPWindowRect(rect);
196 void PluginView::frameRectsChanged()
198 updatePluginWidget();
201 void PluginView::handleEvent(Event* event)
204 #if !ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
209 // Protect the plug-in from deletion while dispatching the event.
210 RefPtr<PluginView> protect(this);
212 if (event->isMouseEvent())
213 handleMouseEvent(static_cast<MouseEvent*>(event));
214 else if (event->isKeyboardEvent())
215 handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
216 else if (event->type() == eventNames().contextmenuEvent)
217 event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
218 #if ENABLE(TOUCH_EVENTS) && PLATFORM(EFL) && ENABLE(TIZEN_PLUGIN_SNPEVENT)
219 else if (event->isTouchEvent())
220 handleTouchEvent(static_cast<TouchEvent*>(event));
222 #if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
223 else if (event->type() == eventNames().focusoutEvent)
224 handleFocusOutEvent();
225 else if (event->type() == eventNames().focusinEvent)
226 handleFocusInEvent();
230 void PluginView::init()
232 if (m_haveInitialized)
235 m_haveInitialized = true;
238 ASSERT(m_status == PluginStatusCanNotFindPlugin);
242 LOG(Plugins, "PluginView::init(): Initializing plug-in '%s'", m_plugin->name().utf8().data());
244 if (!m_plugin->load()) {
246 m_status = PluginStatusCanNotLoadPlugin;
250 if (!startOrAddToUnstartedList()) {
251 m_status = PluginStatusCanNotLoadPlugin;
255 m_status = PluginStatusLoadedSuccessfully;
258 bool PluginView::startOrAddToUnstartedList()
260 if (!m_parentFrame->page())
263 // We only delay starting the plug-in if we're going to kick off the load
264 // ourselves. Otherwise, the loader will try to deliver data before we've
265 // started the plug-in.
266 if (!m_loadManually && !m_parentFrame->page()->canStartMedia()) {
267 m_parentFrame->document()->addMediaCanStartListener(this);
268 m_isWaitingToStart = true;
275 bool PluginView::start()
280 m_isWaitingToStart = false;
282 PluginMainThreadScheduler::scheduler().registerPlugin(m_instance);
285 ASSERT(m_plugin->pluginFuncs()->newp);
289 PluginView::setCurrentPluginView(this);
291 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
293 setCallingPlugin(true);
294 npErr = m_plugin->pluginFuncs()->newp((NPMIMEType)m_mimeType.utf8().data(), m_instance, m_mode, m_paramCount, m_paramNames, m_paramValues, NULL);
295 setCallingPlugin(false);
297 PluginView::setCurrentPluginView(0);
300 if (npErr != NPERR_NO_ERROR) {
301 m_status = PluginStatusCanNotLoadPlugin;
302 PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
308 if (!m_url.isEmpty() && !m_loadManually) {
309 FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
310 frameLoadRequest.resourceRequest().setHTTPMethod("GET");
311 frameLoadRequest.resourceRequest().setURL(m_url);
312 load(frameLoadRequest, false, 0);
315 m_status = PluginStatusLoadedSuccessfully;
317 if (!platformStart())
318 m_status = PluginStatusCanNotLoadPlugin;
320 if (m_status != PluginStatusLoadedSuccessfully)
326 void PluginView::mediaCanStart()
328 ASSERT(!m_isStarted);
330 parentFrame()->loader()->client()->dispatchDidFailToStartPlugin(this);
333 PluginView::~PluginView()
335 LOG(Plugins, "PluginView::~PluginView()");
337 ASSERT(!m_lifeSupportTimer.isActive());
339 // If we failed to find the plug-in, we'll return early in our constructor, and
340 // m_instance will be 0.
342 instanceMap().remove(m_instance);
344 if (m_isWaitingToStart)
345 m_parentFrame->document()->removeMediaCanStartListener(this);
347 #if PLATFORM(EFL) && ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS) && ENABLE(TIZEN_MARK_PLUGIN_HANDLING_EVENTS)
348 if (s_currentPluginHandlingEvents == this) {
349 if (s_isHandlingEvents)
350 s_isHandlingEvents = false;
351 s_currentPluginHandlingEvents = 0;
357 deleteAllValues(m_requests);
359 freeStringArray(m_paramNames, m_paramCount);
360 freeStringArray(m_paramValues, m_paramCount);
364 m_parentFrame->script()->cleanupScriptObjectsForPlugin(this);
366 if (m_plugin && !(m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)))
370 void PluginView::stop()
375 LOG(Plugins, "PluginView::stop(): Stopping plug-in '%s'", m_plugin->name().utf8().data());
377 HashSet<RefPtr<PluginStream> > streams = m_streams;
378 HashSet<RefPtr<PluginStream> >::iterator end = streams.end();
379 for (HashSet<RefPtr<PluginStream> >::iterator it = streams.begin(); it != end; ++it) {
381 disconnectStream((*it).get());
384 ASSERT(m_streams.isEmpty());
389 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
392 #if ENABLE(NETSCAPE_PLUGIN_API)
393 #if defined(XP_WIN) && !PLATFORM(GTK)
394 // Unsubclass the window
397 WNDPROC currentWndProc = (WNDPROC)GetWindowLong(platformPluginWidget(), GWL_WNDPROC);
399 if (currentWndProc == PluginViewWndProc)
400 SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)m_pluginWndProc);
402 WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
404 if (currentWndProc == PluginViewWndProc)
405 SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)m_pluginWndProc);
408 #endif // !defined(XP_WIN) || PLATFORM(GTK)
409 #endif // ENABLE(NETSCAPE_PLUGIN_API)
411 #if !defined(XP_MACOSX)
413 m_npWindow.window = 0;
415 if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
416 PluginView::setCurrentPluginView(this);
417 setCallingPlugin(true);
418 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
419 setCallingPlugin(false);
420 PluginView::setCurrentPluginView(0);
424 if (m_isWindowed && m_npWindow.ws_info)
425 delete (NPSetWindowCallbackStruct *)m_npWindow.ws_info;
426 m_npWindow.ws_info = 0;
429 #endif // !defined(XP_MACOSX)
431 PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
433 NPSavedData* savedData = 0;
434 PluginView::setCurrentPluginView(this);
435 setCallingPlugin(true);
436 NPError npErr = m_plugin->pluginFuncs()->destroy(m_instance, &savedData);
437 setCallingPlugin(false);
439 PluginView::setCurrentPluginView(0);
441 #if ENABLE(NETSCAPE_PLUGIN_API)
443 // TODO: Actually save this data instead of just discarding it
445 NPN_MemFree(savedData->buf);
446 NPN_MemFree(savedData);
450 m_instance->pdata = 0;
453 void PluginView::setCurrentPluginView(PluginView* pluginView)
455 s_currentPluginView = pluginView;
458 PluginView* PluginView::currentPluginView()
460 return s_currentPluginView;
463 static char* createUTF8String(const String& str)
465 CString cstr = str.utf8();
466 char* result = reinterpret_cast<char*>(fastMalloc(cstr.length() + 1));
468 strncpy(result, cstr.data(), cstr.length() + 1);
473 void PluginView::performRequest(PluginRequest* request)
478 // don't let a plugin start any loads if it is no longer part of a document that is being
479 // displayed unless the loads are in the same frame as the plugin.
480 const String& targetFrameName = request->frameLoadRequest().frameName();
481 if (m_parentFrame->loader()->documentLoader() != m_parentFrame->loader()->activeDocumentLoader() &&
482 (targetFrameName.isNull() || m_parentFrame->tree()->find(targetFrameName) != m_parentFrame))
485 KURL requestURL = request->frameLoadRequest().resourceRequest().url();
486 String jsString = scriptStringIfJavaScriptURL(requestURL);
488 if (jsString.isNull()) {
489 // if this is not a targeted request, create a stream for it. otherwise,
490 // just pass it off to the loader
491 if (targetFrameName.isEmpty()) {
492 RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
493 m_streams.add(stream);
496 // If the target frame is our frame, we could destroy the
497 // PluginView, so we protect it. <rdar://problem/6991251>
498 RefPtr<PluginView> protect(this);
500 m_parentFrame->loader()->load(request->frameLoadRequest().resourceRequest(), targetFrameName, false);
502 // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading
503 if (request->sendNotification()) {
504 PluginView::setCurrentPluginView(this);
506 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
508 setCallingPlugin(true);
509 m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData());
510 setCallingPlugin(false);
511 PluginView::setCurrentPluginView(0);
517 // Targeted JavaScript requests are only allowed on the frame that contains the JavaScript plugin
518 // and this has been made sure in ::load.
519 ASSERT(targetFrameName.isEmpty() || m_parentFrame->tree()->find(targetFrameName) == m_parentFrame);
521 // Executing a script can cause the plugin view to be destroyed, so we keep a reference to it.
522 RefPtr<PluginView> protector(this);
523 ScriptValue result = m_parentFrame->script()->executeScript(jsString, request->shouldAllowPopups());
525 if (targetFrameName.isNull()) {
529 ScriptState* scriptState = m_parentFrame->script()->globalObject(pluginWorld())->globalExec();
531 ScriptState* scriptState = 0; // Not used with V8
534 if (result.getString(scriptState, resultString))
535 cstr = resultString.utf8();
537 RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
538 m_streams.add(stream);
539 stream->sendJavaScriptStream(requestURL, cstr);
543 void PluginView::requestTimerFired(Timer<PluginView>* timer)
545 ASSERT(timer == &m_requestTimer);
546 ASSERT(m_requests.size() > 0);
547 ASSERT(!m_isJavaScriptPaused);
549 PluginRequest* request = m_requests[0];
550 m_requests.remove(0);
552 // Schedule a new request before calling performRequest since the call to
553 // performRequest can cause the plugin view to be deleted.
554 if (m_requests.size() > 0)
555 m_requestTimer.startOneShot(0);
557 performRequest(request);
561 void PluginView::scheduleRequest(PluginRequest* request)
563 m_requests.append(request);
565 if (!m_isJavaScriptPaused)
566 m_requestTimer.startOneShot(0);
569 NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData)
571 ASSERT(frameLoadRequest.resourceRequest().httpMethod() == "GET" || frameLoadRequest.resourceRequest().httpMethod() == "POST");
573 KURL url = frameLoadRequest.resourceRequest().url();
576 return NPERR_INVALID_URL;
578 // Don't allow requests to be made when the document loader is stopping all loaders.
579 DocumentLoader* loader = m_parentFrame->loader()->documentLoader();
580 if (!loader || loader->isStopping())
581 return NPERR_GENERIC_ERROR;
583 const String& targetFrameName = frameLoadRequest.frameName();
584 String jsString = scriptStringIfJavaScriptURL(url);
586 if (!jsString.isNull()) {
587 // Return NPERR_GENERIC_ERROR if JS is disabled. This is what Mozilla does.
588 if (!m_parentFrame->script()->canExecuteScripts(NotAboutToExecuteScript))
589 return NPERR_GENERIC_ERROR;
591 // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
592 if (!targetFrameName.isNull() && m_parentFrame->tree()->find(targetFrameName) != m_parentFrame)
593 return NPERR_INVALID_PARAM;
594 } else if (!m_parentFrame->document()->securityOrigin()->canDisplay(url))
595 return NPERR_GENERIC_ERROR;
597 PluginRequest* request = new PluginRequest(frameLoadRequest, sendNotification, notifyData, arePopupsAllowed());
598 scheduleRequest(request);
600 return NPERR_NO_ERROR;
603 static KURL makeURL(const KURL& baseURL, const char* relativeURLString)
605 String urlString = relativeURLString;
607 // Strip return characters.
608 urlString.replace('\n', "");
609 urlString.replace('\r', "");
611 return KURL(baseURL, urlString);
614 NPError PluginView::getURLNotify(const char* url, const char* target, void* notifyData)
616 FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
618 frameLoadRequest.setFrameName(target);
619 frameLoadRequest.resourceRequest().setHTTPMethod("GET");
620 frameLoadRequest.resourceRequest().setURL(makeURL(m_baseURL, url));
622 return load(frameLoadRequest, true, notifyData);
625 NPError PluginView::getURL(const char* url, const char* target)
627 FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
629 frameLoadRequest.setFrameName(target);
630 frameLoadRequest.resourceRequest().setHTTPMethod("GET");
631 frameLoadRequest.resourceRequest().setURL(makeURL(m_baseURL, url));
633 return load(frameLoadRequest, false, 0);
636 NPError PluginView::postURLNotify(const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData)
638 return handlePost(url, target, len, buf, file, notifyData, true, true);
641 NPError PluginView::postURL(const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
643 // As documented, only allow headers to be specified via NPP_PostURL when using a file.
644 return handlePost(url, target, len, buf, file, 0, false, file);
647 NPError PluginView::newStream(NPMIMEType type, const char* target, NPStream** stream)
651 return NPERR_GENERIC_ERROR;
654 int32_t PluginView::write(NPStream* stream, int32_t len, void* buffer)
661 NPError PluginView::destroyStream(NPStream* stream, NPReason reason)
663 if (!stream || PluginStream::ownerForStream(stream) != m_instance)
664 return NPERR_INVALID_INSTANCE_ERROR;
666 PluginStream* browserStream = static_cast<PluginStream*>(stream->ndata);
667 browserStream->cancelAndDestroyStream(reason);
669 return NPERR_NO_ERROR;
672 void PluginView::status(const char* message)
674 if (Page* page = m_parentFrame->page())
675 page->chrome()->setStatusbarText(m_parentFrame.get(), String::fromUTF8(message));
678 NPError PluginView::setValue(NPPVariable variable, void* value)
680 LOG(Plugins, "PluginView::setValue(%s): ", prettyNameForNPPVariable(variable, value).data());
683 case NPPVpluginWindowBool:
684 m_isWindowed = value;
685 return NPERR_NO_ERROR;
686 case NPPVpluginTransparentBool:
687 m_isTransparent = value;
688 return NPERR_NO_ERROR;
689 #if defined(XP_MACOSX)
690 case NPPVpluginDrawingModel: {
691 // Can only set drawing model inside NPP_New()
692 if (this != currentPluginView())
693 return NPERR_GENERIC_ERROR;
695 NPDrawingModel newDrawingModel = NPDrawingModel(uintptr_t(value));
696 switch (newDrawingModel) {
697 case NPDrawingModelCoreGraphics:
698 m_drawingModel = newDrawingModel;
699 return NPERR_NO_ERROR;
700 #ifndef NP_NO_QUICKDRAW
701 case NPDrawingModelQuickDraw:
703 case NPDrawingModelCoreAnimation:
705 LOG(Plugins, "Plugin asked for unsupported drawing model: %s",
706 prettyNameForDrawingModel(newDrawingModel));
707 return NPERR_GENERIC_ERROR;
711 case NPPVpluginEventModel: {
712 // Can only set event model inside NPP_New()
713 if (this != currentPluginView())
714 return NPERR_GENERIC_ERROR;
716 NPEventModel newEventModel = NPEventModel(uintptr_t(value));
717 switch (newEventModel) {
719 case NPEventModelCarbon:
721 case NPEventModelCocoa:
722 m_eventModel = newEventModel;
723 return NPERR_NO_ERROR;
726 LOG(Plugins, "Plugin asked for unsupported event model: %s",
727 prettyNameForEventModel(newEventModel));
728 return NPERR_GENERIC_ERROR;
731 #endif // defined(XP_MACOSX)
733 #if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
734 case NPPVpluginWindowlessLocalBool:
735 m_renderToImage = true;
736 return NPERR_NO_ERROR;
739 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN) && !ENABLE(TIZEN_WEBKIT2)
742 if (!root() || !root()->evasObject())
743 return NPERR_GENERIC_ERROR;
744 Evas_Object* pWebkit = evas_object_smart_parent_get(root()->evasObject());
746 return NPERR_GENERIC_ERROR;
747 evas_object_smart_callback_call(pWebkit, "requestToNative,json", value);
748 return NPERR_NO_ERROR;
750 #endif //ENABLE(TIZEN_JSBRIDGE_PLUGIN)
754 return NPERR_GENERIC_ERROR;
758 void PluginView::invalidateTimerFired(Timer<PluginView>* timer)
760 ASSERT(timer == &m_invalidateTimer);
762 for (unsigned i = 0; i < m_invalidRects.size(); i++)
763 invalidateRect(m_invalidRects[i]);
764 m_invalidRects.clear();
768 void PluginView::pushPopupsEnabledState(bool state)
770 m_popupStateStack.append(state);
773 void PluginView::popPopupsEnabledState()
775 m_popupStateStack.removeLast();
778 bool PluginView::arePopupsAllowed() const
780 if (!m_popupStateStack.isEmpty())
781 return m_popupStateStack.last();
786 void PluginView::setJavaScriptPaused(bool paused)
788 if (m_isJavaScriptPaused == paused)
790 m_isJavaScriptPaused = paused;
792 if (m_isJavaScriptPaused)
793 m_requestTimer.stop();
794 else if (!m_requests.isEmpty())
795 m_requestTimer.startOneShot(0);
798 #if ENABLE(NETSCAPE_PLUGIN_API)
799 NPObject* PluginView::npObject()
801 NPObject* object = 0;
803 if (!m_isStarted || !m_plugin || !m_plugin->pluginFuncs()->getvalue)
806 // On Windows, calling Java's NPN_GetValue can allow the message loop to
807 // run, allowing loading to take place or JavaScript to run. Protect the
808 // PluginView from destruction. <rdar://problem/6978804>
809 RefPtr<PluginView> protect(this);
813 PluginView::setCurrentPluginView(this);
815 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
817 setCallingPlugin(true);
818 npErr = m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginScriptableNPObject, &object);
819 setCallingPlugin(false);
820 PluginView::setCurrentPluginView(0);
823 if (npErr != NPERR_NO_ERROR)
831 PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
833 #if ENABLE(NETSCAPE_PLUGIN_API)
834 NPObject* object = npObject();
839 // The renderer for the PluginView was destroyed during the above call, and
840 // the PluginView will be destroyed when this function returns, so we
845 RefPtr<JSC::Bindings::RootObject> root = m_parentFrame->script()->createRootObject(this);
846 RefPtr<JSC::Bindings::Instance> instance = JSC::Bindings::CInstance::create(object, root.release());
848 _NPN_ReleaseObject(object);
850 return instance.release();
857 void PluginView::disconnectStream(PluginStream* stream)
859 ASSERT(m_streams.contains(stream));
861 m_streams.remove(stream);
864 void PluginView::setParameters(const Vector<String>& paramNames, const Vector<String>& paramValues)
866 ASSERT(paramNames.size() == paramValues.size());
868 unsigned size = paramNames.size();
869 unsigned paramCount = 0;
871 m_paramNames = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
872 m_paramValues = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
874 for (unsigned i = 0; i < size; i++) {
875 if (m_plugin->quirks().contains(PluginQuirkRemoveWindowlessVideoParam) && equalIgnoringCase(paramNames[i], "windowlessvideo"))
878 if (paramNames[i] == "pluginspage")
879 m_pluginsPage = paramValues[i];
881 m_paramNames[paramCount] = createUTF8String(paramNames[i]);
882 m_paramValues[paramCount] = createUTF8String(paramValues[i]);
887 m_paramCount = paramCount;
890 PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* plugin, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
891 : m_parentFrame(parentFrame)
896 , m_baseURL(m_parentFrame->document()->baseURL()) // FIXME: No need for this member variable!
897 , m_status(PluginStatusLoadedSuccessfully)
898 , m_requestTimer(this, &PluginView::requestTimerFired)
899 , m_invalidateTimer(this, &PluginView::invalidateTimerFired)
900 , m_popPopupsStateTimer(this, &PluginView::popPopupsStateTimerFired)
901 , m_lifeSupportTimer(this, &PluginView::lifeSupportTimerFired)
902 , m_mode(loadManually ? NP_FULL : NP_EMBED)
905 , m_mimeType(mimeType)
907 #if defined(XP_MACOSX)
908 , m_isWindowed(false)
912 , m_isTransparent(false)
913 , m_haveInitialized(false)
914 , m_isWaitingToStart(false)
916 , m_needsXEmbed(false)
918 #if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
921 , m_isCallingPluginWndProc(false)
923 , m_haveUpdatedPluginWidget(false)
925 #if (PLATFORM(QT) && OS(WINDOWS)) || defined(XP_MACOSX) || PLATFORM(EFL)
928 #if defined(XP_MACOSX)
929 , m_drawingModel(NPDrawingModel(-1))
930 , m_eventModel(NPEventModel(-1))
934 #if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
935 , m_hasPendingGeometryChange(true)
941 #if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
942 , m_renderToImage(false)
944 , m_loadManually(loadManually)
946 , m_isJavaScriptPaused(false)
947 , m_haveCalledSetWindow(false)
948 //mariusz.g@samsung.com
949 #if ENABLE(TIZEN_EVAS_OBJECT_PLUGIN) && PLATFORM(EFL)
950 , m_pluginEvasObject(0)
951 , m_pluginEvasObjectClipper(0)
952 , m_pluginParentWindow(0)
954 #if ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS)
955 , m_lastEventWasHandled(false)
960 m_status = PluginStatusCanNotFindPlugin;
964 m_instance = &m_instanceStruct;
965 m_instance->ndata = this;
966 m_instance->pdata = 0;
968 instanceMap().add(m_instance, this);
970 setParameters(paramNames, paramValues);
972 memset(&m_npWindow, 0, sizeof(m_npWindow));
973 #if defined(XP_MACOSX)
974 memset(&m_npCgContext, 0, sizeof(m_npCgContext));
980 void PluginView::focusPluginElement()
983 if (Page* page = m_parentFrame->page())
984 page->focusController()->setFocusedNode(m_element, m_parentFrame);
986 m_parentFrame->document()->setFocusedNode(m_element);
989 void PluginView::didReceiveResponse(const ResourceResponse& response)
991 if (m_status != PluginStatusLoadedSuccessfully)
994 ASSERT(m_loadManually);
995 ASSERT(!m_manualStream);
997 m_manualStream = PluginStream::create(this, m_parentFrame.get(), m_parentFrame->loader()->activeDocumentLoader()->request(), false, 0, plugin()->pluginFuncs(), instance(), m_plugin->quirks());
998 m_manualStream->setLoadManually(true);
1000 m_manualStream->didReceiveResponse(0, response);
1003 void PluginView::didReceiveData(const char* data, int length)
1005 if (m_status != PluginStatusLoadedSuccessfully)
1008 ASSERT(m_loadManually);
1009 ASSERT(m_manualStream);
1011 m_manualStream->didReceiveData(0, data, length);
1014 void PluginView::didFinishLoading()
1016 if (m_status != PluginStatusLoadedSuccessfully)
1019 ASSERT(m_loadManually);
1020 ASSERT(m_manualStream);
1022 m_manualStream->didFinishLoading(0);
1025 void PluginView::didFail(const ResourceError& error)
1027 if (m_status != PluginStatusLoadedSuccessfully)
1030 ASSERT(m_loadManually);
1033 m_manualStream->didFail(0, error);
1036 void PluginView::setCallingPlugin(bool b) const
1038 if (!m_plugin->quirks().contains(PluginQuirkHasModalMessageLoop))
1046 ASSERT(s_callingPlugin >= 0);
1049 bool PluginView::isCallingPlugin()
1051 return s_callingPlugin > 0;
1054 PassRefPtr<PluginView> PluginView::create(Frame* parentFrame, const IntSize& size, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
1056 // if we fail to find a plugin for this MIME type, findPlugin will search for
1057 // a plugin by the file extension and update the MIME type, so pass a mutable String
1058 String mimeTypeCopy = mimeType;
1059 PluginPackage* plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
1061 // No plugin was found, try refreshing the database and searching again
1062 if (!plugin && PluginDatabase::installedPlugins()->refresh()) {
1063 mimeTypeCopy = mimeType;
1064 plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
1067 return adoptRef(new PluginView(parentFrame, size, plugin, element, url, paramNames, paramValues, mimeTypeCopy, loadManually));
1070 void PluginView::freeStringArray(char** stringArray, int length)
1075 for (int i = 0; i < length; i++)
1076 fastFree(stringArray[i]);
1078 fastFree(stringArray);
1081 static inline bool startsWithBlankLine(const Vector<char>& buffer)
1083 return buffer.size() > 0 && buffer[0] == '\n';
1086 static inline int locationAfterFirstBlankLine(const Vector<char>& buffer)
1088 const char* bytes = buffer.data();
1089 unsigned length = buffer.size();
1091 for (unsigned i = 0; i < length - 4; i++) {
1092 // Support for Acrobat. It sends "\n\n".
1093 if (bytes[i] == '\n' && bytes[i + 1] == '\n')
1096 // Returns the position after 2 CRLF's or 1 CRLF if it is the first line.
1097 if (bytes[i] == '\r' && bytes[i + 1] == '\n') {
1101 else if (bytes[i] == '\n')
1102 // Support for Director. It sends "\r\n\n" (3880387).
1104 else if (bytes[i] == '\r' && bytes[i + 1] == '\n')
1105 // Support for Flash. It sends "\r\n\r\n" (3758113).
1113 static inline const char* findEOL(const char* bytes, unsigned length)
1115 // According to the HTTP specification EOL is defined as
1116 // a CRLF pair. Unfortunately, some servers will use LF
1117 // instead. Worse yet, some servers will use a combination
1118 // of both (e.g. <header>CRLFLF<body>), so findEOL needs
1119 // to be more forgiving. It will now accept CRLF, LF or
1122 // It returns NULL if EOLF is not found or it will return
1123 // a pointer to the first terminating character.
1124 for (unsigned i = 0; i < length; i++) {
1125 if (bytes[i] == '\n')
1127 if (bytes[i] == '\r') {
1128 // Check to see if spanning buffer bounds
1129 // (CRLF is across reads). If so, wait for
1131 if (i + 1 == length)
1141 static inline String capitalizeRFC822HeaderFieldName(const String& name)
1143 bool capitalizeCharacter = true;
1146 for (unsigned i = 0; i < name.length(); i++) {
1149 if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
1150 c = toASCIIUpper(name[i]);
1151 else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
1152 c = toASCIILower(name[i]);
1157 capitalizeCharacter = true;
1159 capitalizeCharacter = false;
1167 static inline HTTPHeaderMap parseRFC822HeaderFields(const Vector<char>& buffer, unsigned length)
1169 const char* bytes = buffer.data();
1172 HTTPHeaderMap headerFields;
1174 // Loop ove rlines until we're past the header, or we can't find any more end-of-lines
1175 while ((eol = findEOL(bytes, length))) {
1176 const char* line = bytes;
1177 int lineLength = eol - bytes;
1179 // Move bytes to the character after the terminator as returned by findEOL.
1181 if ((*eol == '\r') && (*bytes == '\n'))
1182 bytes++; // Safe since findEOL won't return a spanning CRLF.
1184 length -= (bytes - line);
1185 if (lineLength == 0)
1186 // Blank line; we're at the end of the header
1188 else if (*line == ' ' || *line == '\t') {
1189 // Continuation of the previous header
1190 if (lastKey.isNull()) {
1191 // malformed header; ignore it and continue
1194 // Merge the continuation of the previous header
1195 String currentValue = headerFields.get(lastKey);
1196 String newValue(line, lineLength);
1198 headerFields.set(lastKey, currentValue + newValue);
1203 for (colon = line; *colon != ':' && colon != eol; colon++) {
1207 // malformed header; ignore it and continue
1210 lastKey = capitalizeRFC822HeaderFieldName(String(line, colon - line));
1213 for (colon++; colon != eol; colon++) {
1214 if (*colon != ' ' && *colon != '\t')
1220 value = String(colon, eol - colon);
1222 String oldValue = headerFields.get(lastKey);
1223 if (!oldValue.isNull()) {
1224 String tmp = oldValue;
1230 headerFields.set(lastKey, value);
1235 return headerFields;
1238 NPError PluginView::handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders)
1240 if (!url || !len || !buf)
1241 return NPERR_INVALID_PARAM;
1243 FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
1245 HTTPHeaderMap headerFields;
1246 Vector<char> buffer;
1249 NPError readResult = handlePostReadFile(buffer, len, buf);
1250 if(readResult != NPERR_NO_ERROR)
1254 memcpy(buffer.data(), buf, len);
1257 const char* postData = buffer.data();
1258 int postDataLength = buffer.size();
1261 if (startsWithBlankLine(buffer)) {
1265 int location = locationAfterFirstBlankLine(buffer);
1266 if (location != -1) {
1267 // If the blank line is somewhere in the middle of the buffer, everything before is the header
1268 headerFields = parseRFC822HeaderFields(buffer, location);
1269 unsigned dataLength = buffer.size() - location;
1271 // Sometimes plugins like to set Content-Length themselves when they post,
1272 // but WebFoundation does not like that. So we will remove the header
1273 // and instead truncate the data to the requested length.
1274 String contentLength = headerFields.get("Content-Length");
1276 if (!contentLength.isNull())
1277 dataLength = min(contentLength.toInt(), (int)dataLength);
1278 headerFields.remove("Content-Length");
1280 postData += location;
1281 postDataLength = dataLength;
1286 frameLoadRequest.resourceRequest().setHTTPMethod("POST");
1287 frameLoadRequest.resourceRequest().setURL(makeURL(m_baseURL, url));
1288 frameLoadRequest.resourceRequest().addHTTPHeaderFields(headerFields);
1289 frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(postData, postDataLength));
1290 frameLoadRequest.setFrameName(target);
1292 return load(frameLoadRequest, sendNotification, notifyData);
1295 void PluginView::invalidateWindowlessPluginRect(const IntRect& rect)
1300 if (!m_element->renderer())
1302 RenderBox* renderer = toRenderBox(m_element->renderer());
1304 IntRect dirtyRect = rect;
1305 dirtyRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop());
1306 renderer->repaintRectangle(dirtyRect);
1309 void PluginView::paintMissingPluginIcon(GraphicsContext* context, const IntRect& rect)
1311 static RefPtr<Image> nullPluginImage;
1312 if (!nullPluginImage)
1313 nullPluginImage = Image::loadPlatformResource("nullPlugin");
1315 IntRect imageRect(frameRect().x(), frameRect().y(), nullPluginImage->width(), nullPluginImage->height());
1317 int xOffset = (frameRect().width() - imageRect.width()) / 2;
1318 int yOffset = (frameRect().height() - imageRect.height()) / 2;
1320 imageRect.move(xOffset, yOffset);
1322 if (!rect.intersects(imageRect))
1326 context->clip(windowClipRect());
1327 context->drawImage(nullPluginImage.get(), ColorSpaceDeviceRGB, imageRect.location());
1331 static const char* MozillaUserAgent = "Mozilla/5.0 ("
1332 #if defined(XP_MACOSX)
1333 "Macintosh; U; Intel Mac OS X;"
1334 #elif defined(XP_WIN)
1335 "Windows; U; Windows NT 5.1;"
1336 #elif defined(XP_UNIX)
1337 // The Gtk port uses X11 plugins in Mac.
1338 #if OS(DARWIN) && PLATFORM(GTK)
1339 "X11; U; Intel Mac OS X;"
1341 "X11; U; Linux i686;"
1344 " en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
1346 const char* PluginView::userAgent()
1348 if (m_plugin->quirks().contains(PluginQuirkWantsMozillaUserAgent))
1349 return MozillaUserAgent;
1351 if (m_userAgent.isNull())
1352 m_userAgent = m_parentFrame->loader()->userAgent(m_url).utf8();
1354 return m_userAgent.data();
1357 #if ENABLE(NETSCAPE_PLUGIN_API)
1358 const char* PluginView::userAgentStatic()
1360 return MozillaUserAgent;
1365 void PluginView::lifeSupportTimerFired(Timer<PluginView>*)
1370 void PluginView::keepAlive()
1372 if (m_lifeSupportTimer.isActive())
1376 m_lifeSupportTimer.startOneShot(0);
1379 #if ENABLE(NETSCAPE_PLUGIN_API)
1380 void PluginView::keepAlive(NPP instance)
1382 PluginView* view = instanceMap().get(instance);
1389 NPError PluginView::getValueStatic(NPNVariable variable, void* value)
1391 LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
1394 if (platformGetValueStatic(variable, value, &result))
1397 return NPERR_GENERIC_ERROR;
1400 NPError PluginView::getValue(NPNVariable variable, void* value)
1402 LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
1405 if (platformGetValue(variable, value, &result))
1408 if (platformGetValueStatic(variable, value, &result))
1412 case NPNVWindowNPObject: {
1413 if (m_isJavaScriptPaused)
1414 return NPERR_GENERIC_ERROR;
1416 NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
1418 // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
1419 if (windowScriptObject)
1420 _NPN_RetainObject(windowScriptObject);
1422 void** v = (void**)value;
1423 *v = windowScriptObject;
1425 return NPERR_NO_ERROR;
1428 case NPNVPluginElementNPObject: {
1429 if (m_isJavaScriptPaused)
1430 return NPERR_GENERIC_ERROR;
1432 NPObject* pluginScriptObject = 0;
1434 if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
1435 pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
1437 // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
1438 if (pluginScriptObject)
1439 _NPN_RetainObject(pluginScriptObject);
1441 void** v = (void**)value;
1442 *v = pluginScriptObject;
1444 return NPERR_NO_ERROR;
1447 case NPNVprivateModeBool: {
1448 Page* page = m_parentFrame->page();
1450 return NPERR_GENERIC_ERROR;
1451 *((NPBool*)value) = !page->settings() || page->settings()->privateBrowsingEnabled();
1452 return NPERR_NO_ERROR;
1456 return NPERR_GENERIC_ERROR;
1460 static Frame* getFrame(Frame* parentFrame, Element* element)
1465 Document* document = element->document();
1467 document = element->ownerDocument();
1469 return document->frame();
1474 NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len)
1476 LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
1478 NPError result = NPERR_NO_ERROR;
1481 case NPNURLVCookie: {
1482 KURL u(m_baseURL, url);
1484 Frame* frame = getFrame(parentFrame(), m_element);
1486 const CString cookieStr = cookies(frame->document(), u).utf8();
1487 if (!cookieStr.isNull()) {
1488 const int size = cookieStr.length();
1489 *value = static_cast<char*>(NPN_MemAlloc(size+1));
1491 memset(*value, 0, size+1);
1492 memcpy(*value, cookieStr.data(), size+1);
1496 result = NPERR_OUT_OF_MEMORY_ERROR;
1500 result = NPERR_INVALID_URL;
1503 case NPNURLVProxy: {
1504 KURL u(m_baseURL, url);
1506 Frame* frame = getFrame(parentFrame(), m_element);
1507 const FrameLoader* frameLoader = frame ? frame->loader() : 0;
1508 const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0;
1509 const CString proxyStr = toString(proxyServersForURL(u, context)).utf8();
1510 if (!proxyStr.isNull()) {
1511 const int size = proxyStr.length();
1512 *value = static_cast<char*>(NPN_MemAlloc(size+1));
1514 memset(*value, 0, size+1);
1515 memcpy(*value, proxyStr.data(), size+1);
1519 result = NPERR_OUT_OF_MEMORY_ERROR;
1522 result = NPERR_INVALID_URL;
1526 result = NPERR_GENERIC_ERROR;
1527 LOG(Plugins, "PluginView::getValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
1535 NPError PluginView::setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len)
1537 LOG(Plugins, "PluginView::setValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
1539 NPError result = NPERR_NO_ERROR;
1542 case NPNURLVCookie: {
1543 KURL u(m_baseURL, url);
1545 const String cookieStr = String::fromUTF8(value, len);
1546 Frame* frame = getFrame(parentFrame(), m_element);
1547 if (frame && !cookieStr.isEmpty())
1548 setCookies(frame->document(), u, cookieStr);
1550 result = NPERR_INVALID_URL;
1554 LOG(Plugins, "PluginView::setValueForURL(%s): Plugins are NOT allowed to set proxy information.", prettyNameForNPNURLVariable(variable).data());
1555 result = NPERR_GENERIC_ERROR;
1558 LOG(Plugins, "PluginView::setValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
1559 result = NPERR_GENERIC_ERROR;
1566 NPError PluginView::getAuthenticationInfo(const char* protocol, const char* host, int32_t port, const char* scheme, const char* realm, char** username, uint32_t* ulen, char** password, uint32_t* plen)
1568 LOG(Plugins, "PluginView::getAuthenticationInfo: protocol=%s, host=%s, port=%d", protocol, host, port);
1570 return NPERR_GENERIC_ERROR;
1574 void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
1576 NPP_SetValueProcPtr setValue = m_plugin->pluginFuncs()->setvalue;
1580 PluginView::setCurrentPluginView(this);
1582 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
1584 setCallingPlugin(true);
1585 NPBool value = privateBrowsingEnabled;
1586 setValue(m_instance, NPNVprivateModeBool, &value);
1587 setCallingPlugin(false);
1588 PluginView::setCurrentPluginView(0);
1591 } // namespace WebCore
1593 #endif // ENABLE(NETSCAPE_PLUGIN_API)