1/* 2 * Copyright (C) 2011 Igalia S.L. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#include "config.h" 21#include "ErrorsGtk.h" 22 23#include "DocumentLoader.h" 24#include "Frame.h" 25#include "FrameLoader.h" 26#include "PrintContext.h" 27#include "ResourceError.h" 28#include "ResourceRequest.h" 29#include "ResourceResponse.h" 30#include <glib/gi18n-lib.h> 31 32namespace WebCore { 33 34ResourceError cancelledError(const ResourceRequest& request) 35{ 36 return ResourceError(errorDomainNetwork, NetworkErrorCancelled, 37 request.url().string(), _("Load request cancelled")); 38} 39 40ResourceError blockedError(const ResourceRequest& request) 41{ 42 return ResourceError(errorDomainPolicy, PolicyErrorCannotUseRestrictedPort, 43 request.url().string(), _("Not allowed to use restricted network port")); 44} 45 46ResourceError cannotShowURLError(const ResourceRequest& request) 47{ 48 return ResourceError(errorDomainPolicy, PolicyErrorCannotShowURL, 49 request.url().string(), _("URL cannot be shown")); 50} 51 52ResourceError interruptedForPolicyChangeError(const ResourceRequest& request) 53{ 54 return ResourceError(errorDomainPolicy, PolicyErrorFrameLoadInterruptedByPolicyChange, 55 request.url().string(), _("Frame load was interrupted")); 56} 57 58ResourceError cannotShowMIMETypeError(const ResourceResponse& response) 59{ 60 return ResourceError(errorDomainPolicy, PolicyErrorCannotShowMimeType, 61 response.url().string(), _("Content with the specified MIME type cannot be shown")); 62} 63 64ResourceError fileDoesNotExistError(const ResourceResponse& response) 65{ 66 return ResourceError(errorDomainNetwork, NetworkErrorFileDoesNotExist, 67 response.url().string(), _("File does not exist")); 68} 69 70ResourceError pluginWillHandleLoadError(const ResourceResponse& response) 71{ 72 return ResourceError(errorDomainPlugin, PluginErrorWillHandleLoad, 73 response.url().string(), _("Plugin will handle load")); 74} 75 76ResourceError downloadNetworkError(const ResourceError& networkError) 77{ 78 return ResourceError(errorDomainDownload, DownloadErrorNetwork, 79 networkError.failingURL(), networkError.localizedDescription()); 80} 81 82ResourceError downloadCancelledByUserError(const ResourceResponse& response) 83{ 84 return ResourceError(errorDomainDownload, DownloadErrorCancelledByUser, 85 response.url().string(), _("User cancelled the download")); 86} 87 88ResourceError downloadDestinationError(const ResourceResponse& response, const String& errorMessage) 89{ 90 return ResourceError(errorDomainDownload, DownloadErrorDestination, 91 response.url().string(), errorMessage); 92} 93 94ResourceError printError(const PrintContext* printContext, const String& errorMessage) 95{ 96 DocumentLoader* documentLoader = printContext->frame()->loader()->documentLoader(); 97 return ResourceError(errorDomainPrint, PrintErrorGeneral, 98 documentLoader ? documentLoader->url() : KURL(), errorMessage); 99} 100 101ResourceError printerNotFoundError(const PrintContext* printContext) 102{ 103 DocumentLoader* documentLoader = printContext->frame()->loader()->documentLoader(); 104 return ResourceError(errorDomainPrint, PrintErrorPrinterNotFound, 105 documentLoader ? documentLoader->url() : KURL(), _("Printer not found")); 106} 107 108ResourceError invalidPageRangeToPrint(const PrintContext* printContext) 109{ 110 DocumentLoader* documentLoader = printContext->frame()->loader()->documentLoader(); 111 return ResourceError(errorDomainPrint, PrintErrorInvalidPageRange, 112 documentLoader ? documentLoader->url() : KURL(), _("Invalid page range")); 113} 114 115} // namespace WebCore 116