Implement more request interceptor APIs. (#3466)
authorhuayongxu <49056704+huayongxu@users.noreply.github.com>
Tue, 7 Sep 2021 04:49:15 +0000 (12:49 +0800)
committerhuiyu <35286162+huiyueun@users.noreply.github.com>
Tue, 7 Sep 2021 09:05:39 +0000 (18:05 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebContext.cs
src/Tizen.NUI/src/internal/Interop/Interop.WebHttpRequestInterceptor.cs
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/internal/Interop/WebHttpRequestInterceptorPtr.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/WebView/WebBackForwardList.cs
src/Tizen.NUI/src/internal/WebView/WebContext.cs
src/Tizen.NUI/src/internal/WebView/WebHttpRequestInterceptor.cs
src/Tizen.NUI/src/internal/WebView/WebView.cs
src/Tizen.NUI/src/internal/WebView/WebViewHttpRequestInterceptedEventArgs.cs [deleted file]
test/Tizen.NUI.WebViewTest/SimpleWebViewApp.cs

index 4f75731..e800886 100755 (executable)
@@ -93,6 +93,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebContext_RegisterMimeOverriddenCallback")]
             public static extern void RegisterMimeOverriddenCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebContext_RegisterRequestInterceptedCallback")]
+            public static extern void RegisterRequestInterceptedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebContext_EnableCache")]
             public static extern void EnableCache(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
 
index af9565f..7a7a6a4 100755 (executable)
@@ -21,12 +21,15 @@ namespace Tizen.NUI
     {
         internal static partial class WebHttpRequestInterceptor
         {
-            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebRequestInterceptor")]
-            public static extern void DeleteWebHttpRequestInterceptor(global::System.Runtime.InteropServices.HandleRef jarg1);
-
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_GetUrl")]
             public static extern string GetUrl(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_GetMethod")]
+            public static extern string GetMethod(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_GetHeaders")]
+            public static extern global::System.IntPtr GetHeaders(global::System.Runtime.InteropServices.HandleRef jarg1);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_Ignore")]
             [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
             public static extern bool Ignore(global::System.Runtime.InteropServices.HandleRef jarg1);
@@ -39,9 +42,21 @@ namespace Tizen.NUI
             [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
             public static extern bool AddResponseHeader(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, string jarg3);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_AddResponseHeaders")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool AddResponseHeaders(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_AddResponseBody")]
             [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
             public static extern bool AddResponseBody(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, uint jarg3);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_AddResponse")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool AddResponse(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, string jarg3, uint jarg4);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptor_WriteResponseChunk")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool WriteResponseChunk(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, uint jarg3);
         }
     }
 }
index 52cd3ec..8dc41d5 100755 (executable)
@@ -277,9 +277,6 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterFrameRenderedCallback")]
             public static extern void RegisterFrameRenderedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
-            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterRequestInterceptorCallback")]
-            public static extern void RegisterRequestInterceptorCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterConsoleMessageReceivedCallback")]
             public static extern void RegisterConsoleMessageReceivedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
diff --git a/src/Tizen.NUI/src/internal/Interop/WebHttpRequestInterceptorPtr.cs b/src/Tizen.NUI/src/internal/Interop/WebHttpRequestInterceptorPtr.cs
new file mode 100755 (executable)
index 0000000..3395ff1
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class WebHttpRequestInterceptorPtr
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebRequestInterceptorPtr")]
+            public static extern void DeleteWebHttpRequestInterceptorPtr(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebRequestInterceptorPtr_Get")]
+            public static extern global::System.IntPtr Get(global::System.Runtime.InteropServices.HandleRef jarg1);
+        }
+    }
+}
index 1bfcb83..ca25c9d 100755 (executable)
@@ -110,7 +110,6 @@ namespace Tizen.NUI
                     forwardItemList.Dispose();
                 }
             }
-
             base.Dispose(type);
         }
 
@@ -261,3 +260,4 @@ namespace Tizen.NUI
         }
     }
 }
+
index 0f4b942..aa82b1c 100755 (executable)
@@ -38,11 +38,15 @@ namespace Tizen.NUI
         private WebPasswordDataList passwordList;
         private PasswordDataListAcquiredCallback passwordDataListAcquiredCallback;
         private readonly WebContextPasswordDataListAcquiredProxyCallback passwordDataListAcquiredProxyCallback;
