feat(android props): Add incognito to Android (#524)

This commit is contained in:
José Luis Pereira 2019-08-02 00:48:54 -07:00 committed by Thibault Malbranche
parent 1d649a81c8
commit 25bc5a55c6
3 changed files with 21 additions and 4 deletions

View File

@ -329,6 +329,23 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
((RNCWebView) view).setMessagingEnabled(enabled); ((RNCWebView) view).setMessagingEnabled(enabled);
} }
@ReactProp(name = "incognito")
public void setIncognito(WebView view, boolean enabled) {
// Remove all previous cookies
CookieManager.getInstance().removeAllCookies(null);
// Disable caching
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
view.getSettings().setAppCacheEnabled(!enabled);
view.clearHistory();
view.clearCache(enabled);
// No form data or autofill enabled
view.clearFormData();
view.getSettings().setSavePassword(!enabled);
view.getSettings().setSaveFormData(!enabled);
}
@ReactProp(name = "source") @ReactProp(name = "source")
public void setSource(WebView view, @Nullable ReadableMap source) { public void setSource(WebView view, @Nullable ReadableMap source) {
if (source != null) { if (source != null) {

View File

@ -832,8 +832,8 @@ If true, this will be able horizontal swipe gestures when using the WKWebView. T
Does not store any data within the lifetime of the WebView. Does not store any data within the lifetime of the WebView.
| Type | Required | Platform | | Type | Required | Platform |
| ------- | -------- | ------------- | | ------- | -------- | ---------------------- |
| boolean | No | iOS WKWebView | | boolean | No | Android, iOS WKWebView |
--- ---

View File

@ -212,6 +212,7 @@ export type OnShouldStartLoadWithRequest = (
export interface CommonNativeWebViewProps extends ViewProps { export interface CommonNativeWebViewProps extends ViewProps {
cacheEnabled?: boolean; cacheEnabled?: boolean;
incognito?: boolean;
injectedJavaScript?: string; injectedJavaScript?: string;
mediaPlaybackRequiresUserAction?: boolean; mediaPlaybackRequiresUserAction?: boolean;
messagingEnabled: boolean; messagingEnabled: boolean;
@ -258,7 +259,6 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
decelerationRate?: number; decelerationRate?: number;
directionalLockEnabled?: boolean; directionalLockEnabled?: boolean;
hideKeyboardAccessoryView?: boolean; hideKeyboardAccessoryView?: boolean;
incognito?: boolean;
pagingEnabled?: boolean; pagingEnabled?: boolean;
scrollEnabled?: boolean; scrollEnabled?: boolean;
useSharedProcessPool?: boolean; useSharedProcessPool?: boolean;