1 module webkit2.WebsiteDataManager; 2 3 private import gio.AsyncResultIF; 4 private import gio.Cancellable; 5 private import glib.ConstructionException; 6 private import glib.ErrorG; 7 private import glib.GException; 8 private import glib.ListG; 9 private import glib.Str; 10 private import gobject.ObjectG; 11 private import webkit2.CookieManager; 12 private import webkit2.WebsiteData; 13 private import webkit2.c.functions; 14 public import webkit2.c.types; 15 16 17 /** 18 * WebKitWebsiteDataManager allows you to manage the data that websites 19 * can store in the client file system like databases or caches. 20 * You can use WebKitWebsiteDataManager to configure the local directories 21 * where the Website data will be stored, by creating a new manager with 22 * webkit_website_data_manager_new() passing the values you want to set. 23 * You can set all the possible configuration values or only some of them, 24 * a default value will be used automatically for the configuration options 25 * not provided. #WebKitWebsiteDataManager:base-data-directory and 26 * #WebKitWebsiteDataManager:base-cache-directory are two special properties 27 * that can be used to set a common base directory for all Website data and 28 * caches. It's possible to provide both, a base directory and a specific value, 29 * but in that case, the specific value takes precedence over the base directory. 30 * The newly created WebKitWebsiteDataManager must be passed as a construct property 31 * to a #WebKitWebContext, you can use webkit_web_context_new_with_website_data_manager() 32 * to create a new #WebKitWebContext with a WebKitWebsiteDataManager. 33 * In case you don't want to set any specific configuration, you don't need to create 34 * a WebKitWebsiteDataManager, the #WebKitWebContext will create a WebKitWebsiteDataManager 35 * with the default configuration. To get the WebKitWebsiteDataManager of a #WebKitWebContext 36 * you can use webkit_web_context_get_website_data_manager(). 37 * 38 * A WebKitWebsiteDataManager can also be ephemeral and then all the directories configuration 39 * is not needed because website data will never persist. You can create an ephemeral WebKitWebsiteDataManager 40 * with webkit_website_data_manager_new_ephemeral(). Then you can pass an ephemeral WebKitWebsiteDataManager to 41 * a #WebKitWebContext to make it ephemeral or use webkit_web_context_new_ephemeral() and the WebKitWebsiteDataManager 42 * will be automatically created by the #WebKitWebContext. 43 * 44 * WebKitWebsiteDataManager can also be used to fetch websites data, remove data 45 * stored by particular websites, or clear data for all websites modified since a given 46 * period of time. 47 * 48 * Since: 2.10 49 */ 50 public class WebsiteDataManager : ObjectG 51 { 52 /** the main Gtk struct */ 53 protected WebKitWebsiteDataManager* webKitWebsiteDataManager; 54 55 /** Get the main Gtk struct */ 56 public WebKitWebsiteDataManager* getWebsiteDataManagerStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return webKitWebsiteDataManager; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)webKitWebsiteDataManager; 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (WebKitWebsiteDataManager* webKitWebsiteDataManager, bool ownedRef = false) 73 { 74 this.webKitWebsiteDataManager = webKitWebsiteDataManager; 75 super(cast(GObject*)webKitWebsiteDataManager, ownedRef); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return webkit_website_data_manager_get_type(); 83 } 84 85 /** 86 * Creates an ephemeral #WebKitWebsiteDataManager. See #WebKitWebsiteDataManager:is-ephemeral for more details. 87 * 88 * Returns: a new ephemeral #WebKitWebsiteDataManager. 89 * 90 * Since: 2.16 91 * 92 * Throws: ConstructionException GTK+ fails to create the object. 93 */ 94 public this() 95 { 96 auto __p = webkit_website_data_manager_new_ephemeral(); 97 98 if(__p is null) 99 { 100 throw new ConstructionException("null returned by new_ephemeral"); 101 } 102 103 this(cast(WebKitWebsiteDataManager*) __p, true); 104 } 105 106 /** 107 * Asynchronously clear the website data of the given @types modified in the past @timespan. 108 * If @timespan is 0, all website data will be removed. 109 * 110 * When the operation is finished, @callback will be called. You can then call 111 * webkit_website_data_manager_clear_finish() to get the result of the operation. 112 * 113 * Due to implementation limitations, this function does not currently delete 114 * any stored cookies if @timespan is nonzero. This behavior may change in the 115 * future. 116 * 117 * Params: 118 * types = #WebKitWebsiteDataTypes 119 * timespan = a #GTimeSpan 120 * cancellable = a #GCancellable or %NULL to ignore 121 * callback = a #GAsyncReadyCallback to call when the request is satisfied 122 * userData = the data to pass to callback function 123 * 124 * Since: 2.16 125 */ 126 public void clear(WebKitWebsiteDataTypes types, GTimeSpan timespan, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 127 { 128 webkit_website_data_manager_clear(webKitWebsiteDataManager, types, timespan, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 129 } 130 131 /** 132 * Finish an asynchronous operation started with webkit_website_data_manager_clear() 133 * 134 * Params: 135 * result = a #GAsyncResult 136 * 137 * Returns: %TRUE if website data was successfully cleared, or %FALSE otherwise. 138 * 139 * Since: 2.16 140 * 141 * Throws: GException on failure. 142 */ 143 public bool clearFinish(AsyncResultIF result) 144 { 145 GError* err = null; 146 147 auto __p = webkit_website_data_manager_clear_finish(webKitWebsiteDataManager, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 148 149 if (err !is null) 150 { 151 throw new GException( new ErrorG(err) ); 152 } 153 154 return __p; 155 } 156 157 /** 158 * Asynchronously get the list of #WebKitWebsiteData for the given @types. 159 * 160 * When the operation is finished, @callback will be called. You can then call 161 * webkit_website_data_manager_fetch_finish() to get the result of the operation. 162 * 163 * Params: 164 * types = #WebKitWebsiteDataTypes 165 * cancellable = a #GCancellable or %NULL to ignore 166 * callback = a #GAsyncReadyCallback to call when the request is satisfied 167 * userData = the data to pass to callback function 168 * 169 * Since: 2.16 170 */ 171 public void fetch(WebKitWebsiteDataTypes types, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 172 { 173 webkit_website_data_manager_fetch(webKitWebsiteDataManager, types, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 174 } 175 176 /** 177 * Finish an asynchronous operation started with webkit_website_data_manager_fetch(). 178 * 179 * Params: 180 * result = a #GAsyncResult 181 * 182 * Returns: a #GList of #WebKitWebsiteData. You must free the #GList with 183 * g_list_free() and unref the #WebKitWebsiteData<!-- -->s with webkit_website_data_unref() when you're done with them. 184 * 185 * Since: 2.16 186 * 187 * Throws: GException on failure. 188 */ 189 public ListG fetchFinish(AsyncResultIF result) 190 { 191 GError* err = null; 192 193 auto __p = webkit_website_data_manager_fetch_finish(webKitWebsiteDataManager, (result is null) ? null : result.getAsyncResultStruct(), &err); 194 195 if (err !is null) 196 { 197 throw new GException( new ErrorG(err) ); 198 } 199 200 if(__p is null) 201 { 202 return null; 203 } 204 205 return new ListG(cast(GList*) __p, true); 206 } 207 208 /** 209 * Get the #WebKitWebsiteDataManager:base-cache-directory property. 210 * 211 * Returns: the base directory for Website cache, or %NULL if 212 * #WebKitWebsiteDataManager:base-cache-directory was not provided or @manager is ephemeral. 213 * 214 * Since: 2.10 215 */ 216 public string getBaseCacheDirectory() 217 { 218 return Str.toString(webkit_website_data_manager_get_base_cache_directory(webKitWebsiteDataManager)); 219 } 220 221 /** 222 * Get the #WebKitWebsiteDataManager:base-data-directory property. 223 * 224 * Returns: the base directory for Website data, or %NULL if 225 * #WebKitWebsiteDataManager:base-data-directory was not provided or @manager is ephemeral. 226 * 227 * Since: 2.10 228 */ 229 public string getBaseDataDirectory() 230 { 231 return Str.toString(webkit_website_data_manager_get_base_data_directory(webKitWebsiteDataManager)); 232 } 233 234 /** 235 * Get the #WebKitCookieManager of @manager. 236 * 237 * Returns: a #WebKitCookieManager 238 * 239 * Since: 2.16 240 */ 241 public CookieManager getCookieManager() 242 { 243 auto __p = webkit_website_data_manager_get_cookie_manager(webKitWebsiteDataManager); 244 245 if(__p is null) 246 { 247 return null; 248 } 249 250 return ObjectG.getDObject!(CookieManager)(cast(WebKitCookieManager*) __p); 251 } 252 253 /** 254 * Get the #WebKitWebsiteDataManager:disk-cache-directory property. 255 * 256 * Returns: the directory where HTTP disk cache is stored or %NULL if @manager is ephemeral. 257 * 258 * Since: 2.10 259 */ 260 public string getDiskCacheDirectory() 261 { 262 return Str.toString(webkit_website_data_manager_get_disk_cache_directory(webKitWebsiteDataManager)); 263 } 264 265 /** 266 * Get the #WebKitWebsiteDataManager:dom-cache-directory property. 267 * 268 * Returns: the directory where DOM cache is stored or %NULL if @manager is ephemeral. 269 * 270 * Since: 2.30 271 */ 272 public string getDomCacheDirectory() 273 { 274 return Str.toString(webkit_website_data_manager_get_dom_cache_directory(webKitWebsiteDataManager)); 275 } 276 277 /** 278 * Get the #WebKitWebsiteDataManager:hsts-cache-directory property. 279 * 280 * Returns: the directory where the HSTS cache is stored or %NULL if @manager is ephemeral. 281 * 282 * Since: 2.26 283 */ 284 public string getHstsCacheDirectory() 285 { 286 return Str.toString(webkit_website_data_manager_get_hsts_cache_directory(webKitWebsiteDataManager)); 287 } 288 289 /** 290 * Get the #WebKitWebsiteDataManager:indexeddb-directory property. 291 * 292 * Returns: the directory where IndexedDB databases are stored or %NULL if @manager is ephemeral. 293 * 294 * Since: 2.10 295 */ 296 public string getIndexeddbDirectory() 297 { 298 return Str.toString(webkit_website_data_manager_get_indexeddb_directory(webKitWebsiteDataManager)); 299 } 300 301 /** 302 * Get the #WebKitWebsiteDataManager:itp-directory property. 303 * 304 * Returns: the directory where Intelligent Tracking Prevention data is stored or %NULL if @manager is ephemeral. 305 * 306 * Since: 2.30 307 */ 308 public string getItpDirectory() 309 { 310 return Str.toString(webkit_website_data_manager_get_itp_directory(webKitWebsiteDataManager)); 311 } 312 313 /** 314 * Get whether Intelligent Tracking Prevention (ITP) is enabled or not. 315 * 316 * Returns: %TRUE if ITP is enabled, or %FALSE otherwise. 317 * 318 * Since: 2.30 319 */ 320 public bool getItpEnabled() 321 { 322 return webkit_website_data_manager_get_itp_enabled(webKitWebsiteDataManager) != 0; 323 } 324 325 /** 326 * Asynchronously get the list of #WebKitITPThirdParty seen for @manager. Every #WebKitITPThirdParty 327 * contains the list of #WebKitITPFirstParty under which it has been seen. 328 * 329 * When the operation is finished, @callback will be called. You can then call 330 * webkit_website_data_manager_get_itp_summary_finish() to get the result of the operation. 331 * 332 * Params: 333 * cancellable = a #GCancellable or %NULL to ignore 334 * callback = a #GAsyncReadyCallback to call when the request is satisfied 335 * userData = the data to pass to callback function 336 * 337 * Since: 2.30 338 */ 339 public void getItpSummary(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 340 { 341 webkit_website_data_manager_get_itp_summary(webKitWebsiteDataManager, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 342 } 343 344 /** 345 * Finish an asynchronous operation started with webkit_website_data_manager_get_itp_summary(). 346 * 347 * Params: 348 * result = a #GAsyncResult 349 * 350 * Returns: a #GList of #WebKitITPThirdParty. 351 * You must free the #GList with g_list_free() and unref the #WebKitITPThirdParty<!-- -->s with 352 * webkit_itp_third_party_unref() when you're done with them. 353 * 354 * Since: 2.30 355 * 356 * Throws: GException on failure. 357 */ 358 public ListG getItpSummaryFinish(AsyncResultIF result) 359 { 360 GError* err = null; 361 362 auto __p = webkit_website_data_manager_get_itp_summary_finish(webKitWebsiteDataManager, (result is null) ? null : result.getAsyncResultStruct(), &err); 363 364 if (err !is null) 365 { 366 throw new GException( new ErrorG(err) ); 367 } 368 369 if(__p is null) 370 { 371 return null; 372 } 373 374 return new ListG(cast(GList*) __p, true); 375 } 376 377 /** 378 * Get the #WebKitWebsiteDataManager:local-storage-directory property. 379 * 380 * Returns: the directory where local storage data is stored or %NULL if @manager is ephemeral. 381 * 382 * Since: 2.10 383 */ 384 public string getLocalStorageDirectory() 385 { 386 return Str.toString(webkit_website_data_manager_get_local_storage_directory(webKitWebsiteDataManager)); 387 } 388 389 /** 390 * Get the #WebKitWebsiteDataManager:offline-application-cache-directory property. 391 * 392 * Returns: the directory where offline web application cache is stored or %NULL if @manager is ephemeral. 393 * 394 * Since: 2.10 395 */ 396 public string getOfflineApplicationCacheDirectory() 397 { 398 return Str.toString(webkit_website_data_manager_get_offline_application_cache_directory(webKitWebsiteDataManager)); 399 } 400 401 /** 402 * Get whether persistent credential storage is enabled or not. 403 * See also webkit_website_data_manager_set_persistent_credential_storage_enabled(). 404 * 405 * Returns: %TRUE if persistent credential storage is enabled, or %FALSE otherwise. 406 * 407 * Since: 2.30 408 */ 409 public bool getPersistentCredentialStorageEnabled() 410 { 411 return webkit_website_data_manager_get_persistent_credential_storage_enabled(webKitWebsiteDataManager) != 0; 412 } 413 414 /** 415 * Get the #WebKitWebsiteDataManager:service-worker-registrations-directory property. 416 * 417 * Returns: the directory where service worker registrations are stored or %NULL if @manager is ephemeral. 418 * 419 * Since: 2.30 420 */ 421 public string getServiceWorkerRegistrationsDirectory() 422 { 423 return Str.toString(webkit_website_data_manager_get_service_worker_registrations_directory(webKitWebsiteDataManager)); 424 } 425 426 /** 427 * Get the #WebKitWebsiteDataManager:websql-directory property. 428 * 429 * Deprecated: WebSQL is no longer supported. Use IndexedDB instead. 430 * 431 * Returns: the directory where WebSQL databases are stored or %NULL if @manager is ephemeral. 432 * 433 * Since: 2.10 434 */ 435 public string getWebsqlDirectory() 436 { 437 return Str.toString(webkit_website_data_manager_get_websql_directory(webKitWebsiteDataManager)); 438 } 439 440 /** 441 * Get whether a #WebKitWebsiteDataManager is ephemeral. See #WebKitWebsiteDataManager:is-ephemeral for more details. 442 * 443 * Returns: %TRUE if @manager is ephemeral or %FALSE otherwise. 444 * 445 * Since: 2.16 446 */ 447 public bool isEphemeral() 448 { 449 return webkit_website_data_manager_is_ephemeral(webKitWebsiteDataManager) != 0; 450 } 451 452 /** 453 * Asynchronously removes the website data of the for the given @types for websites in the given @website_data list. 454 * Use webkit_website_data_manager_clear() if you want to remove the website data for all sites. 455 * 456 * When the operation is finished, @callback will be called. You can then call 457 * webkit_website_data_manager_remove_finish() to get the result of the operation. 458 * 459 * Params: 460 * types = #WebKitWebsiteDataTypes 461 * websiteData = a #GList of #WebKitWebsiteData 462 * cancellable = a #GCancellable or %NULL to ignore 463 * callback = a #GAsyncReadyCallback to call when the request is satisfied 464 * userData = the data to pass to callback function 465 * 466 * Since: 2.16 467 */ 468 public void remove(WebKitWebsiteDataTypes types, ListG websiteData, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 469 { 470 webkit_website_data_manager_remove(webKitWebsiteDataManager, types, (websiteData is null) ? null : websiteData.getListGStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 471 } 472 473 /** 474 * Finish an asynchronous operation started with webkit_website_data_manager_remove(). 475 * 476 * Params: 477 * result = a #GAsyncResult 478 * 479 * Returns: %TRUE if website data resources were successfully removed, or %FALSE otherwise. 480 * 481 * Since: 2.16 482 * 483 * Throws: GException on failure. 484 */ 485 public bool removeFinish(AsyncResultIF result) 486 { 487 GError* err = null; 488 489 auto __p = webkit_website_data_manager_remove_finish(webKitWebsiteDataManager, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 490 491 if (err !is null) 492 { 493 throw new GException( new ErrorG(err) ); 494 } 495 496 return __p; 497 } 498 499 /** 500 * Enable or disable Intelligent Tracking Prevention (ITP). When ITP is enabled resource load statistics 501 * are collected and used to decide whether to allow or block third-party cookies and prevent user tracking. 502 * Note that while ITP is enabled the accept policy %WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY is ignored and 503 * %WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS is used instead. See also webkit_cookie_manager_set_accept_policy(). 504 * 505 * Params: 506 * enabled = value to set 507 * 508 * Since: 2.30 509 */ 510 public void setItpEnabled(bool enabled) 511 { 512 webkit_website_data_manager_set_itp_enabled(webKitWebsiteDataManager, enabled); 513 } 514 515 /** 516 * Enable or disable persistent credential storage. When enabled, which is the default for 517 * non-ephemeral sessions, the network process will try to read and write HTTP authentiacation 518 * credentials from persistent storage. 519 * 520 * Params: 521 * enabled = value to set 522 * 523 * Since: 2.30 524 */ 525 public void setPersistentCredentialStorageEnabled(bool enabled) 526 { 527 webkit_website_data_manager_set_persistent_credential_storage_enabled(webKitWebsiteDataManager, enabled); 528 } 529 }