+        private WebHttpRequestInterceptor httpRequestInterceptor;
+        private HttpRequestInterceptedCallback httpRequestInterceptedCallback;
+        private readonly WebContextHttpRequestInterceptedProxyCallback httpRequestInterceptedProxyCallback;
 
         internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
             securityOriginListAcquiredProxyCallback = OnSecurityOriginListAcquired;
             passwordDataListAcquiredProxyCallback = OnPasswordDataListAcquired;
+            httpRequestInterceptedProxyCallback = OnHttpRequestIntercepted;
         }
 
         /// <summary>
@@ -69,6 +73,10 @@ namespace Tizen.NUI
                 {
                     securityOriginList.Dispose();
                 }
+                if (httpRequestInterceptor != null)
+                {
+                    httpRequestInterceptor.Dispose();
+                }
             }
 
             base.Dispose(type);
@@ -109,12 +117,22 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public delegate bool MimeOverriddenCallback(string url, string currentMime, string newMime);
 
+        /// <summary>
+        /// The callback function that is invoked when http request need be intercepted.
+        /// </summary>
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public delegate void HttpRequestInterceptedCallback(WebHttpRequestInterceptor interceptor);
+
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebContextSecurityOriginListAcquiredProxyCallback(IntPtr list);
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebContextPasswordDataListAcquiredProxyCallback(IntPtr list);
 
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void WebContextHttpRequestInterceptedProxyCallback(IntPtr interceptor);
+
         /// <summary>
         /// Cache model
         /// </summary>
@@ -521,6 +539,23 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Registers callback for http request interceptor.
+        /// <param name="callback">callback for overriding mime type</param>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void RegisterHttpRequestInterceptedCallback(HttpRequestInterceptedCallback callback)
+        {
+            httpRequestInterceptedCallback = callback;
+            IntPtr ip = IntPtr.Zero;
+            if (httpRequestInterceptedCallback != null)
+            {
+                ip = Marshal.GetFunctionPointerForDelegate(httpRequestInterceptedProxyCallback);
+            }
+            Interop.WebContext.RegisterRequestInterceptedCallback(SwigCPtr, new HandleRef(this, ip));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
         /// Sets context time zone offset.
         /// <param name="offset">Time offset</param>
         /// <param name="time">Daylight saving time</param>
@@ -690,5 +725,15 @@ namespace Tizen.NUI
             }
             passwordDataListAcquiredCallback?.Invoke(passwordDataList);
         }
+
+        private void OnHttpRequestIntercepted(IntPtr interceptor)
+        {
+            if (httpRequestInterceptor != null)
+            {
+                httpRequestInterceptor.Dispose();
+            }
+            httpRequestInterceptor = new WebHttpRequestInterceptor(interceptor, true);
+            httpRequestInterceptedCallback?.Invoke(httpRequestInterceptor);
+        }
     }
 }
index 994cd7d..d165925 100755 (executable)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,9 @@
  */
 
 using System;
+using System.Collections.Generic;
 using System.ComponentModel;
