@@ -20,14 +20,14 @@ HRESULT ClearBrowsingDataInTimeRange(
2020 [in] double endTime,
2121 [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
2222```
23- The first method takes a uint64 parameter that consists of one or more COREWEBVIEW2_BROWSING_DATA_KIND passed in as well as a handler which will indicate if the proper data has been cleared successfully. The handler will respond with a ` bool ` indicating whether the option successfully cleared the intended data fully. This method clears the data for all time.
23+ The first method takes a uint64 parameter that consists of one or more COREWEBVIEW2_BROWSING_DATA_KINDS passed in as well as a handler which will indicate if the proper data has been cleared successfully. The handler will respond with a ` bool ` indicating whether the option successfully cleared the intended data fully. This method clears the data for all time.
2424
2525The 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.
2626
2727Both methods clear the data with the associated profile in which the method is called on.
2828
2929The browsing data kinds that are supported are listed below. These data kinds follow a hierarchical structure in which nested bullet points are included in their parent bullet point's data kind.
30- Ex: DOM storage is included in site data which is included in the profile data. Each of the following bullets correspond to a COREWEBVIEW2_BROWSING_DATA_KIND .
30+ Ex: DOM storage is included in site data which is included in the profile data. Each of the following bullets correspond to a COREWEBVIEW2_BROWSING_DATA_KINDS .
3131
3232* Profile
3333 * Site Data
@@ -57,16 +57,20 @@ bool EnvironmentComponent::ClearAutofillData()
5757 {
5858 wil::com_ptr<ICoreWebView2Profile> profile;
5959 CHECK_FAILURE (webview7->get_Profile(&profile));
60- double end_time = (double)std::time(nullptr);
61- double start_time = end_time - 3600;
62- COREWEBVIEW2_BROWSING_DATA_KIND data_kinds = COREWEBVIEW2_BROWSING_DATA_KIND_GENERAL_AUTOFILL |
63- COREWEBVIEW2_BROWSING_DATA_KIND_PASSWORD_AUTOSAVE;
60+ double endTime = (double)std::time(nullptr);
61+ double startTime = endTime - 3600;
62+ /// Get the current time and offset the current time by 3600 seconds to clear the data
63+ /// from the start time (one hour ago), until the end time (present time).
64+ /// This will clear the data for the last hour.
65+ COREWEBVIEW2_BROWSING_DATA_KINDS data_kindSs = (COREWEBVIEW2_BROWSING_DATA_KINDS)
66+ (COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL |
67+ COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE));
6468 CHECK_FAILURE(profile->ClearBrowsingDataInTimeRange(
65- data_kinds, start_time, end_time ,
69+ dataKinds, startTime, endTime ,
6670 Callback<ICoreWebView2StagingClearBrowsingDataCompletedHandler >(
67- [ this] (HRESULT error, bool is_successful )
71+ [ this] (HRESULT error, bool isSuccessful )
6872 -> HRESULT {
69- LPCWSTR result = is_successful ? L"Succeeded" : L"Failed";
73+ LPCWSTR result = isSuccessful ? L"Succeeded" : L"Failed";
7074 RunAsync([ this, result] ( ) {
7175 MessageBox(nullptr, result, L"Clear Browsing Data", MB_OK);
7276 });
@@ -87,7 +91,9 @@ private void ClearAutofillData()
8791 {
8892 profile = webView .CoreWebView2 .Profile ;
8993 double endTime = DateTimeOffset .Now .ToUnixTimeSeconds ();
94+ // Get the current time which is the time in which the browsing data will be cleared until.
9095 double startTime = endTime - 3600 ;
96+ // Offset the current time by 3600 seconds to clear the browsing data from the last hour.
9197 CoreWebView2BrowsingDataKind dataKinds = CoreWebView2BrowsingDataKind .GeneralAutofill | CoreWebView2BrowsingDataKind .PasswordAutosave ;
9298 bool isSuccessful = await WebViewProfile .ClearBrowsingDataAsync ((UInt64 )dataKinds , startTime , endTime );
9399 MessageBox .Show (this ,
@@ -112,97 +118,95 @@ interface ICoreWebView2ClearBrowsingDataCompletedHandler;
112118/// Specifies the datatype for the
113119/// `ICoreWebView2Profile::ClearBrowsingData` method.
114120[v1_enum]
115- typedef enum COREWEBVIEW2_BROWSING_DATA_KIND {
121+ typedef enum COREWEBVIEW2_BROWSING_DATA_KINDS {
116122 /// Specifies data stored by the AppCache DOM feature.
117- COREWEBVIEW2_BROWSING_DATA_KIND_APP_CACHE = 1 << 0,
123+ COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE = 1 << 0,
118124
119125 /// Specifies file systems data.
120- COREWEBVIEW2_BROWSING_DATA_KIND_FILE_SYSTEMS = 1 << 1,
126+ COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS = 1 << 1,
121127
122128 /// Specifies data stored by the IndexedDB DOM feature.
123- COREWEBVIEW2_BROWSING_DATA_KIND_INDEXED_DB = 1 << 2,
129+ COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB = 1 << 2,
124130
125131 /// Specifies data stored by the localStorage DOM API.
126- COREWEBVIEW2_BROWSING_DATA_KIND_LOCAL_STORAGE = 1 << 3,
132+ COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE = 1 << 3,
127133
128134 /// Specifies data stored by the Web SQL database DOM API.
129- COREWEBVIEW2_BROWSING_DATA_KIND_WEB_SQL = 1 << 4,
135+ COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 1 << 4,
130136
131137 /// Specifies cache storage which stores the network requests
132138 /// and responses.
133- COREWEBVIEW2_BROWSING_DATA_KIND_CACHE_STORAGE = 1 << 5,
139+ COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 1 << 5,
134140
135141 /// Specifies DOM storage data. This browsing data kind is inclusive
136- /// of COREWEBVIEW2_BROWSING_DATA_KIND_APP_CACHE ,
137- /// COREWEBVIEW2_BROWSING_DATA_KIND_FILE_SYSTEMS ,
138- /// COREWEBVIEW2_BROWSING_DATA_KIND_INDEXED_DB ,
139- /// COREWEBVIEW2_BROWSING_DATA_KIND_LOCAL_STORAGE ,
140- /// COREWEBVIEW2_BROWSING_DATA_KIND_WEB_SQL ,
141- /// COREWEBVIEW2_BROWSING_DATA_KIND_CACHE_STORAGE .
142- COREWEBVIEW2_BROWSING_DATA_KIND_DOM_STORAGE =
143- COREWEBVIEW2_BROWSING_DATA_KIND_APP_CACHE |
144- COREWEBVIEW2_BROWSING_DATA_KIND_FILE_SYSTEMS |
145- COREWEBVIEW2_BROWSING_DATA_KIND_INDEXED_DB |
146- COREWEBVIEW2_BROWSING_DATA_KIND_LOCAL_STORAGE |
147- COREWEBVIEW2_BROWSING_DATA_KIND_WEB_SQL |
148- COREWEBVIEW2_BROWSING_DATA_KIND_CACHE_STORAGE ,
142+ /// of COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE ,
143+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS ,
144+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB ,
145+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE ,
146+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL ,
147+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE .
148+ COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE =
149+ COREWEBVIEW2_BROWSING_DATA_KINDS_APP_CACHE |
150+ COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS |
151+ COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB |
152+ COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE |
153+ COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL |
154+ COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE ,
149155
150156 /// Specifies HTTP cookies data.
151- COREWEBVIEW2_BROWSING_DATA_KIND_COOKIES = 1 << 6,
157+ COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 1 << 6,
152158
153159 /// Specifies site data. This browsing data kind
154- /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KIND_DOM_STORAGE and
155- /// COREWEBVIEW2_BROWSING_DATA_KIND_COOKIES .
156- COREWEBVIEW2_BROWSING_DATA_KIND_SITE = COREWEBVIEW2_BROWSING_DATA_KIND_DOM_STORAGE |
157- COREWEBVIEW2_BROWSING_DATA_KIND_COOKIES ,
160+ /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE and
161+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES .
162+ COREWEBVIEW2_BROWSING_DATA_KINDS_SITE = COREWEBVIEW2_BROWSING_DATA_KINDS_DOM_STORAGE |
163+ COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES ,
158164
159165 /// Specifies content in the HTTP cache including images and other files.
160- COREWEBVIEW2_BROWSING_DATA_KIND_HTTP_CACHE = 1 << 7,
166+ COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE = 1 << 7,
161167
162168 /// Specifies download history data.
163- COREWEBVIEW2_BROWSING_DATA_KIND_DOWNLOAD_HISTORY = 1 << 8,
169+ COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 1 << 8,
164170
165171 /// Specifies general autofill form data.
166172 /// This excludes password information and includes information like:
167173 /// names, street and email addresses, phone numbers, and arbitrary input.
168174 /// This also includes payment data.
169- COREWEBVIEW2_BROWSING_DATA_KIND_GENERAL_AUTOFILL = 1 << 9,
175+ COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 1 << 9,
170176
171177 /// Specifies password autosave data.
172- COREWEBVIEW2_BROWSING_DATA_KIND_PASSWORD_AUTOSAVE = 1 << 10,
178+ COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 1 << 10,
173179
174180 /// Specifies browsing history data.
175- COREWEBVIEW2_BROWSING_DATA_KIND_BROWSING_HISTORY = 1 << 11,
181+ COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 1 << 11,
176182
177183 /// Specifies settings data.
178- COREWEBVIEW2_BROWSING_DATA_KIND_SETTINGS = 1 << 12,
184+ COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 1 << 12,
179185
180186 /// Specifies profile data that should be wiped to make it look like a new profile.
181- /// This does not delete account-scoped data like passwords but will remove access
182- /// to account-scoped data by signing the user out.
183- /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KIND_SITE,
184- /// COREWEBVIEW2_BROWSING_DATA_KIND_HTTP_CACHE,
185- /// COREWEBVIEW2_BROWSING_DATA_KIND_DOWNLOAD_HISTORY,
186- /// COREWEBVIEW2_BROWSING_DATA_KIND_GENERAL_AUTOFILL,
187- /// COREWEBVIEW2_BROWSING_DATA_KIND_PASSWORD_AUTOSAVE,
188- /// COREWEBVIEW2_BROWSING_DATA_KIND_BROWSING_HISTORY, and
189- /// COREWEBVIEW2_BROWSING_DATA_KIND_SETTINGS.
190- COREWEBVIEW2_BROWSING_DATA_KIND_PROFILE =
191- COREWEBVIEW2_BROWSING_DATA_KIND_SITE |
192- COREWEBVIEW2_BROWSING_DATA_KIND_HTTP_CACHE |
193- COREWEBVIEW2_BROWSING_DATA_KIND_DOWNLOAD_HISTORY |
194- COREWEBVIEW2_BROWSING_DATA_KIND_GENERAL_AUTOFILL |
195- COREWEBVIEW2_BROWSING_DATA_KIND_PASSWORD_AUTOSAVE |
196- COREWEBVIEW2_BROWSING_DATA_KIND_BROWSING_HISTORY |
197- COREWEBVIEW2_BROWSING_DATA_KIND_SETTINGS,
198- } COREWEBVIEW2_BROWSING_DATA_KIND;
187+ /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_SITE,
188+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE,
189+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY,
190+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL,
191+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE,
192+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY, and
193+ /// COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS.
194+ COREWEBVIEW2_BROWSING_DATA_KINDS_PROFILE =
195+ COREWEBVIEW2_BROWSING_DATA_KINDS_SITE |
196+ COREWEBVIEW2_BROWSING_DATA_KINDS_HTTP_CACHE |
197+ COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY |
198+ COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL |
199+ COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE |
200+ COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY |
201+ COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS,
202+ } COREWEBVIEW2_BROWSING_DATA_KINDS;
199203
200204[uuid(DAF8B1F9-276D-410C-B481-58CBADF85C9C), object, pointer_default(unique)]
201205interface ICoreWebView2Profile : IUnknown {
202206
203207 /// Clear browsing data based on a data type. This method takes two parameters,
204- /// the first being a mask of one or more COREWEBVIEW2_BROWSING_DATAKIND values . OR operation(s)
205- /// can be applied to multiple COREWEBVIEW2_BROWSING_DATA_KIND values to create a mask
208+ /// the first being a mask of one or more `COREWEBVIEW2_BROWSING_DATAKINDS` . OR operation(s)
209+ /// can be applied to multiple `COREWEBVIEW2_BROWSING_DATA_KINDS` to create a mask
206210 /// representing multiple data types. The browsing data kinds that are supported
207211 /// are listed below. These data kinds follow a hierarchical structure in which
208212 /// nested bullet points are included in their parent bullet point's data kind.
@@ -228,8 +232,9 @@ interface ICoreWebView2Profile : IUnknown {
228232 [in] UINT64 dataKinds,
229233 [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
230234
231- /// ClearBrowsingDataInTimeRange takes in two additional parameters for the
232- /// start and end time for which it should clear the data between. The startTime and endTime
235+ /// ClearBrowsingDataInTimeRange behaves like ClearBrowsingData except that it
236+ /// takes in two additional parameters for the start and end time for which it
237+ /// should clear the data between. The startTime and endTime
233238 /// parameters correspond to the number of seconds since the UNIX epoch.
234239 ///
235240 /// \snippet AppWindow.cpp ClearBrowsingData
@@ -246,6 +251,8 @@ interface ICoreWebView2ClearBrowsingDataCompletedHandler : IUnknown {
246251 /// Provide the completion status and result of the corresponding
247252 /// asynchronous method. The result indicates if the ClearBrowsingData
248253 /// call has completed successfully and all intended data has been cleared.
254+ /// If the call has been interrupted and does not clear all the intended data,
255+ /// the `errorCode` is `S_OK` and `isSuccessful` will be `false`.
249256 HRESULT Invoke(
250257 [in] HRESULT errorCode,
251258 [in] BOOL isSuccessful);
@@ -256,7 +263,7 @@ interface ICoreWebView2ClearBrowsingDataCompletedHandler : IUnknown {
256263``` c#
257264namespace Microsoft .Web .WebView2 .Core
258265{
259- [Flags ] enum CoreWebView2BrowsingDataKind
266+ [Flags ] enum CoreWebView2BrowsingDataKinds
260267 {
261268 AppCache = 1 ,
262269 FileSystems = 2 ,
@@ -276,14 +283,10 @@ namespace Microsoft.Web.WebView2.Core
276283 Profile = 8191 ,
277284 };
278285
279- public partial class CoreWebView2Environment
286+ public partial class CoreWebView2Profile
280287 {
281- /// The ClearBrowsingDataAsync method may be overloaded to take either one parameter - dataKinds, or three parameters - dataKinds, startTime, and endTime.
282- /// NOTE TO REVIEWERS:
283- /// We're taking ulong here because we need to accept orred enum values like HttpCache | DownloadHistory which isn't a value in the DataKind enum.
284- /// We need to take ulong to get the proper masked thru, is it OK to take the enum as the parameter type here in COM, WinRT, and .NET?
285- public async Task <CoreWebView2ClearBrowsingDataResultKind > ClearBrowsingDataAsync (ulong dataKinds );
286- public async Task <CoreWebView2ClearBrowsingDataResultKind > ClearBrowsingDataAsync (ulong dataKinds , double startTime , double endTime );
288+ public async Task <CoreWebView2ClearBrowsingDataResultKind > ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds );
289+ public async Task <CoreWebView2ClearBrowsingDataResultKind > ClearBrowsingDataAsync (CoreWebView2BrowsingDataKinds dataKinds , double startTime , double endTime );
287290 }
288291}
289292```
0 commit comments