[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);
{
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);
[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);
}
}
}
[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);
--- /dev/null
+/*
+ * 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);
+ }
+ }
+}
forwardItemList.Dispose();
}
}
-
base.Dispose(type);
}
}
}
}
+
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>
{
securityOriginList.Dispose();
}
+ if (httpRequestInterceptor != null)
+ {
+ httpRequestInterceptor.Dispose();
+ }
}
base.Dispose(type);
[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>
}
/// <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>
}
passwordDataListAcquiredCallback?.Invoke(passwordDataList);
}
+
+ private void OnHttpRequestIntercepted(IntPtr interceptor)
+ {
+ if (httpRequestInterceptor != null)
+ {
+ httpRequestInterceptor.Dispose();
+ }
+ httpRequestInterceptor = new WebHttpRequestInterceptor(interceptor, true);
+ httpRequestInterceptedCallback?.Invoke(httpRequestInterceptor);
+ }
}
}
-/*
+/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
using System;
+using System.Collections.Generic;
using System.ComponentModel;
+using System.Runtime.InteropServices;
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.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
- Interop.WebHttpRequestInterceptor.DeleteWebHttpRequestInterceptor(swigCPtr);
+ Interop.WebHttpRequestInterceptorPtr.DeleteWebHttpRequestInterceptorPtr(swigCPtr);
}
/// <summary>
{
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;
}
private EventHandler<WebViewHttpAuthRequestedEventArgs> httpAuthRequestedEventHandler;
private WebViewHttpAuthRequestedCallbackDelegate httpAuthRequestedCallback;
- private EventHandler<WebViewHttpRequestInterceptedEventArgs> httpRequestInterceptedEventHandler;
- private WebViewHttpRequestInterceptedCallbackDelegate httpRequestInterceptedCallback;
-
private EventHandler<WebViewConsoleMessageReceivedEventArgs> consoleMessageReceivedEventHandler;
private WebViewConsoleMessageReceivedCallbackDelegate consoleMessageReceivedCallback;
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)]
}
/// <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>
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)));
+++ /dev/null
-/*
- * 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; }
- }
-}
*
*/
using System;
+using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
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),
private int blueKeyPressedCount = 0;
private int yellowKeyPressedCount = 0;
- private int greenKeyPressedCount = 0;
+ private int redKeyPressedCount = 0;
private static long startTime = 0;
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-------");
}
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}-------");
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);
//}
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;
}
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}");
}
//