+using System.Runtime.InteropServices;
 
 namespace Tizen.NUI
 {
@@ -26,8 +28,12 @@ namespace Tizen.NUI
     [EditorBrowsable(EditorBrowsableState.Never)]
     public class WebHttpRequestInterceptor : Disposable
     {
+        private HandleRef interceptorHandle;
+
         internal WebHttpRequestInterceptor(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
+            IntPtr ip = Interop.WebHttpRequestInterceptorPtr.Get(SwigCPtr);
+            interceptorHandle = new HandleRef(this, ip);
         }
 
         /// This will not be public opened.
@@ -35,7 +41,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            Interop.WebHttpRequestInterceptor.DeleteWebHttpRequestInterceptor(swigCPtr);
+            Interop.WebHttpRequestInterceptorPtr.DeleteWebHttpRequestInterceptorPtr(swigCPtr);
         }
 
         /// <summary>
@@ -46,56 +52,180 @@ namespace Tizen.NUI
         {
             get
             {
-                return Interop.WebHttpRequestInterceptor.GetUrl(SwigCPtr);
+                return Interop.WebHttpRequestInterceptor.GetUrl(interceptorHandle);
+            }
+        }
+
+        /// <summary>
+        /// Gets method of intercepted http request, for example, GET, POST, etc.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string Method
+        {
+            get
+            {
+                return Interop.WebHttpRequestInterceptor.GetMethod(interceptorHandle);
+            }
+        }
+
+        /// <summary>
+        /// Gets headers of intercepted http request.
+        /// Headers is a map with string key-value pairs,
+        /// for example, "Accept: text/plain", "Accept-Charset: utf-8", etc.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public IDictionary<string, string> Headers
+        {
+            get
+            {
+                IntPtr mapPtr = Interop.WebHttpRequestInterceptor.GetHeaders(interceptorHandle);
+                IDictionary<string, string> dictionary = new Dictionary<string, string>();
+                PropertyMap map = new PropertyMap(mapPtr, true);
+                for (uint i = 0; i < map.Count(); i++)
+                {
+                    using (PropertyKey key = map.GetKeyAt(i))
+                    {
+                        if (key.Type == PropertyKey.KeyType.String)
+                        {
+                            string outValue;
+                            using (PropertyValue mapValue = map.GetValue(i))
+                            {
+                                if (mapValue.Get(out outValue))
+                                {
+                                    dictionary.Add(key.StringKey, outValue);
+                                }
+                            }
+                        }
+                    }
+                }
+                map.Dispose();
+                return dictionary;
             }
         }
 
         /// <summary>
-        /// Ignores this request.
+        /// Ignores the http request.
+        /// When application doesn't have a response for intercepted request,
+        /// this function would be called which notifies engine to proceed with normal resource loading.
+        /// It can be called only INSIDE WebContext.HttpRequestIntercepted.
+        /// After it called, any further call on WebHttpRequestInterceptor results in undefined behavior.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool Ignore()
         {
-            bool result = Interop.WebHttpRequestInterceptor.Ignore(SwigCPtr);
+            bool result = Interop.WebHttpRequestInterceptor.Ignore(interceptorHandle);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return result;
         }
 
         /// <summary>
         /// Sets status code and status text of response for intercepted request.
+        /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
         /// <param name="statusCode">Status code of response</param>
         /// <param name="customStatusText">Status text of response</param>
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool SetResponseStatus(int statusCode, string customStatusText)
         {
-            bool result = Interop.WebHttpRequestInterceptor.SetResponseStatus(SwigCPtr, statusCode, customStatusText);
+            bool result = Interop.WebHttpRequestInterceptor.SetResponseStatus(interceptorHandle, statusCode, customStatusText);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return result;
         }
 
         /// <summary>
         /// Adds HTTP header to response for intercepted request.
+        /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
         /// <param name="fieldName">Key of response header</param>
         /// <param name="fieldValue">Value of response header</param>
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool AddResponseHeader(string fieldName, string fieldValue)
         {
-            bool result = Interop.WebHttpRequestInterceptor.AddResponseHeader(SwigCPtr, fieldName, fieldValue);
+            bool result = Interop.WebHttpRequestInterceptor.AddResponseHeader(interceptorHandle, fieldName, fieldValue);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return result;
+        }
+
+        /// <summary>
+        /// Adds HTTP headers to response for intercepted request.
+        /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
+        /// <param name="headers">Map of response headers</param>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool AddResponseHeaders(IDictionary<string, string> headers)
+        {
+            if (headers == null)
+                return false;
+            PropertyMap headerMap = new PropertyMap();
+            foreach (KeyValuePair<string, string> kvp in headers)
+            {
+                using (PropertyValue value = new PropertyValue(kvp.Value))
+                {
+                    headerMap.Add(kvp.Key, value);
+                }
+            }
+            bool result = Interop.WebHttpRequestInterceptor.AddResponseHeaders(interceptorHandle, PropertyMap.getCPtr(headerMap));
+            headerMap.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return result;
         }
 
         /// <summary>
         /// Writes whole response body at once.
+        /// To call it, application should have full response body ready for the intercepted request.
+        /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
+        /// After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
+        /// <param name="body">Contents of response</param>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool SetResponseBody(string body)
+        {
+            if (body == null)
+                return false;
+            bool result = Interop.WebHttpRequestInterceptor.AddResponseBody(interceptorHandle, body, (uint)body.Length);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return result;
+        }
+
+        /// <summary>
+        /// Writes whole response body with headers at once.
+        /// To call it, application should have full response headers and body ready for the intercepted request.
+        /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
+        /// After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
+        /// <param name="headers">Headers of response</param>
         /// <param name="body">Contents of response</param>
-        /// <param name="length">Length of Contents of response</param>
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public bool AddResponseBody(string body, uint length)
+        public bool SetResponse(string headers, string body)
+        {
+            if (body == null)
+                return false;
+            bool result = Interop.WebHttpRequestInterceptor.AddResponse(interceptorHandle, headers, body, (uint)body.Length);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return result;
+        }
+
+        /// <summary>
+        /// Writes a part of response body.
+        /// This function can be called only OUTSIDE WebContext.HttpRequestIntercepted.
+        /// If it returns false, handling the request is done.
+        /// Any further calls result in undefined behavior.
+        /// User should always check return value, because response to this request might not be needed any more,
+        /// and the function can return false even though user still has data to write.
+        /// 
+        /// After writing full response body in chunks using this function,
+        /// call it again with null as chunk, to signal that response body is finished.
+        /// <param name="chunk">Chunk of response</param>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool WriteResponseChunk(string chunk)
         {
-            bool result = Interop.WebHttpRequestInterceptor.AddResponseBody(SwigCPtr, body, length);
+            int length = 0;
+            if (chunk != null)
+            {
+                length = chunk.Length;
+            }
+            bool result = Interop.WebHttpRequestInterceptor.WriteResponseChunk(interceptorHandle, chunk, (uint)length);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return result;
         }
index f2506ae..51be8a5 100755 (executable)
@@ -76,9 +76,6 @@ namespace Tizen.NUI.BaseComponents
         private EventHandler<WebViewHttpAuthRequestedEventArgs> httpAuthRequestedEventHandler;
         private WebViewHttpAuthRequestedCallbackDelegate httpAuthRequestedCallback;
 
-        private EventHandler<WebViewHttpRequestInterceptedEventArgs> httpRequestInterceptedEventHandler;
-        private WebViewHttpRequestInterceptedCallbackDelegate httpRequestInterceptedCallback;
-
         private EventHandler<WebViewConsoleMessageReceivedEventArgs> consoleMessageReceivedEventHandler;
         private WebViewConsoleMessageReceivedCallbackDelegate consoleMessageReceivedCallback;
 
@@ -271,9 +268,6 @@ namespace Tizen.NUI.BaseComponents
         private delegate void WebViewHttpAuthRequestedCallbackDelegate(IntPtr handler);
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        private delegate void WebViewHttpRequestInterceptedCallbackDelegate(IntPtr interceptor);
-
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebViewConsoleMessageReceivedCallbackDelegate(IntPtr message);
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -513,29 +507,6 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Event for the HttpRequestIntercepted signal which can be used to subscribe or unsubscribe the event handler.<br />
-        /// This signal is emitted when http request would be intercepted.<br />
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public event EventHandler<WebViewHttpRequestInterceptedEventArgs> HttpRequestIntercepted
-        {
-            add
-            {
-                if (httpRequestInterceptedEventHandler == null)
-                {
-                    httpRequestInterceptedCallback = OnHttpRequestIntercepted;
-                    IntPtr ip = Marshal.GetFunctionPointerForDelegate(httpRequestInterceptedCallback);
-                    Interop.WebView.RegisterRequestInterceptorCallback(SwigCPtr, new HandleRef(this, ip));
-                }
-                httpRequestInterceptedEventHandler += value;
-            }
-            remove
-            {
-                httpRequestInterceptedEventHandler -= value;
-            }
-        }
-
-        /// <summary>
         /// Event for the SslCertificateChanged signal which can be used to subscribe or unsubscribe the event handler.<br />
         /// This signal is emitted when SSL certificate is changed.<br />
         /// </summary>
@@ -2062,11 +2033,6 @@ namespace Tizen.NUI.BaseComponents
             httpAuthRequestedEventHandler?.Invoke(this, new WebViewHttpAuthRequestedEventArgs(new WebHttpAuthHandler(handler, true)));
         }
 
