OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 5 #ifndef IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
6 #define IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 6 #define IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #import "base/ios/block_types.h" | 10 #import "base/ios/block_types.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 CHANGING, | 32 CHANGING, |
33 // Browsing data is stored in a path unique to the BrowserState and is | 33 // Browsing data is stored in a path unique to the BrowserState and is |
34 // currently not being read or written to by web views. | 34 // currently not being read or written to by web views. |
35 INACTIVE, | 35 INACTIVE, |
36 }; | 36 }; |
37 | 37 |
38 } // namespace web | 38 } // namespace web |
39 | 39 |
40 // A CRWBrowsingDataStore represents various types of data that a web view | 40 // A CRWBrowsingDataStore represents various types of data that a web view |
41 // (UIWebView and WKWebView) uses. | 41 // (UIWebView and WKWebView) uses. |
42 // All methods must be called on the UI thread. | 42 // All methods must be called on the main thread. |
43 @interface CRWBrowsingDataStore : NSObject | 43 @interface CRWBrowsingDataStore : NSObject |
44 | 44 |
45 // Designated initializer. |browserState| cannot be null. | |
46 // The initial mode of the CRWBrowsingDataStore is obtained from the active | |
47 // state of the |web::ActiveStateManager| associated with |browserState|. | |
48 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState | |
49 NS_DESIGNATED_INITIALIZER; | |
50 | |
51 // The delegate that is consulted when the mode needs to change. | 45 // The delegate that is consulted when the mode needs to change. |
52 @property(nonatomic, weak) id<CRWBrowsingDataStoreDelegate> delegate; | 46 @property(nonatomic, weak) id<CRWBrowsingDataStoreDelegate> delegate; |
53 | 47 |
54 // The mode that the CRWBrowsingDataStore is in. KVO compliant. | 48 // The mode that the CRWBrowsingDataStore is in. KVO compliant. |
55 @property(nonatomic, assign, readonly) web::BrowsingDataStoreMode mode; | 49 @property(nonatomic, assign, readonly) web::BrowsingDataStoreMode mode; |
56 | 50 |
57 // TODO(shreyasv): Verify the preconditions for the following 3 methods when | 51 // A BOOL indicating whether there is still a pending operation that has not |
58 // web::WebViewCounter class is implemented. crbug.com/480507 | 52 // finished running. Creating web views (UIWebViews and WKWebViews) with this |
| 53 // CRWBrowsingDataStore when there are pending operations results in undefined |
| 54 // behavior. |
| 55 @property(nonatomic, assign, readonly) BOOL hasPendingOperations; |
| 56 |
| 57 // Designated initializer. |browserState| cannot be nullptr. |
| 58 // The initial mode of the CRWBrowsingDataStore is obtained from the active |
| 59 // state of the |web::ActiveStateManager| associated with |browserState|. |
| 60 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState |
| 61 NS_DESIGNATED_INITIALIZER; |
| 62 - (instancetype)init NS_UNAVAILABLE; |
59 | 63 |
60 // Changes the mode to |ACTIVE|. | 64 // Changes the mode to |ACTIVE|. |
61 // if there is no delegate present, the default behavior of this method is to | 65 // If there is no delegate present, the default behavior of this method is to |
62 // restore browsing data from |browserState|'s stash path to the canonical path | 66 // restore browsing data from |browserState|'s stash path to the canonical path |
63 // where web views read/write browsing data to. | 67 // where web views read/write browsing data to. |
64 // |completionHandler| is called on the main thread. This block has no return | 68 // |completionHandler| is called on the main thread. This block has no return |
65 // value and takes a single BOOL argument that indicates whether or not the | 69 // value and takes a single BOOL argument that indicates whether or not the |
66 // the mode was successfully changed to |ACTIVE|. | 70 // the mode was successfully changed to |ACTIVE|. |
67 // The mode change to |ACTIVE| can fail if another |makeActive| or | 71 // The mode change to |ACTIVE| can fail if another |makeActive| or |
68 // |makeInactive| was enqueued after this call. | 72 // |makeInactive| was enqueued after this call. |
69 // Precondition: There must be no web views associated with the BrowserState. | 73 // Precondition: There must be no web views associated with the BrowserState. |
70 - (void)makeActiveWithCompletionHandler: | 74 - (void)makeActiveWithCompletionHandler: |
71 (void (^)(BOOL success))completionHandler; | 75 (void (^)(BOOL success))completionHandler; |
72 | 76 |
73 // Changes the mode to |INACTIVE|. | 77 // Changes the mode to |INACTIVE|. |
74 // if there is no delegate present, the default behavior of this method is to | 78 // If there is no delegate present, the default behavior of this method is to |
75 // value and takes a single BOOL argument that indicates whether or not the | 79 // stash browsing data created by the web view in to the |browserState|'s stash |
76 // stash browsing data created by the web view in to |browserState|'s stash | |
77 // path. | 80 // path. |
78 // |completionHandler| is called on the main thread. This block has no return | 81 // |completionHandler| is called on the main thread. This block has no return |
79 // value and takes a single BOOL argument that indicates whether or not the | 82 // value and takes a single BOOL argument that indicates whether or not the |
80 // the mode was successfully changed to |INACTIVE|. | 83 // the mode was successfully changed to |INACTIVE|. |
81 // The mode change to |ACTIVE| can fail if another |makeActive| or | 84 // The mode change to |INACTIVE| can fail if another |makeActive| or |
82 // |makeInactive| was enqueued after this call. | 85 // |makeInactive| was enqueued after this call. |
83 // Precondition: There must be no web views associated with the BrowserState. | 86 // Precondition: There must be no web views associated with the BrowserState. |
84 - (void)makeInactiveWithCompletionHandler: | 87 - (void)makeInactiveWithCompletionHandler: |
85 (void (^)(BOOL success))completionHandler; | 88 (void (^)(BOOL success))completionHandler; |
86 | 89 |
87 // Removes all browsing data of the provided |browsingDataTypes|. | 90 // Removes all browsing data of the provided |browsingDataTypes|. |
88 // |completionHandler| is called on the main thread after the browsing data has | 91 // |completionHandler| is called on the main thread after the browsing data has |
89 // been removed. | 92 // been removed. |
90 // Precondition: There must be no web views associated with the BrowserState. | 93 // Precondition: There must be no web views associated with the BrowserState. |
91 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes | 94 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes |
92 completionHandler:(ProceduralBlock)completionHandler; | 95 completionHandler:(ProceduralBlock)completionHandler; |
93 | 96 |
94 // Returns YES if there is still a pending operation that has not finished | |
95 // running. Creating web views (UIWebViews and WKWebViews) with this | |
96 // CRWBrowsingDataStore when there are pending operations is undefined | |
97 // behavior. | |
98 @property(nonatomic, assign, readonly) BOOL hasPendingOperations; | |
99 | |
100 @end | 97 @end |
101 | 98 |
102 #endif // IOS_WEB_CRW_BROWSING_DATA_STORE_H_ | 99 #endif // IOS_WEB_CRW_BROWSING_DATA_STORE_H_ |
OLD | NEW |