fix(incognito): Ensures that incognito doesn't clear cookies when not enabled (#1447 by @jasonkellydk)

Co-authored-by: Jason Kelly <jason.kelly@isobar.com>
Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com>
Co-authored-by: Jason Safaiyeh <safaiyeh@protonmail.com>
This commit is contained in:
Jason Kelly 2020-08-15 05:04:20 +02:00 committed by GitHub
parent 7513f198c1
commit 63c584c647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -432,6 +432,11 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@ReactProp(name = "incognito")
public void setIncognito(WebView view, boolean enabled) {
// Don't do anything when incognito is disabled
if (!enabled) {
return;
}
// Remove all previous cookies
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().removeAllCookies(null);
@ -441,14 +446,14 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
// Disable caching
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
view.getSettings().setAppCacheEnabled(!enabled);
view.getSettings().setAppCacheEnabled(false);
view.clearHistory();
view.clearCache(enabled);
view.clearCache(true);
// No form data or autofill enabled
view.clearFormData();
view.getSettings().setSavePassword(!enabled);
view.getSettings().setSaveFormData(!enabled);
view.getSettings().setSavePassword(false);
view.getSettings().setSaveFormData(false);
}
@ReactProp(name = "source")