WKWebsiteDataStore.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2014-2017 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. #import <WebKit/WKFoundation.h>
  26. #import <WebKit/WKWebsiteDataRecord.h>
  27. NS_ASSUME_NONNULL_BEGIN
  28. @class WKHTTPCookieStore;
  29. /*! A WKWebsiteDataStore represents various types of data that a website might
  30. make use of. This includes cookies, disk and memory caches, and persistent data such as WebSQL,
  31. IndexedDB databases, and local storage.
  32. */
  33. WK_EXTERN API_AVAILABLE(macos(10.11), ios(9.0))
  34. @interface WKWebsiteDataStore : NSObject <NSSecureCoding>
  35. /* @abstract Returns the default data store. */
  36. + (WKWebsiteDataStore *)defaultDataStore;
  37. /** @abstract Returns a new non-persistent data store.
  38. @discussion If a WKWebView is associated with a non-persistent data store, no data will
  39. be written to the file system. This is useful for implementing "private browsing" in a web view.
  40. */
  41. + (WKWebsiteDataStore *)nonPersistentDataStore;
  42. - (instancetype)init NS_UNAVAILABLE;
  43. /*! @abstract Whether the data store is persistent or not. */
  44. @property (nonatomic, readonly, getter=isPersistent) BOOL persistent;
  45. /*! @abstract Returns a set of all available website data types. */
  46. + (NSSet<NSString *> *)allWebsiteDataTypes;
  47. /*! @abstract Fetches data records containing the given website data types.
  48. @param dataTypes The website data types to fetch records for.
  49. @param completionHandler A block to invoke when the data records have been fetched.
  50. */
  51. - (void)fetchDataRecordsOfTypes:(NSSet<NSString *> *)dataTypes completionHandler:(void (^)(NSArray<WKWebsiteDataRecord *> *))completionHandler;
  52. /*! @abstract Removes website data of the given types for the given data records.
  53. @param dataTypes The website data types that should be removed.
  54. @param dataRecords The website data records to delete website data for.
  55. @param completionHandler A block to invoke when the website data for the records has been removed.
  56. */
  57. - (void)removeDataOfTypes:(NSSet<NSString *> *)dataTypes forDataRecords:(NSArray<WKWebsiteDataRecord *> *)dataRecords completionHandler:(void (^)(void))completionHandler;
  58. /*! @abstract Removes all website data of the given types that has been modified since the given date.
  59. @param dataTypes The website data types that should be removed.
  60. @param date A date. All website data modified after this date will be removed.
  61. @param completionHandler A block to invoke when the website data has been removed.
  62. */
  63. - (void)removeDataOfTypes:(NSSet<NSString *> *)dataTypes modifiedSince:(NSDate *)date completionHandler:(void (^)(void))completionHandler;
  64. /*! @abstract Returns the cookie store representing HTTP cookies in this website data store. */
  65. @property (nonatomic, readonly) WKHTTPCookieStore *httpCookieStore API_AVAILABLE(macos(10.13), ios(11.0));
  66. @end
  67. NS_ASSUME_NONNULL_END