* [NUI] Implement APIs for form repost decision & frame rendered.
This patch is to implement APIs for form repost decision and frame
rendered off-screen.
And properties for enabling/disabling mouse or key events are
added.
* rename RepostDecision to RepostPolicyDecided
* rename WebFormRepostDecision to WebFormRepostPolicyDecisionMaker
* delate empty WebViewFrameRenderedEventArgs.
* remove some unused functions.
Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
--- /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 WebFormRepostPolicyDecisionMaker
+ {
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebFormRepostDecision_Reply")]
+ public static extern void Reply(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
+ }
+ }
+}
+
namespace Tizen.NUI
{
-
internal static partial class Interop
{
internal static partial class WebView
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_VIDEO_HOLE_ENABLED_get")]
public static extern int VideoHoleEnabledGet();
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_MOUSE_EVENTS_ENABLED_get")]
+ public static extern int MouseEventsEnabledGet();
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_KEY_EVENTS_ENABLED_get")]
+ public static extern int KeyEventsEnabledGet();
+
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetFavicon")]
public static extern global::System.IntPtr GetFavicon(global::System.Runtime.InteropServices.HandleRef jarg1);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewUrlChangedSignal_Disconnect")]
public static extern void WebViewUrlChangedSignalDisconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewFormRepostDecisionSignal_FormRepostDecision")]
+ public static extern global::System.IntPtr NewWebViewFormRepostDecisionSignalFormRepostDecision(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebViewFormRepostDecisionSignal")]
+ public static extern void DeleteWebViewFormRepostDecisionSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewFormRepostDecisionSignal_Connect")]
+ public static extern void WebViewFormRepostDecisionSignalConnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewFormRepostDecisionSignal_Disconnect")]
+ public static extern void WebViewFormRepostDecisionSignalDisconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewFrameRenderedSignal_FrameRendered")]
+ public static extern global::System.IntPtr WebViewFrameRenderedSignalFrameRenderedGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewFrameRenderedSignal_Connect")]
+ public static extern void WebViewFrameRenderedSignalConnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewFrameRenderedSignal_Disconnect")]
+ public static extern void WebViewFrameRenderedSignalDisconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
}
}
}
return new Uri(Interop.WebBackForwardListItem.GetOriginalUrl(SwigCPtr));
}
}
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebBackForwardListItem obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
}
/// <summary>
System.IntPtr itemPtr = Interop.WebBackForwardList.GetItemAtIndex(SwigCPtr, index);
return new WebBackForwardListItem(itemPtr, false);
}
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebBackForwardList obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
}
}
Interop.WebContext.ClearCache(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebContext obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
}
}
Interop.WebCookieManager.ClearCookies(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebCookieManager obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
}
}
--- /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>
+ /// It is a class for form repost policy decision maker of web view.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class WebFormRepostPolicyDecisionMaker : Disposable
+ {
+ internal WebFormRepostPolicyDecisionMaker(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ /// <summary>
+ /// Reply whether form repost decision is allowed or not.
+ /// <param name="allowed">allowed or not</param>
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Reply(bool allowed)
+ {
+ Interop.WebFormRepostPolicyDecisionMaker.Reply(SwigCPtr, allowed);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+}
Interop.WebSettings.SetDefaultTextEncodingName(SwigCPtr, value);
}
}
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebSettings obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
}
}
private EventHandler<WebViewUrlChangedEventArgs> urlChangedEventHandler;
private WebViewUrlChangedCallbackDelegate urlChangedCallback;
+ private readonly WebViewFormRepostDecidedSignal formRepostPolicyDecidedSignal;
+ private EventHandler<WebViewFormRepostPolicyDecidedEventArgs> formRepostPolicyDecidedEventHandler;
+ private WebViewFormRepostPolicyDecidedCallbackDelegate formRepostPolicyDecidedCallback;
+
+ private readonly WebViewFrameRenderedSignal frameRenderedSignal;
+ private EventHandler<EventArgs> frameRenderedEventHandler;
+ private WebViewFrameRenderedCallbackDelegate frameRenderedCallback;
+
/// <summary>
/// Creates a WebView.
/// </summary>
pageLoadErrorSignal = new WebViewPageLoadErrorSignal(Interop.WebView.NewWebViewPageLoadErrorSignalPageLoadError(SwigCPtr));
scrollEdgeReachedSignal = new WebViewScrollEdgeReachedSignal(Interop.WebView.NewWebViewScrollEdgeReachedSignalScrollEdgeReached(SwigCPtr));
urlChangedSignal = new WebViewUrlChangedSignal(Interop.WebView.NewWebViewUrlChangedSignalUrlChanged(SwigCPtr));
+ formRepostPolicyDecidedSignal = new WebViewFormRepostDecidedSignal(Interop.WebView.NewWebViewFormRepostDecisionSignalFormRepostDecision(SwigCPtr));
+ frameRenderedSignal = new WebViewFrameRenderedSignal(Interop.WebView.WebViewFrameRenderedSignalFrameRenderedGet(SwigCPtr));
BackForwardList = new WebBackForwardList(Interop.WebView.GetWebBackForwardList(SwigCPtr), false);
Context = new WebContext(Interop.WebView.GetWebContext(SwigCPtr), false);
pageLoadErrorSignal.Dispose();
scrollEdgeReachedSignal.Dispose();
urlChangedSignal.Dispose();
+ formRepostPolicyDecidedSignal.Dispose();
+ frameRenderedSignal.Dispose();
BackForwardList.Dispose();
Context.Dispose();
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void WebViewUrlChangedCallbackDelegate(IntPtr data, string pageUrl);
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void WebViewFormRepostPolicyDecidedCallbackDelegate(IntPtr data, IntPtr decision);
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void WebViewFrameRenderedCallbackDelegate(IntPtr data);
+
/// <summary>
/// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
/// This signal is emitted when page loading has started.<br />
}
/// <summary>
+ /// Event for the FormRepostDecided signal which can be used to subscribe or unsubscribe the event handler.<br />
+ /// This signal is emitted when form repost policy would be decided.<br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<WebViewFormRepostPolicyDecidedEventArgs> FormRepostPolicyDecided
+ {
+ add
+ {
+ if (formRepostPolicyDecidedEventHandler == null)
+ {
+ formRepostPolicyDecidedCallback = OnFormRepostPolicyDecided;
+ formRepostPolicyDecidedSignal.Connect(formRepostPolicyDecidedCallback);
+ }
+ formRepostPolicyDecidedEventHandler += value;
+ }
+ remove
+ {
+ formRepostPolicyDecidedEventHandler -= value;
+ if (formRepostPolicyDecidedEventHandler == null && formRepostPolicyDecidedCallback != null)
+ {
+ formRepostPolicyDecidedSignal.Disconnect(formRepostPolicyDecidedCallback);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Event for the FrameRendered signal which can be used to subscribe or unsubscribe the event handler.<br />
+ /// This signal is emitted when frame is rendered off-screen.<br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<EventArgs> FrameRendered
+ {
+ add
+ {
+ if (frameRenderedEventHandler == null)
+ {
+ frameRenderedCallback = OnFrameRendered;
+ frameRenderedSignal.Connect(frameRenderedCallback);
+ }
+ frameRenderedEventHandler += value;
+ }
+ remove
+ {
+ frameRenderedEventHandler -= value;
+ if (frameRenderedEventHandler == null && frameRenderedCallback != null)
+ {
+ frameRenderedSignal.Disconnect(frameRenderedCallback);
+ }
+ }
+ }
+
+ /// <summary>
/// BackForwardList.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
}
/// <summary>
+ /// Whether mouse events are enabled or not.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool MouseEventsEnabled
+ {
+ get
+ {
+ return (bool)GetValue(MouseEventsEnabledProperty);
+ }
+ set
+ {
+ SetValue(MouseEventsEnabledProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ /// <summary>
+ /// Whether key events are enabled or not.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool KeyEventsEnabled
+ {
+ get
+ {
+ return (bool)GetValue(KeyEventsEnabledProperty);
+ }
+ set
+ {
+ SetValue(KeyEventsEnabledProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ /// <summary>
/// Gets title of web page.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
internal static readonly int ContentSize = Interop.WebView.ContentSizeGet();
internal static readonly int Title = Interop.WebView.TitleGet();
internal static readonly int VideoHoleEnabled = Interop.WebView.VideoHoleEnabledGet();
+ internal static readonly int MouseEventsEnabled = Interop.WebView.MouseEventsEnabledGet();
+ internal static readonly int KeyEventsEnabled = Interop.WebView.KeyEventsEnabledGet();
}
private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
return temp;
});
+ private static readonly BindableProperty MouseEventsEnabledProperty = BindableProperty.Create(nameof(MouseEventsEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var webview = (WebView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.MouseEventsEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var webview = (WebView)bindable;
+ bool temp;
+ Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.MouseEventsEnabled).Get(out temp);
+ return temp;
+ });
+
+ private static readonly BindableProperty KeyEventsEnabledProperty = BindableProperty.Create(nameof(KeyEventsEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var webview = (WebView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.KeyEventsEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var webview = (WebView)bindable;
+ bool temp;
+ Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.KeyEventsEnabled).Get(out temp);
+ return temp;
+ });
+
// For rooting handlers
internal Dictionary<string, JavaScriptMessageHandler> handlerRootMap = new Dictionary<string, JavaScriptMessageHandler>();
{
urlChangedEventHandler?.Invoke(this, new WebViewUrlChangedEventArgs(pageUrl));
}
+
+ private void OnFormRepostPolicyDecided(IntPtr data, IntPtr decision)
+ {
+ WebFormRepostPolicyDecisionMaker repostDecision = new WebFormRepostPolicyDecisionMaker(decision, false);
+ formRepostPolicyDecidedEventHandler?.Invoke(this, new WebViewFormRepostPolicyDecidedEventArgs(repostDecision));
+ repostDecision.Dispose();
+ }
+
+ private void OnFrameRendered(IntPtr data)
+ {
+ frameRenderedEventHandler?.Invoke(this, new EventArgs());
+ }
}
}
--- /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.WebFormRepostDecision.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class WebViewFormRepostPolicyDecidedEventArgs : EventArgs
+ {
+ internal WebViewFormRepostPolicyDecidedEventArgs(WebFormRepostPolicyDecisionMaker maker)
+ {
+ FormRepostPolicyDecisionMaker = maker;
+ }
+
+ /// <summary>
+ /// The form repost decision.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public WebFormRepostPolicyDecisionMaker FormRepostPolicyDecisionMaker { get; }
+ }
+}
--- /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 class WebViewFormRepostDecidedSignal : Disposable
+ {
+ public WebViewFormRepostDecidedSignal(global::System.IntPtr cPtr) : base(cPtr, true)
+ {
+ }
+
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ Interop.WebView.DeleteWebViewFormRepostDecisionSignal(swigCPtr);
+ }
+
+ public void Connect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ Interop.WebView.WebViewFormRepostDecisionSignalConnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ {
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+ }
+
+ public void Disconnect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
+ {
+ Interop.WebView.WebViewFormRepostDecisionSignalDisconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ {
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+ }
+ }
+}
--- /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 class WebViewFrameRenderedSignal : Disposable
+ {
+ public WebViewFrameRenderedSignal(global::System.IntPtr cPtr) : base(cPtr, false)
+ {
+ }
+
+ public void Connect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ Interop.WebView.WebViewFrameRenderedSignalConnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ {
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+ }
+
+ public void Disconnect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
+ {
+ Interop.WebView.WebViewFrameRenderedSignalDisconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ {
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+ }
+ }
+}