-        private void OnHttpRequestIntercepted(IntPtr interceptor)
-        {
-            httpRequestInterceptedEventHandler?.Invoke(this, new WebViewHttpRequestInterceptedEventArgs(new WebHttpRequestInterceptor(interceptor, true)));
-        }
-
         private void OnConsoleMessageReceived(IntPtr message)
         {
             consoleMessageReceivedEventHandler?.Invoke(this, new WebViewConsoleMessageReceivedEventArgs(new WebConsoleMessage(message, true)));
diff --git a/src/Tizen.NUI/src/internal/WebView/WebViewHttpRequestInterceptedEventArgs.cs b/src/Tizen.NUI/src/internal/WebView/WebViewHttpRequestInterceptedEventArgs.cs
deleted file mode 100755 (executable)
index 80a967c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.ComponentModel;
-
-namespace Tizen.NUI
-{
-    /// <summary>
-    /// Event arguments that passed via the WebView.HttpRequestIntercepted.
-    /// </summary>
-    [EditorBrowsable(EditorBrowsableState.Never)]
-    public class WebViewHttpRequestInterceptedEventArgs : EventArgs
-    {
-        internal WebViewHttpRequestInterceptedEventArgs(WebHttpRequestInterceptor interceptor)
-        {
-            HttpRequestInterceptor = interceptor;
-        }
-
-        /// <summary>
-        /// The http request interceptor.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public WebHttpRequestInterceptor HttpRequestInterceptor { get; }
-    }
-}
index bfeea9f..31724d3 100755 (executable)
@@ -15,6 +15,7 @@
  *
  */
 using System;
+using System.Collections.Generic;
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
 
@@ -42,11 +43,11 @@ namespace Tizen.NUI.WebViewTest
                 LinearAlignment = LinearLayout.Alignment.Center
             };
 
