void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String& mimeType, const ResourceRequest& resourceRequest) { ASSERT(policyFunction); if (!policyFunction) return; if (resourceRequest.isNull()) { (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore); return; } WebKitWebView* page = getViewFromFrame(m_frame); WebKitNetworkRequest* request = webkit_network_request_new_with_core_request(resourceRequest); WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); if (m_policyDecision) g_object_unref(m_policyDecision); m_policyDecision = policyDecision; gboolean isHandled = false; g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request, mimeType.utf8().data(), policyDecision, &isHandled); g_object_unref(request); if (isHandled) return; if (canShowMIMEType(mimeType)) webkit_web_policy_decision_use (policyDecision); else webkit_web_policy_decision_ignore (policyDecision); }
void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>, const String& frameName) { ASSERT(policyFunction); if (!policyFunction) return; if (resourceRequest.isNull()) { (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore); return; } WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); if (m_policyDecision) g_object_unref(m_policyDecision); m_policyDecision = policyDecision; WebKitWebView* webView = getViewFromFrame(m_frame); GRefPtr<WebKitNetworkRequest> request(adoptGRef(webkit_network_request_new(resourceRequest.url().string().utf8().data()))); GRefPtr<WebKitWebNavigationAction> navigationAction(adoptGRef(getNavigationAction(action, frameName.utf8().data()))); gboolean isHandled = false; g_signal_emit_by_name(webView, "new-window-policy-decision-requested", m_frame, request.get(), navigationAction.get(), policyDecision, &isHandled); // FIXME: I think Qt version marshals this to another thread so when we // have multi-threaded download, we might need to do the same if (!isHandled) (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyUse); }
void FrameLoaderClient::dispatchWillSendRequest(WebCore::DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) { GRefPtr<WebKitNetworkResponse> networkResponse(0); // We are adding one more resource to the load, or maybe we are // just redirecting a load. if (redirectResponse.isNull()) static_cast<WebKit::DocumentLoader*>(loader)->increaseLoadCount(identifier); else networkResponse = adoptGRef(kitNew(redirectResponse)); WebKitWebView* webView = getViewFromFrame(m_frame); GOwnPtr<gchar> identifierString(toString(identifier)); WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get()); GRefPtr<WebKitNetworkRequest> networkRequest(adoptGRef(kitNew(request))); if (!redirectResponse.isNull()) { // This is a redirect, so we need to update the WebResource's knowledge // of the URI. g_free(webResource->priv->uri); webResource->priv->uri = g_strdup(request.url().string().utf8().data()); } g_signal_emit_by_name(webView, "resource-request-starting", m_frame, webResource, networkRequest.get(), networkResponse.get()); // Feed any changes back into the ResourceRequest object. SoupMessage* message = webkit_network_request_get_message(networkRequest.get()); if (!message) { request.setURL(KURL(KURL(), String::fromUTF8(webkit_network_request_get_uri(networkRequest.get())))); return; } request.updateFromSoupMessage(message); }
void FrameLoaderClient::postProgressStartedNotification() { WebKitWebView* webView = getViewFromFrame(m_frame); g_signal_emit_by_name(webView, "load-started", m_frame); g_object_notify(G_OBJECT(webView), "progress"); }
void FrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */) { GRefPtr<WebKitNetworkRequest> networkRequest(adoptGRef(kitNew(request))); WebKitWebView* view = getViewFromFrame(m_frame); webkit_web_view_request_download(view, networkRequest.get()); }
void FrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response) { GRefPtr<WebKitNetworkRequest> networkRequest(adoptGRef(kitNew(request))); WebKitWebView* view = getViewFromFrame(m_frame); webkit_web_view_request_download(view, networkRequest.get(), response, handle); }
void FrameLoaderClient::dispatchDidFinishLoading(WebCore::DocumentLoader* loader, unsigned long identifier) { static_cast<WebKit::DocumentLoader*>(loader)->decreaseLoadCount(identifier); WebKitWebView* webView = getViewFromFrame(m_frame); GOwnPtr<gchar> identifierString(toString(identifier)); WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get()); // A NULL WebResource means the load has been interrupted, and // replaced by another one while this resource was being loaded. if (!webResource) return; const char* uri = webkit_web_resource_get_uri(webResource); RefPtr<ArchiveResource> coreResource(loader->subresource(KURL(KURL(), uri))); // If coreResource is NULL here, the resource failed to load, // unless it's the main resource. if (!coreResource && webResource != webkit_web_view_get_main_resource(webView)) return; if (!coreResource) coreResource = loader->mainResource(); webkit_web_resource_init_with_core_resource(webResource, coreResource.get()); // FIXME: This function should notify the application that the resource // finished loading, maybe using a load-status property in the // WebKitWebResource object, similar to what we do for WebKitWebFrame' // signal. notImplemented(); }
void FrameLoaderClient::provisionalLoadStarted() { WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) webkit_web_view_clear_resources(webView); }
void FrameLoaderClient::dispatchDidCommitLoad() { /* Update the URI once first data has been received. * This means the URI is valid and successfully identify the page that's going to be loaded. */ g_object_freeze_notify(G_OBJECT(m_frame)); WebKitWebFramePrivate* priv = m_frame->priv; g_free(priv->uri); priv->uri = g_strdup(core(m_frame)->loader()->url().prettyURL().utf8().data()); g_free(priv->title); priv->title = NULL; g_object_notify(G_OBJECT(m_frame), "uri"); g_object_notify(G_OBJECT(m_frame), "title"); g_signal_emit_by_name(m_frame, "load-committed"); notifyStatus(m_frame, WEBKIT_LOAD_COMMITTED); WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) { g_object_freeze_notify(G_OBJECT(webView)); g_object_notify(G_OBJECT(webView), "uri"); g_object_notify(G_OBJECT(webView), "title"); g_object_thaw_notify(G_OBJECT(webView)); g_signal_emit_by_name(webView, "load-committed", m_frame); } g_object_thaw_notify(G_OBJECT(m_frame)); }
PassRefPtr<Widget> FrameLoaderClient::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { /* Check if we want to embed a GtkWidget, fallback to plugins later */ CString urlString = url.string().utf8(); CString mimeTypeString = mimeType.utf8(); ASSERT(paramNames.size() == paramValues.size()); GOwnPtr<GHashTable> hash(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free)); for (unsigned i = 0; i < paramNames.size(); ++i) { g_hash_table_insert(hash.get(), g_strdup(paramNames[i].utf8().data()), g_strdup(paramValues[i].utf8().data())); } GtkWidget* gtkWidget = 0; g_signal_emit_by_name(getViewFromFrame(m_frame), "create-plugin-widget", mimeTypeString.data(), urlString.data(), hash.get(), >kWidget); if (gtkWidget) return adoptRef(new GtkPluginWidget(gtkWidget)); RefPtr<PluginView> pluginView = PluginView::create(core(m_frame), pluginSize, element, url, paramNames, paramValues, mimeType, loadManually); if (pluginView->status() == PluginStatusLoadedSuccessfully) return pluginView; return 0; }
void FrameLoaderClient::transitionToCommittedForNewPage() { WebKitWebView* containingWindow = getViewFromFrame(m_frame); IntSize size = IntSize(GTK_WIDGET(containingWindow)->allocation.width, GTK_WIDGET(containingWindow)->allocation.height); bool transparent = webkit_web_view_get_transparent(containingWindow); Color backgroundColor = transparent ? WebCore::Color::transparent : WebCore::Color::white; Frame* frame = core(m_frame); ASSERT(frame); frame->createView(size, backgroundColor, transparent, IntSize(), false); // We need to do further manipulation on the FrameView if it was the mainFrame if (frame != frame->page()->mainFrame()) return; WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow); frame->view()->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment); if (priv->currentMenu) { GtkMenu* menu = priv->currentMenu; priv->currentMenu = NULL; gtk_menu_popdown(menu); g_object_unref(menu); } }
void FrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response) { WebKitNetworkRequest* networkRequest = webkit_network_request_new_with_core_request(request); WebKitWebView* view = getViewFromFrame(m_frame); webkit_web_view_request_download(view, networkRequest, response, handle); g_object_unref(networkRequest); }
void FrameLoaderClient::startDownload(const ResourceRequest& request) { WebKitNetworkRequest* networkRequest = webkit_network_request_new_with_core_request(request); WebKitWebView* view = getViewFromFrame(m_frame); webkit_web_view_request_download(view, networkRequest); g_object_unref(networkRequest); }
void FrameLoaderClient::postProgressEstimateChangedNotification() { WebKitWebView* webView = getViewFromFrame(m_frame); Page* corePage = core(webView); g_signal_emit_by_name(webView, "load-progress-changed", lround(corePage->progress()->estimatedProgress()*100)); g_object_notify(G_OBJECT(webView), "progress"); }
void ProgressTrackerClient::progressStarted(WebCore::Frame& originatingProgressFrame) { WebKitWebFrame* frame = kit(&originatingProgressFrame); ASSERT(m_webView == getViewFromFrame(frame)); g_signal_emit_by_name(m_webView, "load-started", frame); g_object_notify(G_OBJECT(m_webView), "progress"); }
void ProgressTrackerClient::progressEstimateChanged(WebCore::Frame& originatingProgressFrame) { ASSERT(m_webView == getViewFromFrame(kit(&originatingProgressFrame))); WebCore::Page* corePage = core(m_webView); g_signal_emit_by_name(m_webView, "load-progress-changed", lround(corePage->progress().estimatedProgress()*100)); g_object_notify(G_OBJECT(m_webView), "progress"); }
void ProgressTrackerClient::progressFinished(WebCore::Frame& originatingProgressFrame) { WebKitWebFrame* frame = kit(&originatingProgressFrame); ASSERT(m_webView == getViewFromFrame(frame)); // We can get a stopLoad() from dispose when the object is being // destroyed, don't emit the signal in that case. if (!m_webView->priv->disposing) g_signal_emit_by_name(m_webView, "load-finished", frame); }
void FrameLoaderClient::postProgressFinishedNotification() { WebKitWebView* webView = getViewFromFrame(m_frame); WebKitWebViewPrivate* privateData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); // We can get a stopLoad() from dispose when the object is being // destroyed, don't emit the signal in that case. if (!privateData->disposing) g_signal_emit_by_name(webView, "load-finished", m_frame); }
void FrameLoaderClient::dispatchDidChangeLocationWithinPage() { WebKitWebFramePrivate* priv = m_frame->priv; g_free(priv->uri); priv->uri = g_strdup(core(m_frame)->loader()->url().prettyURL().utf8().data()); g_object_notify(G_OBJECT(m_frame), "uri"); WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) g_object_notify(G_OBJECT(webView), "uri"); }
static void notifyStatus(WebKitWebFrame* frame, WebKitLoadStatus loadStatus) { frame->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(frame), "load-status"); WebKitWebView* webView = getViewFromFrame(frame); if (frame == webkit_web_view_get_main_frame(webView)) { webView->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(webView), "load-status"); } }
void FrameLoaderClient::transferLoadingResourceFromPage(WebCore::ResourceLoader* loader, const WebCore::ResourceRequest& request, WebCore::Page* oldPage) { ASSERT(oldPage != core(m_frame)->page()); GOwnPtr<gchar> identifierString(toString(loader->identifier())); ASSERT(!webkit_web_view_get_resource(getViewFromFrame(m_frame), identifierString.get())); assignIdentifierToInitialRequest(loader->identifier(), loader->documentLoader(), request); webkit_web_view_remove_resource(kit(oldPage), identifierString.get()); }
void ChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation) { WebKitWebFrame* webFrame = kit(frame); WebKitWebView* webView = getViewFromFrame(webFrame); WebKitGeolocationPolicyDecision* policyDecision = webkit_geolocation_policy_decision_new(webFrame, geolocation); gboolean isHandled = FALSE; g_signal_emit_by_name(webView, "geolocation-policy-decision-requested", webFrame, policyDecision, &isHandled); if (!isHandled) webkit_geolocation_policy_deny(policyDecision); }
void ChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName) { guint64 defaultQuota = webkit_get_default_web_database_quota(); DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), defaultQuota); WebKitWebFrame* webFrame = kit(frame); WebKitWebView* webView = getViewFromFrame(webFrame); WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(webFrame); WebKitWebDatabase* webDatabase = webkit_security_origin_get_web_database(origin, databaseName.utf8().data()); g_signal_emit_by_name(webView, "database-quota-exceeded", webFrame, webDatabase); }
Frame* FrameLoaderClient::dispatchCreatePage(const NavigationAction&) { WebKitWebView* webView = getViewFromFrame(m_frame); WebKitWebView* newWebView = 0; g_signal_emit_by_name(webView, "create-web-view", m_frame, &newWebView); if (!newWebView) return 0; WebKitWebViewPrivate* privateData = newWebView->priv; return core(privateData->mainFrame); }
void FrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response) { // FIXME: We could reuse the same handle here, but when I tried // implementing that the main load would fail and stop, so I have // simplified this case for now. handle->cancel(); WebKitNetworkRequest* networkRequest = webkit_network_request_new(request.url().string().utf8().data()); WebKitWebView* view = getViewFromFrame(m_frame); webkit_web_view_request_download(view, networkRequest, response); g_object_unref(networkRequest); }
Frame* FrameLoaderClient::dispatchCreatePage() { WebKitWebView* webView = getViewFromFrame(m_frame); WebKitWebView* newWebView = 0; g_signal_emit_by_name(webView, "create-web-view", m_frame, &newWebView); if (!newWebView) return 0; WebKitWebViewPrivate* privateData = WEBKIT_WEB_VIEW_GET_PRIVATE(newWebView); return core(privateData->mainFrame); }
void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) { if (m_loadingErrorPage) return; notifyStatus(m_frame, WEBKIT_LOAD_FAILED); WebKitWebView* webView = getViewFromFrame(m_frame); GError* webError = g_error_new_literal(g_quark_from_string(error.domain().utf8().data()), error.errorCode(), error.localizedDescription().utf8().data()); gboolean isHandled = false; g_signal_emit_by_name(webView, "load-error", m_frame, error.failingURL().utf8().data(), webError, &isHandled); if (isHandled) { g_error_free(webError); return; } if (!shouldFallBack(error)) { g_error_free(webError); return; } m_loadingErrorPage = true; String content; gchar* fileContent = 0; gchar* errorURI = g_filename_to_uri(DATA_DIR"/webkit-1.0/resources/error.html", NULL, NULL); GFile* errorFile = g_file_new_for_uri(errorURI); g_free(errorURI); if (!errorFile) content = makeString("<html><body>", webError->message, "</body></html>"); else { gboolean loaded = g_file_load_contents(errorFile, 0, &fileContent, 0, 0, 0); if (!loaded) content = makeString("<html><body>", webError->message, "</body></html>"); else content = String::format(fileContent, error.failingURL().utf8().data(), webError->message); } webkit_web_frame_load_alternate_string(m_frame, content.utf8().data(), 0, error.failingURL().utf8().data()); g_free(fileContent); if (errorFile) g_object_unref(errorFile); g_error_free(webError); }
static void notifyStatus(WebKitWebFrame* frame, WebKitLoadStatus loadStatus) { frame->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(frame), "load-status"); WebKitWebView* webView = getViewFromFrame(frame); if (frame == webkit_web_view_get_main_frame(webView)) { webView->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(webView), "load-status"); if (AXObjectCache::accessibilityEnabled()) notifyAccessibilityStatus(frame, loadStatus); } }
void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) { WebKitWebView* webView = getViewFromFrame(m_frame); GError* webError = g_error_new_literal(g_quark_from_string(error.domain().utf8().data()), error.errorCode(), error.localizedDescription().utf8().data()); gboolean isHandled = false; g_signal_emit_by_name(webView, "load-error", m_frame, error.failingURL().utf8().data(), webError, &isHandled); if (isHandled) { g_error_free(webError); return; } if (!shouldFallBack(error)) { g_error_free(webError); // FIXME: load-done is deprecated. Please remove when signal's been removed. g_signal_emit_by_name(m_frame, "load-done", false); return; } String content; gchar* fileContent = 0; gchar* errorURI = g_filename_to_uri(DATA_DIR"/webkit-1.0/resources/error.html", NULL, NULL); GFile* errorFile = g_file_new_for_uri(errorURI); g_free(errorURI); if (!errorFile) content = String::format("<html><body>%s</body></html>", webError->message); else { gboolean loaded = g_file_load_contents(errorFile, 0, &fileContent, 0, 0, 0); if (!loaded) content = String::format("<html><body>%s</body></html>", webError->message); else content = String::format(fileContent, error.failingURL().utf8().data(), webError->message); } webkit_web_frame_load_alternate_string(m_frame, content.utf8().data(), 0, error.failingURL().utf8().data()); g_free(fileContent); if (errorFile) g_object_unref(errorFile); g_error_free(webError); // FIXME: load-done is deprecated. Please remove when signal's been removed. g_signal_emit_by_name(m_frame, "load-done", false); }
void FrameLoaderClient::dispatchDidReceiveTitle(const String& title) { WebKitWebFramePrivate* priv = m_frame->priv; g_free(priv->title); priv->title = g_strdup(title.utf8().data()); g_signal_emit_by_name(m_frame, "title-changed", priv->title); g_object_notify(G_OBJECT(m_frame), "title"); WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) { g_signal_emit_by_name(webView, "title-changed", m_frame, title.utf8().data()); g_object_notify(G_OBJECT(webView), "title"); } }