diff --git a/harmony/rn_webview/src/main/ets/RNCWebView.ets b/harmony/rn_webview/src/main/ets/RNCWebView.ets index b7234b2de..2749ca713 100644 --- a/harmony/rn_webview/src/main/ets/RNCWebView.ets +++ b/harmony/rn_webview/src/main/ets/RNCWebView.ets @@ -65,6 +65,7 @@ export interface WebViewProps extends ViewBaseProps { webviewDebuggingEnabled: boolean // nestedScrollEnabled: boolean scrollEnabled: boolean + incognito: boolean } export class RNCWebViewBridge { @@ -190,6 +191,15 @@ export struct RNCWebView { )) this.registerCommandCallback() + + if (this.hasIncognito()) { + this.cacheMode = CacheMode.Online; + webview.WebCookieManager.putAcceptCookieEnabled(false); + } + } + + hasIncognito(): boolean { + return this.descriptorWrapper.props.incognito === true } private initVariable() { @@ -268,6 +278,9 @@ export struct RNCWebView { this.controller.deleteJavaScriptRegister(JAVASCRIPT_INTERFACE) this.controller.refresh() this.hasRegisterJavaScriptProxy = false + if (this.hasIncognito()) { + this.controller.clearHistory() + } } catch (error) { Logger.error(TAG, `[RNOH]Errorcode: ${error.code}, Message: ${error.message}`); } @@ -623,4 +636,4 @@ export struct RNCWebView { .height(this.descriptorWrapper.height) .position({ x: this.descriptorWrapper.positionRelativeToParent.x, y: this.descriptorWrapper.positionRelativeToParent.y }) } -} \ No newline at end of file +}