1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef APIError_h
27#define APIError_h
28
29#include "APIObject.h"
30#include <WebCore/ResourceError.h>
31
32namespace IPC {
33class Decoder;
34class Encoder;
35}
36
37namespace API {
38
39class Error : public ObjectImpl<Object::Type::Error> {
40public:
41 static Ref<Error> create()
42 {
43 return adoptRef(*new Error);
44 }
45
46 static Ref<Error> create(const WebCore::ResourceError& error)
47 {
48 return adoptRef(*new Error(error));
49 }
50
51 enum General {
52 Internal = 300
53 };
54 static const WTF::String& webKitErrorDomain();
55
56 enum Network {
57 Cancelled = 302,
58 FileDoesNotExist = 303
59 };
60 static const WTF::String& webKitNetworkErrorDomain();
61
62 enum Policy {
63 CannotShowMIMEType = 100,
64 CannotShowURL = 101,
65 FrameLoadInterruptedByPolicyChange = 102,
66 CannotUseRestrictedPort = 103,
67 FrameLoadBlockedByContentBlocker = 104,
68 FrameLoadBlockedByContentFilter = 105,
69 FrameLoadBlockedByRestrictions = 106,
70 };
71 static const WTF::String& webKitPolicyErrorDomain();
72
73 enum Plugin {
74 CannotFindPlugIn = 200,
75 CannotLoadPlugIn = 201,
76 JavaUnavailable = 202,
77 PlugInCancelledConnection = 203,
78 PlugInWillHandleLoad = 204,
79 InsecurePlugInVersion = 205
80 };
81 static const WTF::String& webKitPluginErrorDomain();
82
83#if USE(SOUP)
84 enum Download {
85 Transport = 499,
86 CancelledByUser = 400,
87 Destination = 401
88 };
89 static const WTF::String& webKitDownloadErrorDomain();
90#endif
91
92#if PLATFORM(GTK)
93 enum Print {
94 Generic = 599,
95 PrinterNotFound = 500,
96 InvalidPageRange = 501
97 };
98 static const WTF::String& webKitPrintErrorDomain();
99#endif
100
101 const WTF::String& domain() const { return m_platformError.domain(); }
102 int errorCode() const { return m_platformError.errorCode(); }
103 const WTF::String& failingURL() const { return m_platformError.failingURL(); }
104 const WTF::String& localizedDescription() const { return m_platformError.localizedDescription(); }
105
106 const WebCore::ResourceError& platformError() const { return m_platformError; }
107
108 void encode(IPC::Encoder&) const;
109 static bool decode(IPC::Decoder&, RefPtr<Object>&);
110
111private:
112 Error()
113 {
114 }
115
116 Error(const WebCore::ResourceError& error)
117 : m_platformError(error)
118 {
119 }
120
121 WebCore::ResourceError m_platformError;
122};
123
124} // namespace API
125
126#endif // APIError_h
127