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 | |
32 | namespace IPC { |
33 | class Decoder; |
34 | class Encoder; |
35 | } |
36 | |
37 | namespace API { |
38 | |
39 | class Error : public ObjectImpl<Object::Type::Error> { |
40 | public: |
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 | }; |
70 | static const WTF::String& webKitPolicyErrorDomain(); |
71 | |
72 | enum Plugin { |
73 | CannotFindPlugIn = 200, |
74 | CannotLoadPlugIn = 201, |
75 | JavaUnavailable = 202, |
76 | PlugInCancelledConnection = 203, |
77 | PlugInWillHandleLoad = 204, |
78 | InsecurePlugInVersion = 205 |
79 | }; |
80 | static const WTF::String& webKitPluginErrorDomain(); |
81 | |
82 | #if USE(SOUP) |
83 | enum Download { |
84 | Transport = 499, |
85 | CancelledByUser = 400, |
86 | Destination = 401 |
87 | }; |
88 | static const WTF::String& webKitDownloadErrorDomain(); |
89 | #endif |
90 | |
91 | #if PLATFORM(GTK) |
92 | enum Print { |
93 | Generic = 599, |
94 | PrinterNotFound = 500, |
95 | = 501 |
96 | }; |
97 | static const WTF::String& webKitPrintErrorDomain(); |
98 | #endif |
99 | |
100 | const WTF::String& domain() const { return m_platformError.domain(); } |
101 | int errorCode() const { return m_platformError.errorCode(); } |
102 | const WTF::String& failingURL() const { return m_platformError.failingURL(); } |
103 | const WTF::String& localizedDescription() const { return m_platformError.localizedDescription(); } |
104 | |
105 | const WebCore::ResourceError& platformError() const { return m_platformError; } |
106 | |
107 | void encode(IPC::Encoder&) const; |
108 | static bool decode(IPC::Decoder&, RefPtr<Object>&); |
109 | |
110 | private: |
111 | Error() |
112 | { |
113 | } |
114 | |
115 | Error(const WebCore::ResourceError& error) |
116 | : m_platformError(error) |
117 | { |
118 | } |
119 | |
120 | WebCore::ResourceError m_platformError; |
121 | }; |
122 | |
123 | } // namespace API |
124 | |
125 | #endif // APIError_h |
126 | |