70321b909a48dbe7dcabd8e7d06464aa2f669634
[WebKit-https.git] / Source / WebKit2 / Shared / APIObject.h
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 APIObject_h
27 #define APIObject_h
28
29 #include <wtf/RefCounted.h>
30
31 namespace WebKit {
32
33 class APIObject : public ThreadSafeRefCounted<APIObject> {
34 public:
35     enum Type {
36         // Base types
37         TypeNull = 0,
38         TypeArray,
39         TypeAuthenticationChallenge,
40         TypeAuthenticationDecisionListener,
41         TypeCertificateInfo,
42         TypeConnection,
43         TypeContextMenuItem,
44         TypeCredential,
45         TypeData,
46         TypeDictionary,
47         TypeError,
48         TypeGraphicsContext,
49         TypeImage,
50         TypeProtectionSpace,
51         TypeRenderLayer,
52         TypeRenderObject,
53         TypeSecurityOrigin,
54         TypeSerializedScriptValue,
55         TypeString,
56         TypeURL,
57         TypeURLRequest,
58         TypeURLResponse,
59         TypeUserContentURLPattern,
60         TypeWebArchive,
61         TypeWebArchiveResource,
62
63         // Base numeric types
64         TypeBoolean,
65         TypeDouble,
66         TypeUInt64,
67         
68         // Geometry types
69         TypePoint,
70         TypeSize,
71         TypeRect,
72         
73         // UIProcess types
74         TypeApplicationCacheManager,
75         TypeBackForwardList,
76         TypeBackForwardListItem,
77         TypeBatteryManager,
78         TypeBatteryStatus,
79         TypeCacheManager,
80         TypeColorPickerResultListener,
81         TypeContext,
82         TypeCookieManager,
83         TypeDatabaseManager,
84         TypeDownload,
85         TypeFormSubmissionListener,
86         TypeFrame,
87         TypeFramePolicyListener,
88         TypeFullScreenManager,
89         TypeGeolocationManager,
90         TypeGeolocationPermissionRequest,
91         TypeHitTestResult,
92         TypeGeolocationPosition,
93         TypeGrammarDetail,
94         TypeIconDatabase,
95         TypeInspector,
96         TypeKeyValueStorageManager,
97         TypeMediaCacheManager,
98         TypeNavigationData,
99         TypeNetworkInfo,
100         TypeNetworkInfoManager,
101         TypeNotification,
102         TypeNotificationManager,
103         TypeNotificationPermissionRequest,
104         TypeOpenPanelParameters,
105         TypeOpenPanelResultListener,
106         TypeOriginDataManager,
107         TypePage,
108         TypePageGroup,
109         TypePluginSiteDataManager,
110         TypePreferences,
111         TypeTextChecker,
112         TypeVibration,
113         TypeViewportAttributes,
114
115         // Bundle types
116         TypeBundle,
117         TypeBundleBackForwardList,
118         TypeBundleBackForwardListItem,
119         TypeBundleDOMWindowExtension,
120         TypeBundleFrame,
121         TypeBundleHitTestResult,
122         TypeBundleInspector,
123         TypeBundleNavigationAction,
124         TypeBundleNodeHandle,
125         TypeBundlePage,
126         TypeBundlePageBanner,
127         TypeBundlePageGroup,
128         TypeBundlePageOverlay,
129         TypeBundleRangeHandle,
130         TypeBundleScriptWorld,
131
132         // Platform specific
133         TypeEditCommandProxy,
134         TypeObjCObjectGraph,
135         TypeView,
136 #if USE(SOUP)
137         TypeSoupRequestManager,
138 #endif
139 #if PLATFORM(EFL)
140         TypePopupMenuItem,
141 #if ENABLE(TOUCH_EVENTS)
142         TypeTouchPoint,
143         TypeTouchEvent,
144 #endif
145 #endif
146     };
147
148     virtual ~APIObject()
149     {
150     }
151
152     virtual Type type() const = 0;
153
154 protected:
155     APIObject();
156 };
157
158 template <APIObject::Type ArgumentType>
159 class TypedAPIObject : public APIObject {
160 public:
161     static const Type APIType = ArgumentType;
162
163     virtual ~TypedAPIObject()
164     {
165     }
166
167 protected:
168     TypedAPIObject()
169     {
170     }
171
172     virtual Type type() const OVERRIDE { return APIType; }
173 };
174
175 } // namespace WebKit
176
177 #endif // APIObject_h