bool ResourceErrorBase::compare(const ResourceError& a, const ResourceError& b) { if (a.isNull() && b.isNull()) return true; if (a.isNull() || b.isNull()) return false; if (a.domain() != b.domain()) return false; if (a.errorCode() != b.errorCode()) return false; if (a.failingURL() != b.failingURL()) return false; if (a.localizedDescription() != b.localizedDescription()) return false; if (a.isCancellation() != b.isCancellation()) return false; return platformCompare(a, b); }
bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) { if (error.errorCode() == WebURLErrorCancelled && error.domain() == String(WebURLErrorDomain)) return false; if (error.errorCode() == WebKitErrorPlugInWillHandleLoad && error.domain() == String(WebKitErrorDomain)) return false; return true; }
void FrameLoaderClientBlackBerry::dispatchDidFailProvisionalLoad(const ResourceError& error) { if (isMainFrame()) { m_loadError = error; m_webPagePrivate->setLoadState(WebPagePrivate::Failed); if (error.domain() == ResourceError::platformErrorDomain && (error.errorCode() == BlackBerry::Platform::FilterStream::StatusErrorAlreadyHandled)) { // Error has already been displayed by client. return; } if (error.domain().isEmpty() && !error.errorCode() && error.failingURL().isEmpty() && error.localizedDescription().isEmpty()) { // Don't try to display empty errors returned from the unimplemented error functions in FrameLoaderClientBlackBerry - there's nothing to display anyway. return; } } if (m_webPagePrivate->m_dumpRenderTree) m_webPagePrivate->m_dumpRenderTree->didFailProvisionalLoadForFrame(m_frame); if (!isMainFrame()) return; String errorPage = m_webPagePrivate->m_client->getErrorPage(error.errorCode() , error.localizedDescription().isEmpty() ? "" : error.localizedDescription().utf8().data() , error.failingURL().isEmpty() ? "" : error.failingURL().utf8().data()); // Make sure we're still in the provisionalLoad state - getErrorPage runs a // nested event loop while it's waiting for client resources to load so // there's a small window for the user to hit stop. if (m_frame->loader()->provisionalDocumentLoader()) { SubstituteData errorData(utf8Buffer(errorPage), "text/html", "utf-8", KURL(KURL(), error.failingURL())); ResourceRequest originalRequest = m_frame->loader()->provisionalDocumentLoader()->originalRequest(); // Loading using SubstituteData will replace the original request with our // error data. This must be done within dispatchDidFailProvisionalLoad, // and do NOT call stopAllLoaders first, because the loader checks the // provisionalDocumentLoader to decide the load type; if called any other // way, the error page is added to the end of the history instead of // replacing the failed load. // // If this comes from a back/forward navigation, we need to save the current viewstate // to original historyitem, and prevent the restore of view state to the error page. if (isBackForwardLoadType(m_frame->loader()->loadType())) { m_frame->loader()->history()->saveScrollPositionAndViewStateToItem(m_frame->loader()->history()->currentItem()); ASSERT(m_frame->loader()->history()->provisionalItem()); m_frame->loader()->history()->provisionalItem()->viewState().shouldSaveViewState = false; } m_loadingErrorPage = true; m_frame->loader()->load(originalRequest, errorData, false); } }
void FrameLoaderClientEfl::dispatchDidFailLoad(const ResourceError& err) { ewk_frame_load_error(m_frame, err.domain().utf8().data(), err.errorCode(), err.isCancellation(), err.localizedDescription().utf8().data(), err.failingURL().utf8().data()); ewk_frame_load_finished(m_frame, err.domain().utf8().data(), err.errorCode(), err.isCancellation(), err.localizedDescription().utf8().data(), err.failingURL().utf8().data()); }
void FetchManager::Loader::didFailAccessControlCheck(const ResourceError& error) { if (error.isCancellation() || error.isTimeout() || error.domain() != errorDomainBlinkInternal) failed(String()); else failed("Fetch API cannot load " + error.failingURL() + ". " + error.localizedDescription()); }
void FrameLoaderClientEfl::dispatchDidFailProvisionalLoad(const ResourceError& err) { Ewk_Frame_Load_Error error; CString errorDomain = err.domain().utf8(); CString errorDescription = err.localizedDescription().utf8(); CString failingUrl = err.failingURL().utf8(); DBG("ewkFrame=%p, error=%s (%d, cancellation=%hhu) \"%s\", url=%s", m_frame, errorDomain.data(), err.errorCode(), err.isCancellation(), errorDescription.data(), failingUrl.data()); error.code = err.errorCode(); error.is_cancellation = err.isCancellation(); error.domain = errorDomain.data(); error.description = errorDescription.data(); error.failing_url = failingUrl.data(); error.resource_identifier = 0; error.frame = m_frame; ewk_frame_load_provisional_failed(m_frame, &error); if (isLoadingMainFrame()) ewk_view_load_provisional_failed(m_view, &error); dispatchDidFailLoad(err); }
void webkitDownloadFailed(WebKitDownload* download, const ResourceError& resourceError) { GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data())); if (download->priv->timer) g_timer_stop(download->priv->timer.get()); g_signal_emit(download, signals[FAILED], 0, webError.get()); g_signal_emit(download, signals[FINISHED], 0, NULL); }
void ArgumentCoder<ResourceError>::encode(ArgumentEncoder* encoder, const ResourceError& resourceError) { encoder->encode(resourceError.domain()); encoder->encode(resourceError.errorCode()); encoder->encode(resourceError.failingURL()); encoder->encode(resourceError.localizedDescription()); #if USE(CFNETWORK) encoder->encode(PlatformCertificateInfo(resourceError.certificate())); #endif }
bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) { DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest()))); DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse()))); if (error.errorCode() == cancelledError.errorCode() && error.domain() == cancelledError.domain()) return false; if (error.errorCode() == pluginWillHandleLoadError.errorCode() && error.domain() == pluginWillHandleLoadError.domain()) return false; #if PLATFORM(QT) DEFINE_STATIC_LOCAL(const ResourceError, errorInterruptedForPolicyChange, (this->interruptedForPolicyChangeError(ResourceRequest()))); if (error.errorCode() == errorInterruptedForPolicyChange.errorCode() && error.domain() == errorInterruptedForPolicyChange.domain()) return false; #endif return true; }
void ArgumentCoder<ResourceError>::encode(ArgumentEncoder* encoder, const ResourceError& resourceError) { bool errorIsNull = resourceError.isNull(); encoder->encode(errorIsNull); if (errorIsNull) return; encoder->encode(resourceError.domain()); encoder->encode(resourceError.errorCode()); encoder->encode(resourceError.failingURL()); encoder->encode(resourceError.localizedDescription()); }
/*this function shows an error message in a popup*/ void FrameLoaderClientWebUI::dispatchDidFailProvisionalLoad(const ResourceError& error) { if (!(error.isNull())) { char errorCode[2]; sprintf(errorCode, "%i", error.errorCode()); String description = error.localizedDescription().deprecatedString().ascii(); description = description.replace("'","\\'"); executeJS(m_frame, "errorLoad('" + String(error.domain().deprecatedString().ascii()) + "','" + String(errorCode) + "','" + String(error.failingURL().deprecatedString().ascii()) + "','" + description + "')"); } m_loadFailed = true; }
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); }
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); }
bool ResourceError::compare(const ResourceError& a, const ResourceError& b) { if (a.isNull() && b.isNull()) return true; if (a.isNull() || b.isNull()) return false; if (a.domain() != b.domain()) return false; if (a.errorCode() != b.errorCode()) return false; if (a.failingURL() != b.failingURL()) return false; if (a.localizedDescription() != b.localizedDescription()) return false; if (a.isCancellation() != b.isCancellation()) return false; if (a.isAccessCheck() != b.isAccessCheck()) return false; if (a.isTimeout() != b.isTimeout()) return false; if (a.staleCopyInCache() != b.staleCopyInCache()) return false; if (a.wasIgnoredByHandler() != b.wasIgnoredByHandler()) return false; return true; }
void ResourceHandle::platformLoadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data) { LOG(Network, "ResourceHandle::platformLoadResourceSynchronously:%s allowStoredCredentials:%u", request.url().string().utf8().data(), storedCredentials); ASSERT(!request.isEmpty()); ASSERT(response.isNull()); ASSERT(error.isNull()); OwnPtr<SynchronousLoaderClient> client = SynchronousLoaderClient::create(); client->setAllowStoredCredentials(storedCredentials == AllowStoredCredentials); RefPtr<ResourceHandle> handle = adoptRef(new ResourceHandle(context, request, client.get(), false /*defersLoading*/, true /*shouldContentSniff*/)); handle->d->m_storageSession = context->storageSession().platformSession(); if (handle->d->m_scheduledFailureType != NoFailure) { error = context->blockedError(request); return; } handle->createCFURLConnection(storedCredentials == AllowStoredCredentials, ResourceHandle::shouldContentSniffURL(request.url()), SchedulingBehavior::Synchronous, handle->client()->connectionProperties(handle.get()).get()); CFURLConnectionScheduleWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode()); CFURLConnectionScheduleDownloadWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode()); CFURLConnectionStart(handle->connection()); while (!client->isDone()) CFRunLoopRunInMode(synchronousLoadRunLoopMode(), UINT_MAX, true); error = client->error(); CFURLConnectionCancel(handle->connection()); if (error.isNull()) response = client->response(); else { response = ResourceResponse(request.url(), String(), 0, String(), String()); // FIXME: ResourceHandleMac also handles authentication errors by setting code to 401. CFNet version should probably do the same. if (error.domain() == String(kCFErrorDomainCFNetwork)) response.setHTTPStatusCode(error.errorCode()); else response.setHTTPStatusCode(404); } data.swap(client->mutableData()); }
void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError) { bool errorIsNull = resourceError.isNull(); encoder << errorIsNull; if (errorIsNull) return; encoder << resourceError.domain(); encoder << resourceError.errorCode(); encoder << resourceError.failingURL().string(); encoder << resourceError.localizedDescription(); encoder << resourceError.isCancellation(); encoder << resourceError.isTimeout(); encoder << CertificateInfo(resourceError); }
void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError) { if (kShouldSerializeWebCoreData) { bool errorIsNull = resourceError.isNull(); encoder << errorIsNull; if (errorIsNull) return; encoder << resourceError.domain(); encoder << resourceError.errorCode(); encoder << resourceError.failingURL(); encoder << resourceError.localizedDescription(); encoder << resourceError.isCancellation(); encoder << resourceError.isTimeout(); } encodePlatformData(encoder, resourceError); }
void FrameLoaderClientEfl::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& err) { Ewk_Frame_Load_Error error; CString errorDomain = err.domain().utf8(); CString errorDescription = err.localizedDescription().utf8(); CString failingUrl = err.failingURL().utf8(); DBG("ewkFrame=%p, resource=%ld, error=%s (%d, cancellation=%hhu) \"%s\", url=%s", m_frame, identifier, errorDomain.data(), err.errorCode(), err.isCancellation(), errorDescription.data(), failingUrl.data()); error.code = err.errorCode(); error.is_cancellation = err.isCancellation(); error.domain = errorDomain.data(); error.description = errorDescription.data(); error.failing_url = failingUrl.data(); error.resource_identifier = identifier; error.frame = m_frame; ewk_frame_load_resource_failed(m_frame, &error); evas_object_smart_callback_call(m_view, "load,resource,failed", &error); }