1 /* 2 * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Jan Michael C. Alonzo 4 * Copyright (C) 2008 Collabora Ltd. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef webkitprivate_h 23 #define webkitprivate_h 24 25 /* 26 * This file knows the shared secret of WebKitWebView, WebKitWebFrame, 27 * and WebKitNetworkRequest. 28 * They are using WebCore which musn't be exposed to the outer world. 29 */ 30 31 #include <webkit/webkitdefines.h> 32 #include <webkit/webkitdownload.h> 33 #include <webkit/webkithittestresult.h> 34 #include <webkit/webkitnetworkrequest.h> 35 #include <webkit/webkitwebview.h> 36 #include <webkit/webkitwebdatasource.h> 37 #include <webkit/webkitwebframe.h> 38 #include <webkit/webkitwebpolicydecision.h> 39 #include <webkit/webkitwebnavigationaction.h> 40 #include <webkit/webkitwebresource.h> 41 #include <webkit/webkitwebsettings.h> 42 #include <webkit/webkitwebwindowfeatures.h> 43 #include <webkit/webkitwebbackforwardlist.h> 44 #include <webkit/webkitnetworkrequest.h> 45 #include <webkit/webkitsecurityorigin.h> 46 47 #include "ArchiveResource.h" 48 #include "BackForwardList.h" 49 #include "CString.h" 50 #include <enchant.h> 51 #include "GOwnPtr.h" 52 #include "HistoryItem.h" 53 #include "Settings.h" 54 #include "Page.h" 55 #include "Frame.h" 56 #include "InspectorClientGtk.h" 57 #include "FrameLoaderClient.h" 58 #include "ResourceHandle.h" 59 #include "ResourceRequest.h" 60 #include "ResourceResponse.h" 61 #include "WindowFeatures.h" 62 #include "SecurityOrigin.h" 63 64 #include <atk/atk.h> 65 #include <glib.h> 66 #include <libsoup/soup.h> 67 68 class DownloadClient; 69 70 namespace WebKit { 71 72 class DocumentLoader; 73 class PasteboardHelperGtk; 74 75 WebKitWebView* getViewFromFrame(WebKitWebFrame*); 76 77 WebCore::Frame* core(WebKitWebFrame*); 78 WebKitWebFrame* kit(WebCore::Frame*); 79 80 WebCore::Page* core(WebKitWebView*); 81 WebKitWebView* kit(WebCore::Page*); 82 83 WebCore::HistoryItem* core(WebKitWebHistoryItem*); 84 WebKitWebHistoryItem* kit(PassRefPtr<WebCore::HistoryItem>); 85 86 WebCore::BackForwardList* core(WebKitWebBackForwardList*); 87 88 WebKitWebNavigationReason kit(WebCore::NavigationType type); 89 WebCore::NavigationType core(WebKitWebNavigationReason reason); 90 91 WebCore::ResourceRequest core(WebKitNetworkRequest* request); 92 93 WebCore::ResourceResponse core(WebKitNetworkResponse* response); 94 95 WebCore::EditingBehavior core(WebKitEditingBehavior type); 96 97 WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*); 98 WebCore::SecurityOrigin* core(WebKitSecurityOrigin*); 99 100 WebKitHitTestResult* kit(const WebCore::HitTestResult&); 101 102 WebKit::PasteboardHelperGtk* pasteboardHelperInstance(); 103 } 104 105 typedef struct { 106 EnchantBroker* config; 107 EnchantDict* speller; 108 } SpellLanguage; 109 110 extern "C" { 111 void webkit_init(); 112 113 #define WEBKIT_PARAM_READABLE ((GParamFlags)(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) 114 #define WEBKIT_PARAM_READWRITE ((GParamFlags)(G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) 115 116 #define WEBKIT_WEB_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate)) 117 typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; 118 struct _WebKitWebViewPrivate { 119 WebCore::Page* corePage; 120 WebKitWebSettings* webSettings; 121 WebKitWebInspector* webInspector; 122 WebKitWebWindowFeatures* webWindowFeatures; 123 124 WebKitWebFrame* mainFrame; 125 WebKitWebBackForwardList* backForwardList; 126 127 GtkMenu* currentMenu; 128 gint lastPopupXPosition; 129 gint lastPopupYPosition; 130 131 HashSet<GtkWidget*> children; 132 bool editable; 133 GtkIMContext* imContext; 134 135 gboolean transparent; 136 137 GtkAdjustment* horizontalAdjustment; 138 GtkAdjustment* verticalAdjustment; 139 140 gboolean zoomFullContent; 141 WebKitLoadStatus loadStatus; 142 char* encoding; 143 char* customEncoding; 144 145 char* iconURI; 146 147 gboolean disposing; 148 gboolean usePrimaryForPaste; 149 150 // These are hosted here because the DataSource object is 151 // created too late in the frame loading process. 152 WebKitWebResource* mainResource; 153 char* mainResourceIdentifier; 154 GHashTable* subResources; 155 char* tooltipText; 156 }; 157 158 #define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate)) 159 typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; 160 struct _WebKitWebFramePrivate { 161 WebCore::Frame* coreFrame; 162 WebKitWebView* webView; 163 164 gchar* name; 165 gchar* title; 166 gchar* uri; 167 WebKitLoadStatus loadStatus; 168 WebKitSecurityOrigin* origin; 169 }; 170 171 #define WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginPrivate)) 172 struct _WebKitSecurityOriginPrivate { 173 RefPtr<WebCore::SecurityOrigin> coreOrigin; 174 gchar* protocol; 175 gchar* host; 176 GHashTable* webDatabases; 177 178 gboolean disposed; 179 }; 180 181 PassRefPtr<WebCore::Frame> 182 webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*); 183 184 void 185 webkit_web_frame_core_frame_gone(WebKitWebFrame*); 186 187 // WebKitWebHistoryItem private 188 WebKitWebHistoryItem* 189 webkit_web_history_item_new_with_core_item(PassRefPtr<WebCore::HistoryItem> historyItem); 190 191 WEBKIT_API G_CONST_RETURN gchar* 192 webkit_web_history_item_get_target(WebKitWebHistoryItem*); 193 194 WEBKIT_API gboolean 195 webkit_web_history_item_is_target_item(WebKitWebHistoryItem*); 196 197 WEBKIT_API GList* 198 webkit_web_history_item_get_children(WebKitWebHistoryItem*); 199 // end WebKitWebHistoryItem private 200 201 // WebKitWebResource private 202 #define WEBKIT_WEB_RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourcePrivate)) 203 struct _WebKitWebResourcePrivate { 204 WebCore::ArchiveResource* resource; 205 206 gchar* uri; 207 gchar* mimeType; 208 gchar* textEncoding; 209 gchar* frameName; 210 211 GString* data; 212 }; 213 WebKitWebResource* 214 webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>); 215 216 void 217 webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>); 218 219 // end WebKitWebResource private 220 221 void 222 webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebCore::Page*); 223 224 void 225 webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view); 226 227 void 228 webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri); 229 230 WEBKIT_API void 231 webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script); 232 233 234 WebKitWebWindowFeatures* 235 webkit_web_window_features_new_from_core_features (const WebCore::WindowFeatures& features); 236 237 void 238 webkit_web_view_notify_ready (WebKitWebView* web_view); 239 240 void 241 webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse(), WebCore::ResourceHandle* handle = 0); 242 243 void 244 webkit_web_view_add_resource(WebKitWebView*, char*, WebKitWebResource*); 245 246 WebKitWebResource* 247 webkit_web_view_get_resource(WebKitWebView*, char*); 248 249 WebKitWebResource* 250 webkit_web_view_get_main_resource(WebKitWebView*); 251 252 void 253 webkit_web_view_clear_resources(WebKitWebView*); 254 255 GList* 256 webkit_web_view_get_subresources(WebKitWebView*); 257 258 void 259 webkit_web_view_set_tooltip_text(WebKitWebView*, const char*); 260 261 WebKitDownload* 262 webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response); 263 264 void 265 webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename); 266 267 WebKitWebPolicyDecision* 268 webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction); 269 270 void 271 webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision); 272 273 WebKitNetworkRequest* 274 webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest); 275 276 WebKitNetworkResponse* 277 webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse); 278 279 // FIXME: move this to webkitnetworkrequest.h once the API is agreed upon. 280 WEBKIT_API SoupMessage* 281 webkit_network_request_get_message(WebKitNetworkRequest* request); 282 283 // FIXME: move this functionality into a 'WebKitWebDataSource' once implemented 284 WEBKIT_API gchar* 285 webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame); 286 287 // FIXME: Move these to webkitwebframe.h once their API has been discussed. 288 289 WEBKIT_API GSList* 290 webkit_web_frame_get_children (WebKitWebFrame* frame); 291 292 WEBKIT_API gchar* 293 webkit_web_frame_get_inner_text (WebKitWebFrame* frame); 294 295 WEBKIT_API gchar* 296 webkit_web_frame_dump_render_tree (WebKitWebFrame* frame); 297 298 WEBKIT_API gchar* 299 webkit_web_frame_counter_value_for_element_by_id (WebKitWebFrame* frame, const gchar* id); 300 301 WEBKIT_API int 302 webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight); 303 304 WEBKIT_API guint 305 webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame); 306 307 WEBKIT_API bool 308 webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); 309 310 WEBKIT_API bool 311 webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); 312 313 WEBKIT_API bool 314 webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId); 315 316 WEBKIT_API unsigned int 317 webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); 318 319 WEBKIT_API void 320 webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame); 321 322 WEBKIT_API AtkObject* 323 webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame); 324 325 WEBKIT_API gchar* 326 webkit_web_view_get_selected_text (WebKitWebView* web_view); 327 328 WEBKIT_API void 329 webkit_web_view_set_group_name(WebKitWebView* web_view, const gchar* group_name); 330 331 WEBKIT_API void 332 webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory); 333 334 GSList* 335 webkit_web_settings_get_spell_languages(WebKitWebView* web_view); 336 337 bool 338 webkit_web_view_use_primary_for_paste(WebKitWebView* web_view); 339 340 GHashTable* 341 webkit_history_items(void); 342 343 WEBKIT_API void 344 webkit_gc_collect_javascript_objects(); 345 346 WEBKIT_API void 347 webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone); 348 349 WEBKIT_API gsize 350 webkit_gc_count_javascript_objects(); 351 352 WEBKIT_API void 353 webkit_application_cache_set_maximum_size(unsigned long long size); 354 355 WEBKIT_API unsigned int 356 webkit_worker_thread_count(); 357 358 WEBKIT_API void 359 webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains); 360 361 WEBKIT_API void 362 webkit_reset_origin_access_white_lists(); 363 364 // WebKitWebDataSource private 365 WebKitWebDataSource* 366 webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader>); 367 368 WEBKIT_API WebKitWebDatabase * 369 webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const char* databaseName); 370 371 WEBKIT_API void 372 webkit_web_frame_layout(WebKitWebFrame* frame); 373 } 374 375 namespace WTF { 376 template <> void freeOwnedGPtr<SoupMessage>(SoupMessage*); 377 template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest*); 378 template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse*); 379 template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource*); 380 } 381 382 #endif 383