-
Notifications
You must be signed in to change notification settings - Fork 41
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
WIP: Cookie Impl #10
WIP: Cookie Impl #10
Conversation
@KevinnZou I will be having somewhat super packed up coming weeks, so you are more than welcome to take this to end stage in case I might take extended time. Appreciate your efforts in here. |
Thank you for providing the blueprint setup. It will be very helpful to me. Last week, we focused on transitioning from JavaFX to the CEF browser. We were able to solve the issue today and we plan to release the new version tomorrow. After that, we will have time to address this issue and aim to implement it by the end of next week. We will keep you updated on our progress. Thank you once again for your contribution! |
} | ||
} | ||
|
||
expect fun getCookieExpirationDate(expiresDate: Long): String |
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.
would it be better to just use the kotlinx-datetime library?
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.
We can if it increases convenience, if its just this usage and no usage in future then adding additional library doesnt make much sense.
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.
makes sense.
@Shabinder I have implemented CookieManager for iOS and Desktop. It works well on iOS, but there is a major issue on Desktop. The problem is that I am using the CefCookieManager obtained through After some research, I found an existing issue in the JCEF repository that is related to this problem. @DatL4g, could you please take a look at it? If the issue with the CefCookieManager cannot be resolved, we may need to explore alternative methods to support cookie management on the Desktop platform. |
interface CookieManager { | ||
suspend fun setCookie(url: String, cookie: Cookie) | ||
suspend fun getCookies(url: String): List<Cookie> | ||
suspend fun removeAllCookies() |
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.
We should also have a delete cookie function for a URL.
suspend fun removeCookies(url: String)
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.
Also WebSettings
should have following options.
- isCookiesEnabled: Boolean
- isThirdPartyCookiesEnabled: Boolean
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.
Great progress overall, kudos @KevinnZou
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.
We should also have a delete cookie function for a URL.
suspend fun removeCookies(url: String)
I have implemented it for iOS and Desktop in this commit. It seems that Android does not provide a method to delete cookies for specific URLs so I leave it as TODO.
@Shabinder Could not push to your PR directly, opened a PR Shabinder#1 @KevinnZou |
WIP: Cookie Impl
Have merged it, and sent u an invite for access aswell. |
@DatL4g I tested your PR locally and it turns out that it still does not work. We can only get the cookie we set before. It is because we have a local cache. But for other cookies sent by the website, we still cannot get it. |
@KevinnZou I think we need to stall this on desktop then. I can write a kotlin library that handles the native bindings etc, so basically a newer, better and maybe depending on Jetbrains CEF version of JCEF. I already have experience with Kotlin Native and Java/Kotlin bindings so I have the required know-how |
@KevinnZou we could also read the cookie sqlite file ourself (already tried that with no success until I noticed that we delete all cookies right after adding one 🤦🏻) But the value is encrypted in there, and I don't know how to decrypt it |
@DatL4g Thanks for your investigation! If the current version of JCEF does not support it, I think we can release a version that supports Android and iOS first. As for the desktop, I am looking forward to seeing your library that is based on Jetbrains CEF, which will definitely have better performance. |
Please test https://github.com/DATL4G/KCEF by doing the following: git clone git@github.com:DATL4G/KCEF.git --recurse-submodules
./gradlew example:run # Or run it from IntelliJ @Shabinder do you use Windows? |
I am a mac user aswell. |
Tested https://github.com/DATL4G/KCEF on Windows and added some patches. Added fixes for MacOS as well, @Shabinder @KevinnZou if you tried it before, please do it again. |
Apologies for the delayed response. I have recently returned from a lengthy vacation. Regarding your project, I encountered an issue while testing it on my Mac system. Specifically, it crashed right after the Jcef Bundled was downloaded. Here is the corresponding stack trace:
|
@KevinnZou thanks for reporting, I applied some fixes. |
@DatL4g As previously discussed, I will clean up this MR today and release it with the latest version. Regarding KCEF, Before switching to it, I believe it is necessary to conduct a comprehensive test and wait for public feedback. It may take some time to become stable and ready for use. Let's use this separate issue to discuss future problems with KCEF. |
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.
Due to some issues with JCEF, we have decided to initially support Android and iOS platforms. Once the KCEF testing is stable, we will switch to it and also support cookies on the Desktop platform.
val cookieList = mutableListOf<Cookie>() | ||
CefCookieManager.getGlobalManager().visitUrlCookies( | ||
val cookieList = mutableSetOf<Cookie>() | ||
desktopCookieManager?.visitUrlCookies( |
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.
If desktopCookieManager?.visitUrlCookies
cannot return the value synchronously, should it just not work like before? The cookieList
will only contain the values obtained from cached cookies
which may not be the latest.
@@ -88,14 +90,17 @@ object DesktopCookieManager : CookieManager, CefCookieVisitor { | |||
) | |||
}.forEach(cookieList::add) | |||
|
|||
return cookieList.toList() | |||
continuation.resume(cookieList.toList()) |
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.
If desktopCookieManager?.visitUrlCookies
does not provide a callback to inform us that the cookies are obtained from the disk, will it be no use to have a suspendCoroutine
here? Since the continuation.resume(cookieList.toList())
will always be called at the end of the method, it works just like the return.
interface CookieManager { | ||
suspend fun setCookie(url: String, cookie: Cookie) | ||
suspend fun getCookies(url: String): List<Cookie> | ||
suspend fun removeAllCookies() |
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.
We should also have a delete cookie function for a URL.
suspend fun removeCookies(url: String)
I have implemented it for iOS and Desktop in this commit. It seems that Android does not provide a method to delete cookies for specific URLs so I leave it as TODO.
PR building Cookie Management in client using WebView.