1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_CRW_BROWSING_DATA_STORE_H_
6 #define IOS_WEB_CRW_BROWSING_DATA_STORE_H_
8 #import <Foundation/Foundation.h>
10 #import "base/ios/block_types.h"
15 // Represents the cookie browsing data that a web view stores.
16 extern NSString
* const kBrowsingDataTypeCookies
;
19 // Represents the modes that a CRWBrowsingDataStore is currently at.
20 enum CRWBrowsingDataStoreMode
{
21 // Web views (associated transitively through the BrowseState) are
22 // flushing/reading their data from disk.
24 // The CRWBrowsingDataStore's mode is in the process of becoming either ACTIVE
27 // Browsing data is stored in a path unique to the BrowserState and is
28 // currently not being read or written to by web views.
32 // A CRWBrowsingDataStore represents various types of data that a web view
33 // (UIWebView and WKWebView) uses.
34 // All methods must be called on the UI thread.
35 @interface CRWBrowsingDataStore
: NSObject
37 // Designated initializer. |browserState| cannot be a nullptr.
38 // The |web::ActiveStateManager| associated with |browserState| needs to be in
40 - (instancetype
)initWithBrowserState
:(web::BrowserState
*)browserState
41 NS_DESIGNATED_INITIALIZER
;
43 // Returns a set of all available browsing data types.
44 + (NSSet
*)allBrowsingDataTypes
;
46 // The mode that the CRWBrowsingDataStore is in.
47 @
property(nonatomic
, assign
, readonly
) CRWBrowsingDataStoreMode mode
;
49 // TODO(shreyasv): Verify the preconditions for the following 3 methods when
50 // web::WebViewCounter class is implemented. crbug.com/480507
52 // Changes the mode to |ACTIVE|.
53 // |completionHandler| is called on the main thread.
54 // Precondition: There must be no web views associated with the BrowserState.
55 // Note: If there is another operation driven to change the mode, the mode will
56 // still be |SYNCHRONIZING| rather than |ACTIVE| when the callback is received.
57 - (void)makeActiveWithCompletionHandler
:(ProceduralBlock
)completionHandler
;
59 // Changes the mode to |INACTIVE|.
60 // |completionHandler| is called on the main thread.
61 // Precondition: There must be no web views associated with the BrowserState.
62 // Note: If there is another operation driven to change the mode, the mode will
63 // still be |SYNCHRONIZING| rather than |INACTIVE| when the callback is
65 - (void)makeInactiveWithCompletionHandler
:(ProceduralBlock
)completionHandler
;
67 // Removes all browsing data of the provided |browsingDataTypes|.
68 // |completionHandler| is called on the main thread after the browsing data has
70 // Precondition: There must be no web views associated with the BrowserState.
71 - (void)removeDataOfTypes
:(NSSet
*)browsingDataTypes
72 completionHandler
:(ProceduralBlock
)completionHandler
;
74 // Returns YES if there is still a pending operation that has not finished
75 // running. Creating web views (UIWebViews and WKWebViews) with this
76 // CRWBrowsingDataStore when there are pending operations is undefined
78 @
property(nonatomic
, assign
, readonly
) BOOL hasPendingOperations
;
82 #endif // IOS_WEB_CRW_BROWSING_DATA_STORE_H_