@@ -20,9 +20,9 @@ HRESULT ClearBrowsingDataInTimeRange(
2020 [in] double endTime,
2121 [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
2222```
23- The first method takes ` COREWEBVIEW2_BROWSING_DATA_KINDS ` which corresponds to the data type(s) to clear as well as a handler which will indicate if the proper data has been cleared successfully. This method clears the data for all time .
23+ The first method takes ` COREWEBVIEW2_BROWSING_DATA_KINDS ` which corresponds to the data type(s) to clear as well as a handler which will indicate if the proper data has been cleared successfully. This method clears the data regardless of timestamp .
2424
25- The second method takes the same parameters for the dataKinds and handler, as well as a start and end time in which the API should clear the corresponding data between. The time parameters correspond to how many seconds have passed since the UNIX epoch.
25+ The second method takes the same parameters for the dataKinds and handler, as well as a start and end time in which the API should clear the corresponding data between. The time parameters correspond to how many seconds have passed since the UNIX epoch. Passing in a value of zero or less than zero (up to negative infinity) will clear the corresponding data for any time before X time. Passing in a value of the current time or greater (up to positive infinity) will clear the corresponding data for any time after X time. For example passing in negative infinity and positive infinity as the time parameters will clear the entirety of the corresponding data. The timestamp represents the time at which the data was created.
2626
2727Both methods clear the data for the associated profile in which the method is called on.
2828
@@ -49,16 +49,12 @@ void ClearAutofillData()
4949 /// This will clear the data for the last hour.
5050 COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds = (COREWEBVIEW2_BROWSING_DATA_KINDS)
5151 (COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL |
52- COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE)) ;
52+ COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE);
5353 CHECK_FAILURE(profile->ClearBrowsingDataInTimeRange(
5454 dataKinds, startTime, endTime,
5555 Callback<ICoreWebView2StagingClearBrowsingDataCompletedHandler >(
5656 [ this] (HRESULT error)
5757 -> HRESULT {
58- LPCWSTR result = error == S_OK ? L"Succeeded" : L"Failed";
59- RunAsync([ this, result] ( ) {
60- MessageBox(nullptr, result, L"Clear Browsing Data", MB_OK);
61- });
6258 return S_OK;
6359 })
6460 .Get()));
@@ -75,10 +71,10 @@ private void ClearAutofillData()
7571 if (webView .CoreWebView2 != null )
7672 {
7773 profile = webView .CoreWebView2 .Profile ;
78- double endTime = DateTimeOffset . Now . ToUnixTimeSeconds ();
79- // Get the current time which is the time in which the browsing data will be cleared until.
80- double startTime = endTime - 3600 ;
81- // Offset the current time by 3600 seconds to clear the browsing data from the last hour.
74+ // Get the current time, the time in which the browsing data will be cleared until.
75+ System . DateTime endTime = DateTime . Now ;
76+ System . DateTime startTime = DateTime . Now . AddHours ( - 1 );
77+ // Offset the current time by one hour to clear the browsing data from the last hour.
8278 CoreWebView2BrowsingDataKinds dataKinds = (CoreWebView2BrowsingDataKinds )(CoreWebView2BrowsingDataKinds .GeneralAutofill | CoreWebView2BrowsingDataKinds .PasswordAutosave );
8379 await profile .ClearBrowsingDataAsync (dataKinds , startTime , endTime );
8480 }
@@ -99,7 +95,7 @@ interface ICoreWebView2ClearBrowsingDataCompletedHandler;
9995
10096/// Specifies the datatype for the
10197/// `ICoreWebView2Profile::ClearBrowsingData` method.
102- [v1_enum]
98+ [v1_enum]
10399typedef enum COREWEBVIEW2_BROWSING_DATA_KINDS {
104100 /// Specifies data stored by the AppCache DOM feature.
105101 COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE = 1 << 0,
@@ -116,71 +112,62 @@ typedef enum COREWEBVIEW2_BROWSING_DATA_KINDS {
116112 /// Specifies data stored by the Web SQL database DOM API.
117113 COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 1 << 4,
118114
119- /// Specifies cache storage which stores the network requests
120- /// and responses.
115+ /// Specifies data stored by the CacheStorge DOM API.
121116 COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 1 << 5,
122117
123- /// Specifies DOM storage data. This browsing data kind is inclusive
124- /// of COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE,
118+ /// Specifies DOM storage data, now and future . This browsing data kind is
119+ /// inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE,
125120 /// COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS,
126121 /// COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB,
127122 /// COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE,
128123 /// COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL,
129124 /// COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE.
130- COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE =
131- COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE|
132- COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS |
133- COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB |
134- COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE |
135- COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL |
136- COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE,
125+ /// New DOM storage data types may be added to this data kind in the future.
126+ COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE = 1 << 6,
137127
138128 /// Specifies HTTP cookies data.
139- COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 1 << 6 ,
129+ COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 1 << 7 ,
140130
141- /// Specifies site data. This browsing data kind
142- /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE and
143- /// COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES.
144- COREWEBVIEW2_BROWSING_DATA_KINDS_SITE = COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE |
145- COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES,
131+ /// Specifies all site data, now and future . This browsing data kind
132+ /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE and
133+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES. New site data types
134+ /// may be added to this data kind in the future.
135+ COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE = 1 << 8,
146136
147- /// Specifies content in the HTTP cache including images and other files .
148- COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE = 1 << 7 ,
137+ /// Specifies disk cache.
138+ COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE = 1 << 9 ,
149139
150140 /// Specifies download history data.
151- COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 1 << 8 ,
141+ COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 1 << 10 ,
152142
153143 /// Specifies general autofill form data.
154144 /// This excludes password information and includes information like:
155145 /// names, street and email addresses, phone numbers, and arbitrary input.
156146 /// This also includes payment data.
157- COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 1 << 9 ,
147+ COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 1 << 11 ,
158148
159149 /// Specifies password autosave data.
160- COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 1 << 10 ,
150+ COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 1 << 12 ,
161151
162152 /// Specifies browsing history data.
163- COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 1 << 11 ,
153+ COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 1 << 13 ,
164154
165155 /// Specifies settings data.
166- COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 1 << 12 ,
156+ COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 1 << 14 ,
167157
168158 /// Specifies profile data that should be wiped to make it look like a new profile.
169- /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_SITE,
170- /// COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE,
159+ /// This does not delete account-scoped data like passwords but will remove access
160+ /// to account-scoped data by signing the user out.
161+ /// Specifies all profile data, now and future. New profile data types may be added
162+ /// to this data kind in the future.
163+ /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE,
164+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE,
171165 /// COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY,
172166 /// COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL,
173167 /// COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE,
174168 /// COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY, and
175169 /// COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS.
176- COREWEBVIEW2_BROWSING_DATA_KINDS_PROFILE =
177- COREWEBVIEW2_BROWSING_DATA_KINDS_SITE |
178- COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE |
179- COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY |
180- COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL |
181- COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE |
182- COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY |
183- COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS,
170+ COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_PROFILE = 1 << 15,
184171} COREWEBVIEW2_BROWSING_DATA_KINDS;
185172
186173[uuid(DAF8B1F9-276D-410C-B481-58CBADF85C9C), object, pointer_default(unique)]
@@ -193,23 +180,26 @@ interface ICoreWebView2Profile : IUnknown {
193180 /// are listed below. These data kinds follow a hierarchical structure in which
194181 /// nested bullet points are included in their parent bullet point's data kind.
195182 /// Ex: DOM storage is encompassed in site data which is encompassed in the profile data.
196- /// * Profile
197- /// * Site Data
198- /// * DOM Storage: App Cache, File Systems, Indexed DB, Local Storage, Web SQL, Cache
183+ /// * All Profile
184+ /// * All Site Data
185+ /// * All DOM Storage: App Cache, File Systems, Indexed DB, Local Storage, Web SQL, Cache
199186 /// Storage
200187 /// * Cookies
201- /// * HTTP Cache
188+ /// * Disk Cache
202189 /// * Download History
203190 /// * General Autofill
204191 /// * Password Autosave
205192 /// * Browsing History
206193 /// * Settings
207- /// The completed handler will be invoked when the browsing data has been cleared and will
208- /// indicate if the specified data was properly cleared.
209- /// If the WebView object is closed before the clear browsing data operation
210- /// has completed, the handler will be released, but not invoked. In this case
211- /// the clear browsing data operation may or may not be completed.
212- /// ClearBrowsingData clears the `dataKinds` for all time.
194+ /// The completed handler will be invoked when the browsing data has been cleared and
195+ /// will indicate if the specified data was properly cleared.
196+ /// Because this is an asynchronous operation, code that is dependent on the cleared
197+ /// data must be placed in the callback of this operation.
198+ /// If the WebView object is closed before the clear browsing data operation
199+ /// has completed, the handler will be released, but not invoked. In this case
200+ /// the clear browsing data operation may or may not be completed.
201+ /// ClearBrowsingData clears the `dataKinds` regardless of timestamp.
202+
213203 HRESULT ClearBrowsingData(
214204 [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds,
215205 [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
@@ -218,19 +208,30 @@ interface ICoreWebView2Profile : IUnknown {
218208 /// takes in two additional parameters for the start and end time for which it
219209 /// should clear the data between. The `startTime` and `endTime`
220210 /// parameters correspond to the number of seconds since the UNIX epoch.
221- ///
222- /// \snippet AppWindow.cpp ClearBrowsingData
211+ /// The `startTime` will be offset by -1.0 and the `endTime will be offset by +1.0
212+ /// to ensure the last fractional second is cleared on each respective end.
213+ /// `startTime` is inclusive while `endTime` is exclusive, therefore the data will
214+ /// clear [startTime, endTime).
215+
223216 HRESULT ClearBrowsingDataInTimeRange(
224217 [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds,
225218 [in] double startTime,
226219 [in] double endTime,
227220 [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
221+
222+ /// ClearBrowsingDataAll behaves like ClearBrowsingData except that it
223+ /// clears the entirety of the data associated with the profile it is called on.
224+ /// It clears the data regardless of timestamp.
225+
226+ HRESULT ClearBrowsingDataAll(
227+ [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
228228}
229229
230230/// The caller implements this interface to receive the `ClearBrowsingData` result.
231231[uuid(27676699-FE17-4E2B-8C1B-267395A04ED5), object, pointer_default(unique)]
232232interface ICoreWebView2ClearBrowsingDataCompletedHandler : IUnknown {
233233 /// Provide the completion status of the corresponding asynchronous method.
234+
234235 HRESULT Invoke([in] HRESULT errorCode);
235236}
236237
@@ -247,22 +248,24 @@ namespace Microsoft.Web.WebView2.Core
247248 LocalStorage = 8 ,
248249 WebSql = 16 ,
249250 CacheStorage = 32 ,
250- DomStorage = 63 ,
251- Cookies = 64 ,
252- Site = 127 ,
253- HttpCache = 128 ,
254- DownloadHistory = 256 ,
255- GeneralAutofill = 512 ,
256- PasswordAutosave = 1024 ,
257- BrowsingHistory = 2048 ,
258- Settings = 4096 ,
259- Profile = 8191 ,
251+ AllDomStorage = 64 ,
252+ Cookies = 128 ,
253+ AllSite = 256 ,
254+ DiskCache = 512 ,
255+ DownloadHistory = 1024 ,
256+ GeneralAutofill = 2048 ,
257+ PasswordAutosave = 4096 ,
258+ BrowsingHistory = 8192 ,
259+ Settings = 16384 ,
260+ AllProfile = 32768 ,
260261 };
261262
262263 public partial class CoreWebView2Profile
263264 {
264- public async Task <bool > ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds );
265- public async Task <bool > ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds , double startTime , double endTime );
265+ public async Task ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds );
266+ /// .NET and WinRT will take the official DateTime object for start and end time parameters.
267+ public async Task ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds , DateTime startTime , DateTime endTime );
268+ public async Task ClearBrowsingDataAsync ();
266269 }
267270}
268271```
0 commit comments