-            buttons = new Button[menu.ItemList.ItemCount];
+            buttons = new Button[menu.ItemCount];
 
-            for (uint i = 0; i < menu.ItemList.ItemCount; i++)
+            for (uint i = 0; i < menu.ItemCount; i++)
             {
-                WebContextMenuItem item = menu.ItemList.GetItemAtIndex(i);
+                WebContextMenuItem item = menu.GetItemAtIndex(i);
                 buttons[i] = new Button()
                 {
                     Size = new Size(200, 80),
@@ -129,7 +130,7 @@ namespace Tizen.NUI.WebViewTest
 
         private int blueKeyPressedCount = 0;
         private int yellowKeyPressedCount = 0;
-        private int greenKeyPressedCount = 0;
+        private int redKeyPressedCount = 0;
 
         private static long startTime = 0;
 
@@ -372,11 +373,11 @@ namespace Tizen.NUI.WebViewTest
             e.HttpAuthHandler.UseCredential("", "");
         }
 
-        private void OnHttpRequestIntercepted(object sender, WebViewHttpRequestInterceptedEventArgs e)
+        private void OnHttpRequestIntercepted(WebHttpRequestInterceptor interceptor)
         {
-            Log.Info("WebView", $"------------http request intercepted, Url: {e.HttpRequestInterceptor.Url}-------");
+            Log.Info("WebView", $"------------http request intercepted, Url: {interceptor.Url}-------");
 
-            e.HttpRequestInterceptor.Ignore();
+            interceptor.Ignore();
 
             Log.Info("WebView", $"------------http request intercepted-------");
         }
@@ -466,10 +467,10 @@ namespace Tizen.NUI.WebViewTest
                 GetDefaultWindow().Add(menuView);
             }
 
-            Log.Info("WebView", $"------------context menu shown, ItemList ItemCount: {e.ContextMenu.ItemList.ItemCount}-------");
-            if (e.ContextMenu.ItemList.ItemCount > 0)
+            Log.Info("WebView", $"------------context menu shown, ItemList ItemCount: {e.ContextMenu.ItemCount}-------");
+            if (e.ContextMenu.ItemCount > 0)
             {
-                WebContextMenuItem item = e.ContextMenu.ItemList.GetItemAtIndex(0);
+                WebContextMenuItem item = e.ContextMenu.GetItemAtIndex(0);
                 Log.Info("WebView", $"------------context menu shown, Item Tag: {item.Tag}-------");
                 Log.Info("WebView", $"------------context menu shown, Item Type: {item.Type}-------");
                 Log.Info("WebView", $"------------context menu shown, Item IsEnabled: {item.IsEnabled}-------");
@@ -617,37 +618,37 @@ namespace Tizen.NUI.WebViewTest
             simpleWebView.JavaScriptPromptReply("test");
         }
 
