New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for clearing browsing data in wxWebView #24421
base: master
Are you sure you want to change the base?
Conversation
a90c9f9
to
a5e39ca
Compare
a5e39ca
to
78650ac
Compare
78650ac
to
541ccd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for adding this and sorry for such a long delay with the review!
But, to answer your question, I think that using wxDateTime(0)
is indeed a bit ugly and I believe it would be better to use wxInvalidDateTime
and then do something like
date.IsValid() ? date.GetTicks() : 0
in the implementation code. This would be slightly more verbose but IMHO much more clear at the interface level.
WebKitWebsiteDataManager* manager = static_cast<wxWebViewConfigurationImplWebKit*>(m_config.GetImpl())->GetWebsiteDataManager(); | ||
|
||
if (types & wxWEBVIEW_BROWSING_DATA_OTHER) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not map it to all the elements of WebKitWebsiteDataTypes
not otherwise used below?
if (types & wxWEBVIEW_BROWSING_DATA_COOKIES) | ||
[dataTypes addObject:WKWebsiteDataTypeCookies]; | ||
if (types & wxWEBVIEW_BROWSING_DATA_CACHE) | ||
[dataTypes addObjectsFromArray:@[WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also WKWebsiteDataTypeFetchCache
, is it excluded on purpose?
NSSet<NSString*>* clearDataTypes = nil; | ||
if (types & wxWEBVIEW_BROWSING_DATA_OTHER) | ||
{ | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, it looks like we could map this to WKWebsiteDataTypeServiceWorkerRegistrations
?
wxWEBVIEW_BROWSING_DATA_CACHE = 2, | ||
wxWEBVIEW_BROWSING_DATA_DOM_STORAGE = 4, | ||
wxWEBVIEW_BROWSING_DATA_OTHER = 8, | ||
wxWEBVIEW_BROWSING_DATA_ALL = 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should actually be 15, i.e. the sum of everything below, as otherwise it's not really clear what is the difference between specifying all of the previous constants together or this one -- by making it equal to their sum, this would clearly show that this is equivalent.
Add new method
wxWebView::ClearBrowsingData()
for WKWebView, Edge and WebKitGTKClears the browsing data of the web view.
This function clears the browsing data of the web view, such as cookies, cache, history, etc. The exact data that is cleared depends on the types parameter and the backend used.
This operation is asynchronous and may take some time to complete.
When finished a
wxEVT_WEBVIEW_BROWSING_DATA_CLEARED
event is generated.@vadz Could you please have a look at my usage of
wxDateTime
? From what I understand it would be initialized to min(int) but some of the backends treat 0 as a special value that's why I initialized it to 0. Not sure if there would be a better way.