From fd4ca9be10c273af986ae120a99300bb4f3af000 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Tue, 14 May 2019 17:34:45 +0900 Subject: [PATCH] Implement WebView APIs (#823) Add Properties * CACHE_MODEL * COOKIE_ACCEPT_POLICY * USER_AGENT * JAVASCRIPT_ENABLED * LOAD_IMAGE_AUTOMATICALLY * DEFAULT_TEXT_ENCODING_NAME * DEFAULT_FONT_SIZE Add Signals * PageLoadErrorSignal Add Methods * Suspend * Resume * ClearCookies Signed-off-by: Jiyun Yang --- .../src/internal/Interop/Interop.WebView.cs | 88 ++- src/Tizen.NUI/src/internal/WebView.cs | 526 +++++++++++++----- .../internal/WebViewPageLoadErrorEventArgs.cs | 148 +++++ .../internal/WebViewPageLoadErrorSignal.cs | 115 ++++ .../src/internal/WebViewPageLoadEventArgs.cs | 64 +++ .../src/internal/WebViewPageLoadSignal.cs | 115 ++++ src/Tizen.NUI/src/public/NUIConstants.cs | 40 ++ 7 files changed, 945 insertions(+), 151 deletions(-) create mode 100644 src/Tizen.NUI/src/internal/WebViewPageLoadErrorEventArgs.cs create mode 100644 src/Tizen.NUI/src/internal/WebViewPageLoadErrorSignal.cs create mode 100644 src/Tizen.NUI/src/internal/WebViewPageLoadEventArgs.cs create mode 100644 src/Tizen.NUI/src/internal/WebViewPageLoadSignal.cs diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs index 868a2b815..e533e2621 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs @@ -34,13 +34,40 @@ namespace Tizen.NUI public static extern global::System.IntPtr WebView_DownCast(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_LoadUrl")] - public static extern void WebView_LoadUrl(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_URL_get")] + public static extern int WebView_Property_URL_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_CACHE_MODEL_get")] + public static extern int WebView_Property_CACHE_MODEL_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_COOKIE_ACCEPT_POLICY_get")] + public static extern int WebView_Property_COOKIE_ACCEPT_POLICY_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_USER_AGENT_get")] + public static extern int WebView_Property_USER_AGENT_get(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_ENABLE_JAVASCRIPT_get")] + public static extern int WebView_Property_ENABLE_JAVASCRIPT_get(); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetUrl")] - public static extern string WebView_GetUrl(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_LOAD_IMAGES_AUTOMATICALLY_get")] + public static extern int WebView_Property_LOAD_IMAGES_AUTOMATICALLY_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_DEFAULT_TEXT_ENCODING_NAME_get")] + public static extern int WebView_Property_DEFAULT_TEXT_ENCODING_NAME_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Property_DEFAULT_FONT_SIZE_get")] + public static extern int WebView_Property_DEFAULT_FONT_SIZE_get(); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_LoadUrl")] + public static extern void WebView_LoadUrl(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_LoadHTMLString")] @@ -55,6 +82,13 @@ namespace Tizen.NUI public static extern void WebView_StopLoading(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Suspend")] + public static extern void WebView_Suspend(global::System.Runtime.InteropServices.HandleRef jarg1); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Resume")] + public static extern void WebView_Resume(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GoBack")] public static extern void WebView_GoBack(global::System.Runtime.InteropServices.HandleRef jarg1); @@ -68,53 +102,67 @@ namespace Tizen.NUI public static extern bool WebView_CanGoBack(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_CanGoForward")] public static extern bool WebView_CanGoForward(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_EvaluateJavaScript")] - public static extern void WebView_EvaluateJavaScript(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); - + public static extern void WebView_EvaluateJavaScript(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_AddJavaScriptMessageHandler")] public static extern void WebView_AddJavaScriptMessageHandler(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_ClearHistory")] public static extern void WebView_ClearHistory(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_ClearCache")] public static extern void WebView_ClearCache(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_ClearCookies")] + public static extern void WebView_ClearCookies(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_SWIGUpcast")] public static extern global::System.IntPtr WebView_SWIGUpcast(global::System.IntPtr jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewSignalProxy_PageLoadStarted")] - public static extern global::System.IntPtr new_WebViewSignalProxy_PageLoadStarted(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewPageLoadSignal_PageLoadStarted")] + public static extern global::System.IntPtr new_WebViewPageLoadSignal_PageLoadStarted(global::System.Runtime.InteropServices.HandleRef jarg1); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewPageLoadSignal_PageLoadFinished")] + public static extern global::System.IntPtr new_WebViewPageLoadSignal_PageLoadFinished(global::System.Runtime.InteropServices.HandleRef jarg1); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebViewPageLoadSignal")] + public static extern void delete_WebViewPageLoadSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewPageLoadSignal_Connect")] + public static extern void WebViewPageLoadSignal_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewPageLoadSignal_Disconnect")] + public static extern void WebViewPageLoadSignal_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewSignalProxy_PageLoadFinished")] - public static extern global::System.IntPtr new_WebViewSignalProxy_PageLoadFinished(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebViewPageLoadErrorSignal_PageLoadError")] + public static extern global::System.IntPtr new_WebViewPageLoadErrorSignal_PageLoadError(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebViewSignalProxy")] - public static extern void delete_WebViewSignalProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WebViewPageLoadErrorSignal")] + public static extern void delete_WebViewPageLoadErrorSignal(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewSignalProxy_Connect")] - public static extern void WebViewSignalProxy_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewPageLoadErrorSignal_Connect")] + public static extern void WebViewPageLoadErrorSignal_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewSignalProxy_Disconnect")] - public static extern void WebViewSignalProxy_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebViewPageLoadErrorSignal_Disconnect")] + public static extern void WebViewPageLoadErrorSignal_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); } } diff --git a/src/Tizen.NUI/src/internal/WebView.cs b/src/Tizen.NUI/src/internal/WebView.cs index e03fd7937..652f7071d 100755 --- a/src/Tizen.NUI/src/internal/WebView.cs +++ b/src/Tizen.NUI/src/internal/WebView.cs @@ -20,6 +20,7 @@ using System.ComponentModel; using System.Collections.Generic; using System.Runtime.InteropServices; using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; namespace Tizen.NUI { @@ -30,29 +31,55 @@ namespace Tizen.NUI public class WebView : View { private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void WebViewPageLoadCallbackDelegate(IntPtr data, string pageUrl); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void WebViewPageLoadErrorCallbackDelegate(IntPtr data, string pageUrl, int errorCode); + + private readonly WebViewPageLoadSignal pageLoadStartedSignal; + private EventHandler pageLoadStartedEventHandler; + private WebViewPageLoadCallbackDelegate pageLoadStartedCallback; + + private readonly WebViewPageLoadSignal pageLoadFinishedSignal; + private EventHandler pageLoadFinishedEventHandler; + private WebViewPageLoadCallbackDelegate pageLoadFinishedCallback; + + private readonly WebViewPageLoadErrorSignal pageLoadErrorSignal; + private EventHandler pageLoadErrorEventHandler; + private WebViewPageLoadErrorCallbackDelegate pageLoadErrorCallback; + internal WebView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WebView.WebView_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - InitializeSignals(); + pageLoadStartedSignal = new WebViewPageLoadSignal(Interop.WebView.new_WebViewPageLoadSignal_PageLoadStarted(swigCPtr)); + pageLoadFinishedSignal = new WebViewPageLoadSignal(Interop.WebView.new_WebViewPageLoadSignal_PageLoadFinished(swigCPtr)); + pageLoadErrorSignal = new WebViewPageLoadErrorSignal(Interop.WebView.new_WebViewPageLoadErrorSignal_PageLoadError(swigCPtr)); } - private global::System.Runtime.InteropServices.HandleRef pageLoadStartedSignalProxy; - private global::System.Runtime.InteropServices.HandleRef pageLoadFinishedSignalProxy; - private void InitializeSignals() + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj) { - pageLoadStartedSignalProxy = new global::System.Runtime.InteropServices.HandleRef(this, Interop.WebView.new_WebViewSignalProxy_PageLoadStarted(swigCPtr)); - pageLoadFinishedSignalProxy = new global::System.Runtime.InteropServices.HandleRef(this, Interop.WebView.new_WebViewSignalProxy_PageLoadFinished(swigCPtr)); + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj) + internal WebView Assign(WebView webView) { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + WebView ret = new WebView(Interop.WebView.WebView_Assign(swigCPtr, WebView.getCPtr(webView)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } + internal static WebView DownCast(BaseHandle handle) + { + WebView ret = new WebView(Interop.WebView.WebView_DownCast(BaseHandle.getCPtr(handle)), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } /// - /// To make Button instance be disposed. + /// Dispose for IDisposable pattern /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void Dispose(DisposeTypes type) @@ -67,15 +94,15 @@ namespace Tizen.NUI //Called by User //Release your own managed resources here. //You should release all of your own disposable objects here. - + pageLoadStartedSignal.Dispose(); + pageLoadFinishedSignal.Dispose(); + pageLoadErrorSignal.Dispose(); } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. - DisposeSignals(); - if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) @@ -89,29 +116,202 @@ namespace Tizen.NUI base.Dispose(type); } - private void DisposeSignals() + private void OnPageLoadStarted(IntPtr data, string pageUrl) { - if (pageLoadStartedSignalProxy.Handle != global::System.IntPtr.Zero) + WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs(); + + e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView; + e.PageUrl = pageUrl; + + if (pageLoadStartedEventHandler != null) { - if (pageLoadStartedCallback != null) - { - WebViewProxyDisconnect(pageLoadStartedSignalProxy, pageLoadStartedCallback); - } - Interop.WebView.delete_WebViewSignalProxy(pageLoadStartedSignalProxy); - pageLoadStartedSignalProxy = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + pageLoadStartedEventHandler(this, e); } + } + + private void OnPageLoadFinished(IntPtr data, string pageUrl) + { + WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs(); - if (pageLoadFinishedSignalProxy.Handle != global::System.IntPtr.Zero) + e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView; + e.PageUrl = pageUrl; + + if (pageLoadFinishedEventHandler != null) { - if (pageLoadFinishedCallback != null) - { - WebViewProxyDisconnect(pageLoadFinishedSignalProxy, pageLoadFinishedCallback); - } - Interop.WebView.delete_WebViewSignalProxy(pageLoadFinishedSignalProxy); - pageLoadFinishedSignalProxy = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + pageLoadFinishedEventHandler(this, e); + } + } + + private void OnPageLoadError(IntPtr data, string pageUrl, int errorCode) + { + WebViewPageLoadErrorEventArgs e = new WebViewPageLoadErrorEventArgs(); + + e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView; + e.PageUrl = pageUrl; + e.ErrorCode = (WebViewPageLoadErrorEventArgs.LoadErrorCode)errorCode; + + if (pageLoadErrorEventHandler != null) + { + pageLoadErrorEventHandler(this, e); } } + internal static new class Property + { + internal static readonly int URL = Interop.WebView.WebView_Property_URL_get(); + internal static readonly int CACHE_MODEL = Interop.WebView.WebView_Property_CACHE_MODEL_get(); + internal static readonly int COOKIE_ACCEPT_POLICY = Interop.WebView.WebView_Property_COOKIE_ACCEPT_POLICY_get(); + internal static readonly int USER_AGENT = Interop.WebView.WebView_Property_USER_AGENT_get(); + internal static readonly int ENABLE_JAVASCRIPT = Interop.WebView.WebView_Property_ENABLE_JAVASCRIPT_get(); + internal static readonly int LOAD_IMAGES_AUTOMATICALLY = Interop.WebView.WebView_Property_LOAD_IMAGES_AUTOMATICALLY_get(); + internal static readonly int DEFAULT_TEXT_ENCODING_NAME = Interop.WebView.WebView_Property_DEFAULT_TEXT_ENCODING_NAME_get(); + internal static readonly int DEFAULT_FONT_SIZE = Interop.WebView.WebView_Property_DEFAULT_FONT_SIZE_get(); + } + + private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.URL, new Tizen.NUI.PropertyValue((string)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + string temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.URL).Get(out temp); + return temp; + }); + + private static readonly BindableProperty CacheModelProperty = BindableProperty.Create(nameof(CacheModel), typeof(CacheModel), typeof(WebView), CacheModel.DocumentViewer, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.CACHE_MODEL, new Tizen.NUI.PropertyValue((int)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + string temp; + if (Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.CACHE_MODEL).Get(out temp) == false) + { + NUILog.Error("CacheModel get error!"); + } + switch (temp) + { + case "DOCUMENT_VIEWER": return CacheModel.DocumentViewer; + case "DOCUMENT_BROWSER": return CacheModel.DocumentBrowser; + default: return CacheModel.PrimaryWebBrowser; + } + }); + + private static readonly BindableProperty CookieAcceptPolicyProperty = BindableProperty.Create(nameof(CookieAcceptPolicy), typeof(CookieAcceptPolicy), typeof(WebView), CookieAcceptPolicy.NoThirdParty, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.COOKIE_ACCEPT_POLICY, new Tizen.NUI.PropertyValue((int)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + string temp; + if (Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.COOKIE_ACCEPT_POLICY).Get(out temp) == false) + { + NUILog.Error("CookieAcceptPolicy get error!"); + } + switch (temp) + { + case "ALWAYS": return CookieAcceptPolicy.Always; + case "NEVER": return CookieAcceptPolicy.Never; + default: return CookieAcceptPolicy.NoThirdParty; + } + }); + + private static readonly BindableProperty UserAgentProperty = BindableProperty.Create(nameof(UserAgent), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.USER_AGENT, new Tizen.NUI.PropertyValue((string)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + string temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.USER_AGENT).Get(out temp); + return temp; + }); + + private static readonly BindableProperty EnableJavaScriptProperty = BindableProperty.Create(nameof(EnableJavaScript), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.ENABLE_JAVASCRIPT, new Tizen.NUI.PropertyValue((bool)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + bool temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.ENABLE_JAVASCRIPT).Get(out temp); + return temp; + }); + + private static readonly BindableProperty LoadImagesAutomaticallyProperty = BindableProperty.Create(nameof(LoadImagesAutomatically), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.LOAD_IMAGES_AUTOMATICALLY, new Tizen.NUI.PropertyValue((bool)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + bool temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.LOAD_IMAGES_AUTOMATICALLY).Get(out temp); + return temp; + }); + + private static readonly BindableProperty DefaultTextEncodingNameProperty = BindableProperty.Create(nameof(DefaultTextEncodingName), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.DEFAULT_TEXT_ENCODING_NAME, new Tizen.NUI.PropertyValue((string)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + string temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.DEFAULT_TEXT_ENCODING_NAME).Get(out temp); + return temp; + }); + + private static readonly BindableProperty DefaultFontSizeProperty = BindableProperty.Create(nameof(DefaultFontSize), typeof(int), typeof(WebView), 16, propertyChanged: (bindable, oldValue, newValue) => + { + var webview = (WebView)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.DEFAULT_FONT_SIZE, new Tizen.NUI.PropertyValue((int)newValue)); + } + }, + defaultValueCreator: (bindable) => + { + var webview = (WebView)bindable; + int temp; + Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.DEFAULT_FONT_SIZE).Get(out temp); + return temp; + }); + /// /// Creates an uninitialized WebView. /// @@ -143,98 +343,148 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal WebView Assign(WebView webView) + /// + /// The url to load. + /// + public string Url { - WebView ret = new WebView(Interop.WebView.WebView_Assign(swigCPtr, WebView.getCPtr(webView)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + get + { + return (string)GetValue(UrlProperty); + } + set + { + SetValue(UrlProperty, value); + NotifyPropertyChanged(); + } } - internal static WebView DownCast(BaseHandle handle) + /// + /// The cache model of the current WebView. + /// + public CacheModel CacheModel { - WebView ret = new WebView(Interop.WebView.WebView_DownCast(BaseHandle.getCPtr(handle)), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + get + { + return (CacheModel)GetValue(CacheModelProperty); + } + set + { + SetValue(CacheModelProperty, value); + NotifyPropertyChanged(); + } } /// - /// Event arguments that passed via the webview signal. + /// The cookie acceptance policy. /// - [EditorBrowsable(EditorBrowsableState.Never)] - public class WebViewEventArgs : EventArgs + public CookieAcceptPolicy CookieAcceptPolicy { - private WebView _webView; - /// - /// The view for displaying webpages. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public WebView WebView + get { - get - { - return _webView; - } - set - { - _webView = value; - } + return (CookieAcceptPolicy)GetValue(CookieAcceptPolicyProperty); } + set + { + SetValue(CookieAcceptPolicyProperty, value); + NotifyPropertyChanged(); + } + } - private string _pageUrl; - /// - /// The url string of current webpage. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string PageUrl + /// + /// The user agent string. + /// + public string UserAgent + { + get { - get - { - return _pageUrl; - } - set - { - _pageUrl = value; - } + return (string)GetValue(UserAgentProperty); + } + set + { + SetValue(UserAgentProperty, value); + NotifyPropertyChanged(); } } - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void WebViewCallbackDelegate(IntPtr data, string pageUrl); + /// + /// Whether JavaScript is enabled. + /// + public bool EnableJavaScript + { + get + { + return (bool)GetValue(EnableJavaScriptProperty); + } + set + { + SetValue(EnableJavaScriptProperty, value); + NotifyPropertyChanged(); + } + } - private void WebViewProxyConnect(global::System.Runtime.InteropServices.HandleRef proxy, System.Delegate func) + /// + /// Whether images can be loaded automatically. + /// + public bool LoadImagesAutomatically { - System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + get + { + return (bool)GetValue(LoadImagesAutomaticallyProperty); + } + set { - Interop.WebView.WebViewSignalProxy_Connect(proxy, new System.Runtime.InteropServices.HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + SetValue(LoadImagesAutomaticallyProperty, value); + NotifyPropertyChanged(); } } - private void WebViewProxyDisconnect(global::System.Runtime.InteropServices.HandleRef proxy, System.Delegate func) + /// + /// The default text encoding name.
+ /// e.g. "UTF-8"
+ ///
+ public string DefaultTextEncodingName { - System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + get + { + return (string)GetValue(DefaultTextEncodingNameProperty); + } + set { - Interop.WebView.WebViewSignalProxy_Disconnect(proxy, new System.Runtime.InteropServices.HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + SetValue(DefaultTextEncodingNameProperty, value); + NotifyPropertyChanged(); } } - private EventHandler pageLoadStartedEventHandler; - private WebViewCallbackDelegate pageLoadStartedCallback; + /// + /// The default font size in pixel. + /// + public int DefaultFontSize + { + get + { + return (int)GetValue(DefaultFontSizeProperty); + } + set + { + SetValue(DefaultFontSizeProperty, value); + NotifyPropertyChanged(); + } + } /// /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.
/// This signal is emitted when page loading has started.
///
[EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler PageLoadStarted + public event EventHandler PageLoadStarted { add { if (pageLoadStartedEventHandler == null) { pageLoadStartedCallback = (OnPageLoadStarted); - WebViewProxyConnect(pageLoadStartedSignalProxy, pageLoadStartedCallback); + pageLoadStartedSignal.Connect(pageLoadStartedCallback); } pageLoadStartedEventHandler += value; } @@ -243,40 +493,24 @@ namespace Tizen.NUI pageLoadStartedEventHandler -= value; if (pageLoadStartedEventHandler == null && pageLoadStartedCallback != null) { - WebViewProxyDisconnect(pageLoadStartedSignalProxy, pageLoadStartedCallback); + pageLoadStartedSignal.Disconnect(pageLoadStartedCallback); } } } - private void OnPageLoadStarted(IntPtr data, string pageUrl) - { - WebViewEventArgs e = new WebViewEventArgs(); - - e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView; - e.PageUrl = pageUrl; - - if (pageLoadStartedEventHandler != null) - { - pageLoadStartedEventHandler(this, e); - } - } - - private EventHandler pageLoadFinishedEventHandler; - private WebViewCallbackDelegate pageLoadFinishedCallback; - /// /// Event for the PageLoadFinished signal which can be used to subscribe or unsubscribe the event handler.
/// This signal is emitted when page loading has finished.
///
[EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler PageLoadFinished + public event EventHandler PageLoadFinished { add { if (pageLoadFinishedEventHandler == null) { pageLoadFinishedCallback = (OnPageLoadFinished); - WebViewProxyConnect(pageLoadFinishedSignalProxy, pageLoadFinishedCallback); + pageLoadFinishedSignal.Connect(pageLoadFinishedCallback); } pageLoadFinishedEventHandler += value; } @@ -285,21 +519,34 @@ namespace Tizen.NUI pageLoadFinishedEventHandler -= value; if (pageLoadFinishedEventHandler == null && pageLoadFinishedCallback != null) { - WebViewProxyDisconnect(pageLoadFinishedSignalProxy, pageLoadFinishedCallback); + pageLoadFinishedSignal.Disconnect(pageLoadFinishedCallback); } } } - private void OnPageLoadFinished(IntPtr data, string pageUrl) + /// + /// Event for the PageLoadError signal which can be used to subscribe or unsubscribe the event handler.
+ /// This signal is emitted when there's an error in page loading.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PageLoadError { - WebViewEventArgs e = new WebViewEventArgs(); - - e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView; - e.PageUrl = pageUrl; - - if (pageLoadFinishedEventHandler != null) + add { - pageLoadFinishedEventHandler(this, e); + if (pageLoadErrorEventHandler == null) + { + pageLoadErrorCallback = (OnPageLoadError); + pageLoadErrorSignal.Connect(pageLoadErrorCallback); + } + pageLoadErrorEventHandler += value; + } + remove + { + pageLoadErrorEventHandler -= value; + if (pageLoadErrorEventHandler == null && pageLoadErrorCallback != null) + { + pageLoadErrorSignal.Disconnect(pageLoadErrorCallback); + } } } @@ -314,18 +561,6 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - /// - /// Returns the URL of the Web - /// Url of string type - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string GetUrl() - { - string url = Interop.WebView.WebView_GetUrl(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return url; - } - /// /// Returns the URL of the Web /// The data of Web @@ -357,6 +592,26 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + /// + /// Suspends the operation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Suspend() + { + Interop.WebView.WebView_Suspend(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Resumes the operation after calling Suspend() + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Resume() + { + Interop.WebView.WebView_Resume(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + /// /// Goes to the back /// @@ -401,6 +656,13 @@ namespace Tizen.NUI return ret; } + /// + /// The callback function that is invoked when the message is received from the script. + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + [EditorBrowsable(EditorBrowsableState.Never)] + public delegate void JavaScriptMessageHandler(string message); + /// /// Evaluates JavaScript code represented as a string. /// The JavaScript code @@ -408,18 +670,10 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public void EvaluateJavaScript(string script) { - Interop.WebView.WebView_EvaluateJavaScript(swigCPtr, script); + Interop.WebView.WebView_EvaluateJavaScript(swigCPtr, script, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - /// - /// The callback function that is invoked when the message is received from the script. - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - [EditorBrowsable(EditorBrowsableState.Never)] - public delegate void JavaScriptMessageHandler(string message); - - // For rooting handlers internal Dictionary handlerRootMap = new Dictionary(); @@ -445,7 +699,7 @@ namespace Tizen.NUI } /// - /// Clears the history of Web. + /// Clears the history of current WebView. /// [EditorBrowsable(EditorBrowsableState.Never)] public void ClearHistory() @@ -455,7 +709,7 @@ namespace Tizen.NUI } /// - /// Clears the cache of Web. + /// Clears the cache of current WebView. /// [EditorBrowsable(EditorBrowsableState.Never)] public void ClearCache() @@ -463,5 +717,15 @@ namespace Tizen.NUI Interop.WebView.WebView_ClearCache(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + + /// + /// Clears all the cookies of current WebView. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ClearCookies() + { + Interop.WebView.WebView_ClearCookies(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } } } diff --git a/src/Tizen.NUI/src/internal/WebViewPageLoadErrorEventArgs.cs b/src/Tizen.NUI/src/internal/WebViewPageLoadErrorEventArgs.cs new file mode 100644 index 000000000..f335d8b28 --- /dev/null +++ b/src/Tizen.NUI/src/internal/WebViewPageLoadErrorEventArgs.cs @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2019 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 +{ + /// + /// Event arguments that passed via the WebView.PageLoadError. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class WebViewPageLoadErrorEventArgs : EventArgs + { + /// + /// Enumeration for the load error code + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum LoadErrorCode + { + /// + /// Unknown. + /// + Unknown, + /// + /// User canceled. + /// + Canceled, + /// + /// Can't show the page for this MIME type. + /// + CantSupportMimetype, + /// + /// File IO error. + /// + FailedFileIo, + /// + /// Cannot connect to the network. + /// + CantConnect, + /// + /// Fail to look up host from the DNS. + /// + CantLookupHost, + /// + /// Fail to SSL/TLS handshake. + /// + FailedTlsHandshake, + /// + /// Received certificate is invalid. + /// + InvalidCertificate, + /// + /// Connection timeout. + /// + RequestTimeout, + /// + /// Too many redirects. + /// + TooManyRedirects, + /// + /// Too many requests during this load. + /// + TooManyRequests, + /// + /// Malformed URL. + /// + BadUrl, + /// + /// Unsupported scheme. + /// + UnsupportedScheme, + /// + /// User authentication failed on the server. + /// + Authentication, + /// + /// Web server has an internal server error. + /// + InternalServer, + } + + private WebView _webView; + /// + /// The view for displaying webpages. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public WebView WebView + { + get + { + return _webView; + } + set + { + _webView = value; + } + } + + private string _pageUrl; + /// + /// The url string of current webpage. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public string PageUrl + { + get + { + return _pageUrl; + } + set + { + _pageUrl = value; + } + } + + private LoadErrorCode _errorCode; + /// + /// The code for the current error. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public LoadErrorCode ErrorCode + { + get + { + return _errorCode; + } + set + { + _errorCode = value; + } + } + } +} diff --git a/src/Tizen.NUI/src/internal/WebViewPageLoadErrorSignal.cs b/src/Tizen.NUI/src/internal/WebViewPageLoadErrorSignal.cs new file mode 100644 index 000000000..8903febab --- /dev/null +++ b/src/Tizen.NUI/src/internal/WebViewPageLoadErrorSignal.cs @@ -0,0 +1,115 @@ +/* + * Copyright(c) 2019 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 WebViewPageLoadErrorSignal : global::System.IDisposable + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebViewPageLoadErrorSignal obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + //A Flag to check who called Dispose(). (By User or DisposeQueue) + private bool isDisposeQueued; + //A Flat to check if it is already disposed. + protected bool disposed; + + ~WebViewPageLoadErrorSignal() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(false); + } + else + { + Dispose(true); + System.GC.SuppressFinalize(this); + } + } + + protected virtual void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + if (disposing) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + Interop.WebView.delete_WebViewPageLoadErrorSignal(swigCPtr); + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + disposed = true; + } + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + Interop.WebView.WebViewPageLoadErrorSignal_Connect(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(func); + { + Interop.WebView.WebViewPageLoadErrorSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) + { + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + } + + public WebViewPageLoadErrorSignal(global::System.IntPtr cPtr) + { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + } + +} diff --git a/src/Tizen.NUI/src/internal/WebViewPageLoadEventArgs.cs b/src/Tizen.NUI/src/internal/WebViewPageLoadEventArgs.cs new file mode 100644 index 000000000..0ebc7b2f5 --- /dev/null +++ b/src/Tizen.NUI/src/internal/WebViewPageLoadEventArgs.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 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 +{ + /// + /// Event arguments that passed via the WebView.PageLoadStarted or WebView.PageLoadFinished. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class WebViewPageLoadEventArgs : EventArgs + { + + private WebView _webView; + /// + /// The view for displaying webpages. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public WebView WebView + { + get + { + return _webView; + } + set + { + _webView = value; + } + } + + private string _pageUrl; + /// + /// The url string of current webpage. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public string PageUrl + { + get + { + return _pageUrl; + } + set + { + _pageUrl = value; + } + } + } +} diff --git a/src/Tizen.NUI/src/internal/WebViewPageLoadSignal.cs b/src/Tizen.NUI/src/internal/WebViewPageLoadSignal.cs new file mode 100644 index 000000000..f7da87fcb --- /dev/null +++ b/src/Tizen.NUI/src/internal/WebViewPageLoadSignal.cs @@ -0,0 +1,115 @@ +/* + * Copyright(c) 2019 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 WebViewPageLoadSignal : global::System.IDisposable + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebViewPageLoadSignal obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + //A Flag to check who called Dispose(). (By User or DisposeQueue) + private bool isDisposeQueued; + //A Flat to check if it is already disposed. + protected bool disposed; + + ~WebViewPageLoadSignal() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(false); + } + else + { + Dispose(true); + System.GC.SuppressFinalize(this); + } + } + + protected virtual void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + if (disposing) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + Interop.WebView.delete_WebViewPageLoadSignal(swigCPtr); + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + disposed = true; + } + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + Interop.WebView.WebViewPageLoadSignal_Connect(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(func); + { + Interop.WebView.WebViewPageLoadSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) + { + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + } + + public WebViewPageLoadSignal(global::System.IntPtr cPtr) + { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + } + +} diff --git a/src/Tizen.NUI/src/public/NUIConstants.cs b/src/Tizen.NUI/src/public/NUIConstants.cs index 542cdd7f2..9e2e0dec1 100755 --- a/src/Tizen.NUI/src/public/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/NUIConstants.cs @@ -2818,4 +2818,44 @@ namespace Tizen.NUI } } } + + /// + /// Enumeration for setting cache model of a WebView. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum CacheModel + { + /// + /// Use the smallest cache capacity. + /// + DocumentViewer, + /// + /// Use the bigger cache capacity than DocumentBrowser. + /// + DocumentBrowser, + /// + /// Use the biggest cache capacity. + /// + PrimaryWebBrowser + } + + /// + /// Enumeration for setting cache model of a WebView. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum CookieAcceptPolicy + { + /// + /// Accepts every cookie sent from any page. + /// + Always, + /// + /// Rejects all the cookies. + /// + Never, + /// + /// Accepts only cookies set by the main document that is loaded. + /// + NoThirdParty + } } -- 2.34.1