-        private void OnPasswordDataListAcquired(WebPasswordDataList list)
+        private void OnPasswordDataListAcquired(IList<WebPasswordData> list)
         {
-            Log.Info("WebView", $"------------password data list, count: {list.ItemCount}-------");
-            string[] passwords = new string[list.ItemCount];
-            for (uint i = 0; i < list.ItemCount; i++)
+            Log.Info("WebView", $"------------password data list, count: {list.Count}-------");
+            string[] passwords = new string[list.Count];
+            for (int i = 0; i < list.Count; i++)
             {
-                WebPasswordData data = list.GetItemAtIndex(i);
+                WebPasswordData data = list[i];
                 passwords[i] = data.Url;
                 Log.Info("WebView", $"------------password data, Url: {data.Url}-------");
                 Log.Info("WebView", $"------------password data, FingerprintUsed: {data.FingerprintUsed}-------");
             }
 
-            if (list.ItemCount > 0)
+            if (list.Count > 0)
             {
                 simpleWebView.Context.DeleteFormPasswordDataList(passwords);
             }
         }
 
-        private void OnSecurityOriginListAcquired(WebSecurityOriginList list)
+        private void OnSecurityOriginListAcquired(IList<WebSecurityOrigin> list)
         {
-            Log.Info("WebView", $"------------security origin, count: {list.ItemCount}-------");
-            for (uint i = 0; i < list.ItemCount; i++)
+            Log.Info("WebView", $"------------security origin, count: {list.Count}-------");
+            for (int i = 0; i < list.Count; i++)
             {
-                WebSecurityOrigin origin = list.GetItemAtIndex(i);
+                WebSecurityOrigin origin = list[i];
                 Log.Info("WebView", $"------------security origin, Host: {origin.Host}-------");
                 Log.Info("WebView", $"------------security origin, Protocol: {origin.Protocol}-------");
             }
 
-            if (list.ItemCount > 0)
+            if (list.Count > 0)
             {
-                WebSecurityOrigin origin = list.GetItemAtIndex(0);
+                WebSecurityOrigin origin = list[0];
                 simpleWebView.Context.GetWebStorageUsageForOrigin(origin, OnStorageUsageAcquired);
                 simpleWebView.Context.DeleteApplicationCache(origin);
                 simpleWebView.Context.DeleteWebDatabase(origin);
@@ -725,8 +726,16 @@ namespace Tizen.NUI.WebViewTest
                 //}
                 else if (args.Key.KeyPressedName == "XF86Red")
                 {
-                    //simpleWebView.HttpRequestIntercepted += OnHttpRequestIntercepted;
-                    //simpleWebView.HttpRequestIntercepted -= OnHttpRequestIntercepted;
+                    if (redKeyPressedCount % 2 == 0)
+                    {
+                        simpleWebView.Context.RegisterHttpRequestInterceptedCallback(OnHttpRequestIntercepted);
+                        redKeyPressedCount = 0;
+                    }
+                    else
+                    {
+                        simpleWebView.Context.RegisterHttpRequestInterceptedCallback(null);
+                    }
+                    redKeyPressedCount++;
                     FocusManager.Instance.SetCurrentFocusView(addressBar);
                     result = true;
                 }
@@ -994,10 +1003,10 @@ namespace Tizen.NUI.WebViewTest
                             Log.Info("WebView", $"web back forward list, item0 url is {item.Url}");
                             Log.Info("WebView", $"web back forward list, item0 title is {item.Title}");
                             Log.Info("WebView", $"web back forward list, item0 original url is {item.OriginalUrl}");
-                            WebBackForwardSubList subList = simpleWebView.BackForwardList.GetForwardItems(0);
-                            Log.Info("WebView", $"web back forward list, forward sub list ItemCount is {subList.ItemCount}");
+                            IList<WebBackForwardListItem> subList = simpleWebView.BackForwardList.GetForwardItems(0);
+                            Log.Info("WebView", $"web back forward list, forward sub list ItemCount is {subList.Count}");
                             subList = simpleWebView.BackForwardList.GetBackwardItems(0);
-                            Log.Info("WebView", $"web back forward list, backward sub list  ItemCount is {subList.ItemCount}");
+                            Log.Info("WebView", $"web back forward list, backward sub list  ItemCount is {subList.Count}");
                         }
 
                         //