Widget* WebFrame::createJavaAppletWidget(const IntSize& pluginSize, Element* element, const KURL& /*baseURL*/, const Vector<String>& paramNames, const Vector<String>& paramValues) { PluginView* pluginView = PluginView::create(core(this), pluginSize, element, KURL(), paramNames, paramValues, "application/x-java-applet", false); // Check if the plugin can be loaded successfully if (pluginView->plugin() && pluginView->plugin()->load()) return pluginView; return pluginView; }
Widget* WebFrameLoaderClient::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { WebView* webView = m_webFrame->webView(); COMPtr<IWebUIDelegate> ui; if (SUCCEEDED(webView->uiDelegate(&ui)) && ui) { COMPtr<IWebUIDelegatePrivate4> uiPrivate(Query, ui); if (uiPrivate) { // Assemble the view arguments in a property bag. HashMap<String, String> viewArguments; for (unsigned i = 0; i < paramNames.size(); i++) viewArguments.set(paramNames[i], paramValues[i]); COMPtr<IPropertyBag> viewArgumentsBag(AdoptCOM, COMPropertyBag<String>::adopt(viewArguments)); COMPtr<IDOMElement> containingElement(AdoptCOM, DOMElement::createInstance(element)); HashMap<String, COMVariant> arguments; arguments.set(WebEmbeddedViewAttributesKey, viewArgumentsBag); arguments.set(WebEmbeddedViewBaseURLKey, url.string()); arguments.set(WebEmbeddedViewContainingElementKey, containingElement); arguments.set(WebEmbeddedViewMIMETypeKey, mimeType); COMPtr<IPropertyBag> argumentsBag(AdoptCOM, COMPropertyBag<COMVariant>::adopt(arguments)); COMPtr<IWebEmbeddedView> view; HRESULT result = uiPrivate->embeddedViewWithArguments(webView, m_webFrame, argumentsBag.get(), &view); if (SUCCEEDED(result)) { HWND parentWindow; HRESULT hr = webView->viewWindow((OLE_HANDLE*)&parentWindow); ASSERT(SUCCEEDED(hr)); return EmbeddedWidget::create(view.get(), element, parentWindow, pluginSize); } } } Frame* frame = core(m_webFrame); PluginView* pluginView = PluginView::create(frame, pluginSize, element, url, paramNames, paramValues, mimeType, loadManually); if (pluginView->status() == PluginStatusLoadedSuccessfully) return pluginView; COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate; if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate))) return pluginView; RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); unsigned count = (unsigned)paramNames.size(); for (unsigned i = 0; i < count; i++) { if (paramNames[i] == "pluginspage") { static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey); RetainPtr<CFStringRef> str(AdoptCF, paramValues[i].createCFString()); CFDictionarySetValue(userInfo.get(), key, str.get()); break; } } if (!mimeType.isNull()) { static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorMIMETypeKey); RetainPtr<CFStringRef> str(AdoptCF, mimeType.createCFString()); CFDictionarySetValue(userInfo.get(), key, str.get()); } String pluginName; if (pluginView->plugin()) pluginName = pluginView->plugin()->name(); if (!pluginName.isNull()) { static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInNameKey); RetainPtr<CFStringRef> str(AdoptCF, pluginName.createCFString()); CFDictionarySetValue(userInfo.get(), key, str.get()); } COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance()); userInfoBag->setDictionary(userInfo.get()); int errorCode = 0; switch (pluginView->status()) { case PluginStatusCanNotFindPlugin: errorCode = WebKitErrorCannotFindPlugIn; break; case PluginStatusCanNotLoadPlugin: errorCode = WebKitErrorCannotLoadPlugIn; break; default: ASSERT_NOT_REACHED(); } ResourceError resourceError(String(WebKitErrorDomain), errorCode, url.string(), String()); COMPtr<IWebError> error(AdoptCOM, WebError::createInstance(resourceError, userInfoBag.get())); resourceLoadDelegate->plugInFailedWithError(webView, error.get(), getWebDataSource(frame->loader()->documentLoader())); return pluginView; }