Support clearing browsing data for a specific domain only with `ClearBrowsingDataAsync`
Is your feature request related to a problem? Please describe.
Add support to CoreWebView2Profile.ClearBrowsingDataAsync to be able to clear browsing data only for specific domain / website.
Currently CoreWebView2Profile.ClearBrowsingDataAsync only support clearing data per data kind and between a time range. However we want to be able to clear cache data for some domains only and leave the other data intact.
Describe the solution you'd like and alternatives you've considered Possible solutions
- ClearBrowsingDataAsync() should have a new overload that accepts a
stringto delete all data for a specific domain. - Add support for
InPrivatemode where no browsing data is persisted, so we can manage all data clearing on our side.
I would like to use this feature too.
Thanks for the feature request, we've added this to our backlog!
Hi @q71114,
Can you describe the scenarios you are trying to build with this feature?
Thank you, Nishitha
Hi @nishitha-burman,
This will be the exact scenario describe in Feature request: Permissions API: We offer option to clear all data for specific domains. When selected all user data will be cleared for those domains including any browsing data or cache.
Hi @q71114,
Can you use the Permission Management APIs to reset the state per domain using SetPermissionState?
Hi @nishitha-burman ,
That will only clear the permission state but not the browsing data or cache. Also with the new Permission Management APIs and the SavesInProfile property the permission states are not even necessarily stored in WebView2 anymore.
Hey @nishitha-burman,
I gathered a two scenarios below which might help with your feature design.
Scenario 1 - clearing browsing data of specific domains only
- User wants to clear all browsing data for
bing.comandmicrosoft.combut wants to keep everything else intact. - For example:
- User visited websites under
github.com,bing.com,microsoft.comand various other hosts. - User was logged in to
github.comandmicrosoft.com - After calling the new API:
- they should still have all the cookies / caches from
github.comand are still logged in togithub.com - but all cookies / caches from
microsoft.comandbing.comare deleted and they should not be logged in tomicrosoft.comanymore
- they should still have all the cookies / caches from
- User visited websites under
Scenario 2 - clearing all browsing data except for specific domains
- User wants to clear all browsing data of all websites except the ones for
bing.comandmicrosoft.com. - For example:
- User visited websites under
github.com,bing.com,microsoft.comand various other hosts. - User was logged in to
github.comandmicrosoft.com. - After calling the new API:
- they should still have all the cookies / caches from
microsoft.com/bing.comand are still logged in tomicrosoft.com - all cookies / caches for all other hosts including
github.comare deleted and they should not be logged in togithub.comanymore
- they should still have all the cookies / caches from
- User visited websites under
- In theory this can be solved by using Scenario 1 and clearing every visited hosts one by one except
bing.com/microsoft.combut having a separate API for it would make things easier.
Hope this helps, otherwise I can clarify further if needed.
Hi @q71114,
Thank you for the context. Can you see if using CDP's storage domain addresses your scenario? https://chromedevtools.github.io/devtools-protocol/tot/Storage/
Thanks!
Hi @nishitha-burman ,
I'm afraid there's a number of stores that the WebView2's ClearBrowsingDataAsync method cleans up but the CDP's Storage.clearDataForOrigin misses:
- \EBWebView\Default\Favicons
- \EBWebView\Default\History
- \EBWebView\Default\Top Sites
- \EBWebView\Default\Cache\Cache_Data
- \EBWebView\Default\Code Cache
- \EBWebView\Default\Network\Network Persistent State
- \EBWebView\Default\Network\Reporting and NEL
(There might be others, but these are the ones discovered through our first pass). These stores might have been added by Edge, thus CDP misses them when doing cleanup.
As such, we can't purely rely on the CDP methods.
Hi, it's been over a year since the last update. Any updates on the feature request?