2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using System.Collections.Generic;
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Binding;
30 [EditorBrowsable(EditorBrowsableState.Never)]
31 public class WebView : View
33 private readonly WebViewPageLoadSignal pageLoadStartedSignal;
34 private EventHandler<WebViewPageLoadEventArgs> pageLoadStartedEventHandler;
35 private WebViewPageLoadCallbackDelegate pageLoadStartedCallback;
37 private readonly WebViewPageLoadSignal pageLoadingSignal;
38 private EventHandler<WebViewPageLoadEventArgs> pageLoadingEventHandler;
39 private WebViewPageLoadCallbackDelegate pageLoadingCallback;
41 private readonly WebViewPageLoadSignal pageLoadFinishedSignal;
42 private EventHandler<WebViewPageLoadEventArgs> pageLoadFinishedEventHandler;
43 private WebViewPageLoadCallbackDelegate pageLoadFinishedCallback;
45 private readonly WebViewPageLoadErrorSignal pageLoadErrorSignal;
46 private EventHandler<WebViewPageLoadErrorEventArgs> pageLoadErrorEventHandler;
47 private WebViewPageLoadErrorCallbackDelegate pageLoadErrorCallback;
49 private readonly WebViewScrollEdgeReachedSignal scrollEdgeReachedSignal;
50 private EventHandler<WebViewScrollEdgeReachedEventArgs> scrollEdgeReachedEventHandler;
51 private WebViewScrollEdgeReachedCallbackDelegate scrollEdgeReachedCallback;
53 private readonly WebViewUrlChangedSignal urlChangedSignal;
54 private EventHandler<WebViewUrlChangedEventArgs> urlChangedEventHandler;
55 private WebViewUrlChangedCallbackDelegate urlChangedCallback;
57 private readonly WebViewFormRepostDecidedSignal formRepostPolicyDecidedSignal;
58 private EventHandler<WebViewFormRepostPolicyDecidedEventArgs> formRepostPolicyDecidedEventHandler;
59 private WebViewFormRepostPolicyDecidedCallbackDelegate formRepostPolicyDecidedCallback;
61 private readonly WebViewFrameRenderedSignal frameRenderedSignal;
62 private EventHandler<EventArgs> frameRenderedEventHandler;
63 private WebViewFrameRenderedCallbackDelegate frameRenderedCallback;
66 /// Creates a WebView.
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public WebView() : this(Interop.WebView.New(), true)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
75 /// Creates a WebView with local language and time zone.
76 /// <param name="locale">The locale language of Web</param>
77 /// <param name="timezoneId">The time zone Id of Web</param>
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public WebView(string locale, string timezoneId) : this(Interop.WebView.New2(locale, timezoneId), true)
82 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86 /// Creates a WebView with an args list.
87 /// <param name="args">args array. The first value of array must be program's name.</param>
89 [EditorBrowsable(EditorBrowsableState.Never)]
90 public WebView(string[] args) : this(Interop.WebView.New3(args?.Length ?? 0, args), true)
92 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 /// <param name="webView">WebView to copy. The copied WebView will point at the same implementation</param>
99 [EditorBrowsable(EditorBrowsableState.Never)]
100 public WebView(WebView webView) : this(Interop.WebView.NewWebView(WebView.getCPtr(webView)), true)
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 internal WebView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WebView.Upcast(cPtr), cMemoryOwn)
107 pageLoadStartedSignal = new WebViewPageLoadSignal(Interop.WebView.NewWebViewPageLoadSignalPageLoadStarted(SwigCPtr));
108 pageLoadingSignal = new WebViewPageLoadSignal(Interop.WebView.NewWebViewPageLoadSignalPageLoadInProgress(SwigCPtr));
109 pageLoadFinishedSignal = new WebViewPageLoadSignal(Interop.WebView.NewWebViewPageLoadSignalPageLoadFinished(SwigCPtr));
110 pageLoadErrorSignal = new WebViewPageLoadErrorSignal(Interop.WebView.NewWebViewPageLoadErrorSignalPageLoadError(SwigCPtr));
111 scrollEdgeReachedSignal = new WebViewScrollEdgeReachedSignal(Interop.WebView.NewWebViewScrollEdgeReachedSignalScrollEdgeReached(SwigCPtr));
112 urlChangedSignal = new WebViewUrlChangedSignal(Interop.WebView.NewWebViewUrlChangedSignalUrlChanged(SwigCPtr));
113 formRepostPolicyDecidedSignal = new WebViewFormRepostDecidedSignal(Interop.WebView.NewWebViewFormRepostDecisionSignalFormRepostDecision(SwigCPtr));
114 frameRenderedSignal = new WebViewFrameRenderedSignal(Interop.WebView.WebViewFrameRenderedSignalFrameRenderedGet(SwigCPtr));
116 BackForwardList = new WebBackForwardList(Interop.WebView.GetWebBackForwardList(SwigCPtr), false);
117 Context = new WebContext(Interop.WebView.GetWebContext(SwigCPtr), false);
118 CookieManager = new WebCookieManager(Interop.WebView.GetWebCookieManager(SwigCPtr), false);
119 Settings = new WebSettings(Interop.WebView.GetWebSettings(SwigCPtr), false);
123 /// Dispose for IDisposable pattern
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 protected override void Dispose(DisposeTypes type)
133 if (type == DisposeTypes.Explicit)
136 //Release your own managed resources here.
137 //You should release all of your own disposable objects here.
138 pageLoadStartedSignal.Dispose();
139 pageLoadingSignal.Dispose();
140 pageLoadFinishedSignal.Dispose();
141 pageLoadErrorSignal.Dispose();
142 scrollEdgeReachedSignal.Dispose();
143 urlChangedSignal.Dispose();
144 formRepostPolicyDecidedSignal.Dispose();
145 frameRenderedSignal.Dispose();
147 BackForwardList.Dispose();
149 CookieManager.Dispose();
157 /// The callback function that is invoked when the message is received from the script.
159 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
160 [EditorBrowsable(EditorBrowsableState.Never)]
161 public delegate void JavaScriptMessageHandler(string message);
164 /// The callback function that is invoked when the message is received from the script.
166 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
167 [EditorBrowsable(EditorBrowsableState.Never)]
168 public delegate void JavaScriptAlertCallback(string message);
171 /// The callback function that is invoked when the message is received from the script.
173 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
174 [EditorBrowsable(EditorBrowsableState.Never)]
175 public delegate void JavaScriptConfirmCallback(string message);
178 /// The callback function that is invoked when the message is received from the script.
180 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
181 [EditorBrowsable(EditorBrowsableState.Never)]
182 public delegate void JavaScriptPromptCallback(string message1, string message2);
184 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
185 private delegate void WebViewPageLoadCallbackDelegate(IntPtr data, string pageUrl);
187 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
188 private delegate void WebViewPageLoadErrorCallbackDelegate(IntPtr data, string pageUrl, int errorCode);
190 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
191 private delegate void WebViewScrollEdgeReachedCallbackDelegate(IntPtr data, int edge);
193 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
194 private delegate void WebViewUrlChangedCallbackDelegate(IntPtr data, string pageUrl);
196 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
197 private delegate void WebViewFormRepostPolicyDecidedCallbackDelegate(IntPtr data, IntPtr decision);
199 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
200 private delegate void WebViewFrameRenderedCallbackDelegate(IntPtr data);
203 /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
204 /// This signal is emitted when page loading has started.<br />
206 [EditorBrowsable(EditorBrowsableState.Never)]
207 public event EventHandler<WebViewPageLoadEventArgs> PageLoadStarted
211 if (pageLoadStartedEventHandler == null)
213 pageLoadStartedCallback = (OnPageLoadStarted);
214 pageLoadStartedSignal.Connect(pageLoadStartedCallback);
216 pageLoadStartedEventHandler += value;
220 pageLoadStartedEventHandler -= value;
221 if (pageLoadStartedEventHandler == null && pageLoadStartedCallback != null)
223 pageLoadStartedSignal.Disconnect(pageLoadStartedCallback);
229 /// Event for the PageLoading signal which can be used to subscribe or unsubscribe the event handler.<br />
230 /// This signal is emitted when page loading is in progress.<br />
232 [EditorBrowsable(EditorBrowsableState.Never)]
233 public event EventHandler<WebViewPageLoadEventArgs> PageLoading
237 if (pageLoadingEventHandler == null)
239 pageLoadingCallback = OnPageLoading;
240 pageLoadingSignal.Connect(pageLoadingCallback);
242 pageLoadingEventHandler += value;
246 pageLoadingEventHandler -= value;
247 if (pageLoadingEventHandler == null && pageLoadingCallback != null)
249 pageLoadingSignal.Disconnect(pageLoadingCallback);
255 /// Event for the PageLoadFinished signal which can be used to subscribe or unsubscribe the event handler.<br />
256 /// This signal is emitted when page loading has finished.<br />
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public event EventHandler<WebViewPageLoadEventArgs> PageLoadFinished
263 if (pageLoadFinishedEventHandler == null)
265 pageLoadFinishedCallback = (OnPageLoadFinished);
266 pageLoadFinishedSignal.Connect(pageLoadFinishedCallback);
268 pageLoadFinishedEventHandler += value;
272 pageLoadFinishedEventHandler -= value;
273 if (pageLoadFinishedEventHandler == null && pageLoadFinishedCallback != null)
275 pageLoadFinishedSignal.Disconnect(pageLoadFinishedCallback);
281 /// Event for the PageLoadError signal which can be used to subscribe or unsubscribe the event handler.<br />
282 /// This signal is emitted when there's an error in page loading.<br />
284 [EditorBrowsable(EditorBrowsableState.Never)]
285 public event EventHandler<WebViewPageLoadErrorEventArgs> PageLoadError
289 if (pageLoadErrorEventHandler == null)
291 pageLoadErrorCallback = (OnPageLoadError);
292 pageLoadErrorSignal.Connect(pageLoadErrorCallback);
294 pageLoadErrorEventHandler += value;
298 pageLoadErrorEventHandler -= value;
299 if (pageLoadErrorEventHandler == null && pageLoadErrorCallback != null)
301 pageLoadErrorSignal.Disconnect(pageLoadErrorCallback);
307 /// Event for the ScrollEdgeReached signal which can be used to subscribe or unsubscribe the event handler.<br />
308 /// This signal is emitted when web view is scrolled to edge.<br />
310 [EditorBrowsable(EditorBrowsableState.Never)]
311 public event EventHandler<WebViewScrollEdgeReachedEventArgs> ScrollEdgeReached
315 if (scrollEdgeReachedEventHandler == null)
317 scrollEdgeReachedCallback = OnScrollEdgeReached;
318 scrollEdgeReachedSignal.Connect(scrollEdgeReachedCallback);
320 scrollEdgeReachedEventHandler += value;
324 scrollEdgeReachedEventHandler -= value;
325 if (scrollEdgeReachedEventHandler == null && scrollEdgeReachedCallback != null)
327 scrollEdgeReachedSignal.Disconnect(scrollEdgeReachedCallback);
333 /// Event for the UrlChanged signal which can be used to subscribe or unsubscribe the event handler.<br />
334 /// This signal is emitted when url is changed.<br />
336 [EditorBrowsable(EditorBrowsableState.Never)]
337 public event EventHandler<WebViewUrlChangedEventArgs> UrlChanged
341 if (urlChangedEventHandler == null)
343 urlChangedCallback = OnUrlChanged;
344 urlChangedSignal.Connect(urlChangedCallback);
346 urlChangedEventHandler += value;
350 urlChangedEventHandler -= value;
351 if (urlChangedEventHandler == null && urlChangedCallback != null)
353 urlChangedSignal.Disconnect(urlChangedCallback);
359 /// Event for the FormRepostDecided signal which can be used to subscribe or unsubscribe the event handler.<br />
360 /// This signal is emitted when form repost policy would be decided.<br />
362 [EditorBrowsable(EditorBrowsableState.Never)]
363 public event EventHandler<WebViewFormRepostPolicyDecidedEventArgs> FormRepostPolicyDecided
367 if (formRepostPolicyDecidedEventHandler == null)
369 formRepostPolicyDecidedCallback = OnFormRepostPolicyDecided;
370 formRepostPolicyDecidedSignal.Connect(formRepostPolicyDecidedCallback);
372 formRepostPolicyDecidedEventHandler += value;
376 formRepostPolicyDecidedEventHandler -= value;
377 if (formRepostPolicyDecidedEventHandler == null && formRepostPolicyDecidedCallback != null)
379 formRepostPolicyDecidedSignal.Disconnect(formRepostPolicyDecidedCallback);
385 /// Event for the FrameRendered signal which can be used to subscribe or unsubscribe the event handler.<br />
386 /// This signal is emitted when frame is rendered off-screen.<br />
388 [EditorBrowsable(EditorBrowsableState.Never)]
389 public event EventHandler<EventArgs> FrameRendered
393 if (frameRenderedEventHandler == null)
395 frameRenderedCallback = OnFrameRendered;
396 frameRenderedSignal.Connect(frameRenderedCallback);
398 frameRenderedEventHandler += value;
402 frameRenderedEventHandler -= value;
403 if (frameRenderedEventHandler == null && frameRenderedCallback != null)
405 frameRenderedSignal.Disconnect(frameRenderedCallback);
413 [EditorBrowsable(EditorBrowsableState.Never)]
414 public WebBackForwardList BackForwardList { get; }
419 [EditorBrowsable(EditorBrowsableState.Never)]
420 public WebContext Context { get; }
425 [EditorBrowsable(EditorBrowsableState.Never)]
426 public WebCookieManager CookieManager { get; }
431 [EditorBrowsable(EditorBrowsableState.Never)]
432 public WebSettings Settings { get; }
437 [EditorBrowsable(EditorBrowsableState.Never)]
442 return (string)GetValue(UrlProperty);
446 SetValue(UrlProperty, value);
447 NotifyPropertyChanged();
452 /// Deprecated. The cache model of the current WebView.
454 [EditorBrowsable(EditorBrowsableState.Never)]
455 public CacheModel CacheModel
459 return (CacheModel)Context.CacheModel;
463 Context.CacheModel = (WebContext.CacheModelType)value;
468 /// Deprecated. The cookie acceptance policy.
470 [EditorBrowsable(EditorBrowsableState.Never)]
471 public CookieAcceptPolicy CookieAcceptPolicy
475 return (CookieAcceptPolicy)CookieManager.CookieAcceptPolicy;
479 CookieManager.CookieAcceptPolicy = (WebCookieManager.CookieAcceptPolicyType)value;
484 /// The user agent string.
486 [EditorBrowsable(EditorBrowsableState.Never)]
487 public string UserAgent
491 return (string)GetValue(UserAgentProperty);
495 SetValue(UserAgentProperty, value);
496 NotifyPropertyChanged();
501 /// Deprecated. Whether JavaScript is enabled.
503 [EditorBrowsable(EditorBrowsableState.Never)]
504 public bool EnableJavaScript
508 return Settings.EnableJavaScript;
512 Settings.EnableJavaScript = value;
517 /// Deprecated. Whether images can be loaded automatically.
519 [EditorBrowsable(EditorBrowsableState.Never)]
520 public bool LoadImagesAutomatically
524 return Settings.AllowImagesLoadAutomatically;
528 Settings.AllowImagesLoadAutomatically = value;
533 /// The default text encoding name.<br />
534 /// e.g. "UTF-8"<br />
536 [EditorBrowsable(EditorBrowsableState.Never)]
537 public string DefaultTextEncodingName
541 return Settings.DefaultTextEncodingName;
545 Settings.DefaultTextEncodingName = value;
550 /// The default font size in pixel.
552 [EditorBrowsable(EditorBrowsableState.Never)]
553 public int DefaultFontSize
557 return Settings.DefaultFontSize;
561 Settings.DefaultFontSize = value;
566 /// The position of scroll.
568 [EditorBrowsable(EditorBrowsableState.Never)]
569 public Position ScrollPosition
573 Vector2 pv = (Vector2)GetValue(ScrollPositionProperty);
574 return new Position(pv.X, pv.Y);
581 Vector2 vpv = new Vector2(pv.X, pv.Y);
582 SetValue(ScrollPositionProperty, vpv);
583 NotifyPropertyChanged();
589 /// The size of scroll, read-only.
591 [EditorBrowsable(EditorBrowsableState.Never)]
592 public Size ScrollSize
596 Vector2 sv = (Vector2)GetValue(ScrollSizeProperty);
597 return new Size(sv.Width, sv.Height);
602 /// The size of content, read-only.
604 [EditorBrowsable(EditorBrowsableState.Never)]
605 public Size ContentSize
609 Vector2 sv = (Vector2)GetValue(ContentSizeProperty);
610 return new Size(sv.Width, sv.Height);
615 /// Whether video hole is enabled or not.
617 [EditorBrowsable(EditorBrowsableState.Never)]
618 public bool VideoHoleEnabled
622 return (bool)GetValue(VideoHoleEnabledProperty);
626 SetValue(VideoHoleEnabledProperty, value);
627 NotifyPropertyChanged();
632 /// Whether mouse events are enabled or not.
634 [EditorBrowsable(EditorBrowsableState.Never)]
635 public bool MouseEventsEnabled
639 return (bool)GetValue(MouseEventsEnabledProperty);
643 SetValue(MouseEventsEnabledProperty, value);
644 NotifyPropertyChanged();
649 /// Whether key events are enabled or not.
651 [EditorBrowsable(EditorBrowsableState.Never)]
652 public bool KeyEventsEnabled
656 return (bool)GetValue(KeyEventsEnabledProperty);
660 SetValue(KeyEventsEnabledProperty, value);
661 NotifyPropertyChanged();
666 /// Gets title of web page.
668 [EditorBrowsable(EditorBrowsableState.Never)]
673 return (string)GetValue(TitleProperty);
680 [EditorBrowsable(EditorBrowsableState.Never)]
681 public ImageView Favicon
685 global::System.IntPtr imageView = Interop.WebView.GetFavicon(SwigCPtr);
686 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 return new ImageView(imageView, false);
692 internal static new class Property
694 internal static readonly int Url = Interop.WebView.UrlGet();
695 internal static readonly int UserAgent = Interop.WebView.UserAgentGet();
696 internal static readonly int ScrollPosition = Interop.WebView.ScrollPositionGet();
697 internal static readonly int ScrollSize = Interop.WebView.ScrollSizeGet();
698 internal static readonly int ContentSize = Interop.WebView.ContentSizeGet();
699 internal static readonly int Title = Interop.WebView.TitleGet();
700 internal static readonly int VideoHoleEnabled = Interop.WebView.VideoHoleEnabledGet();
701 internal static readonly int MouseEventsEnabled = Interop.WebView.MouseEventsEnabledGet();
702 internal static readonly int KeyEventsEnabled = Interop.WebView.KeyEventsEnabledGet();
705 private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
707 var webview = (WebView)bindable;
708 if (newValue != null)
710 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.Url, new Tizen.NUI.PropertyValue((string)newValue));
713 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
715 var webview = (WebView)bindable;
717 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.Url).Get(out temp);
721 private static readonly BindableProperty UserAgentProperty = BindableProperty.Create(nameof(UserAgent), typeof(string), typeof(WebView), string.Empty, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
723 var webview = (WebView)bindable;
724 if (newValue != null)
726 Tizen.NUI.Object.SetProperty((HandleRef)webview.SwigCPtr, WebView.Property.UserAgent, new Tizen.NUI.PropertyValue((string)newValue));
729 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
731 var webview = (WebView)bindable;
733 Tizen.NUI.Object.GetProperty((HandleRef)webview.SwigCPtr, WebView.Property.UserAgent).Get(out temp);
737 private static readonly BindableProperty ScrollPositionProperty = BindableProperty.Create(nameof(ScrollPosition), typeof(Vector2), typeof(WebView), null, propertyChanged: (bindable, oldValue, newValue) =>
739 var webview = (WebView)bindable;
740 if (newValue != null)
742 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition, new Tizen.NUI.PropertyValue((Vector2)newValue));
745 defaultValueCreator: (bindable) =>
747 var webview = (WebView)bindable;
748 Vector2 temp = new Vector2(0.0f, 0.0f);
749 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition).Get(temp);
753 private static readonly BindableProperty ScrollSizeProperty = BindableProperty.Create(nameof(ScrollSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
755 var webview = (WebView)bindable;
756 Vector2 temp = new Vector2(0.0f, 0.0f);
757 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollSize).Get(temp);
761 private static readonly BindableProperty ContentSizeProperty = BindableProperty.Create(nameof(ContentSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
763 var webview = (WebView)bindable;
764 Vector2 temp = new Vector2(0.0f, 0.0f);
765 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ContentSize).Get(temp);
769 private static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(WebView), null, defaultValueCreator: (bindable) =>
771 var webview = (WebView)bindable;
773 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.Title).Get(out title);
777 private static readonly BindableProperty VideoHoleEnabledProperty = BindableProperty.Create(nameof(VideoHoleEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
779 var webview = (WebView)bindable;
780 if (newValue != null)
782 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
785 defaultValueCreator: (bindable) =>
787 var webview = (WebView)bindable;
789 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled).Get(out temp);
793 private static readonly BindableProperty MouseEventsEnabledProperty = BindableProperty.Create(nameof(MouseEventsEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
795 var webview = (WebView)bindable;
796 if (newValue != null)
798 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.MouseEventsEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
801 defaultValueCreator: (bindable) =>
803 var webview = (WebView)bindable;
805 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.MouseEventsEnabled).Get(out temp);
809 private static readonly BindableProperty KeyEventsEnabledProperty = BindableProperty.Create(nameof(KeyEventsEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
811 var webview = (WebView)bindable;
812 if (newValue != null)
814 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.KeyEventsEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
817 defaultValueCreator: (bindable) =>
819 var webview = (WebView)bindable;
821 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.KeyEventsEnabled).Get(out temp);
825 // For rooting handlers
826 internal Dictionary<string, JavaScriptMessageHandler> handlerRootMap = new Dictionary<string, JavaScriptMessageHandler>();
830 /// <param name="url">The path of Web</param>
832 [EditorBrowsable(EditorBrowsableState.Never)]
833 public void LoadUrl(string url)
835 Interop.WebView.LoadUrl(SwigCPtr, url);
836 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 /// Deprecated. Loads a html by string.
841 /// <param name="data">The data of Web</param>
843 [EditorBrowsable(EditorBrowsableState.Never)]
844 public void LoadHTMLString(string data)
846 Interop.WebView.LoadHtmlString(SwigCPtr, data);
847 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 /// Loads a html by string.
852 /// <param name="data">The data of Web</param>
854 [EditorBrowsable(EditorBrowsableState.Never)]
855 public void LoadHtmlString(string data)
857 Interop.WebView.LoadHtmlString(SwigCPtr, data);
858 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864 [EditorBrowsable(EditorBrowsableState.Never)]
867 Interop.WebView.Reload(SwigCPtr);
868 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
872 /// Stops loading the Web
874 [EditorBrowsable(EditorBrowsableState.Never)]
875 public void StopLoading()
877 Interop.WebView.StopLoading(SwigCPtr);
878 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882 /// Suspends the operation.
884 [EditorBrowsable(EditorBrowsableState.Never)]
885 public void Suspend()
887 Interop.WebView.Suspend(SwigCPtr);
888 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 /// Resumes the operation after calling Suspend()
894 [EditorBrowsable(EditorBrowsableState.Never)]
897 Interop.WebView.Resume(SwigCPtr);
898 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
902 /// Scroll web view by deltaX and detlaY.
903 /// <param name="deltaX">The deltaX of scroll</param>
904 /// <param name="deltaY">The deltaY of scroll</param>
906 [EditorBrowsable(EditorBrowsableState.Never)]
907 public void ScrollBy(int deltaX, int deltaY)
909 Interop.WebView.ScrollBy(SwigCPtr, deltaX, deltaY);
910 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 [EditorBrowsable(EditorBrowsableState.Never)]
919 Interop.WebView.GoBack(SwigCPtr);
920 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
924 /// Goes to the forward
926 [EditorBrowsable(EditorBrowsableState.Never)]
927 public void GoForward()
929 Interop.WebView.GoForward(SwigCPtr);
930 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
934 /// Returns whether backward is possible.
935 /// <returns>True if backward is possible, false otherwise</returns>
937 [EditorBrowsable(EditorBrowsableState.Never)]
938 public bool CanGoBack()
940 bool ret = Interop.WebView.CanGoBack(SwigCPtr);
941 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
946 /// Returns whether forward is possible.
947 /// <returns>True if forward is possible, false otherwise</returns>
949 [EditorBrowsable(EditorBrowsableState.Never)]
950 public bool CanGoForward()
952 bool ret = Interop.WebView.CanGoForward(SwigCPtr);
953 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
958 /// Evaluates JavaScript code represented as a string.
959 /// <param name="script">The JavaScript code</param>
961 [EditorBrowsable(EditorBrowsableState.Never)]
962 public void EvaluateJavaScript(string script)
964 Interop.WebView.EvaluateJavaScript(SwigCPtr, script, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
965 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
969 /// Add a message handler into the WebView.
970 /// <param name="objectName">The name of exposed object</param>
971 /// <param name="handler">The callback function</param>
973 [EditorBrowsable(EditorBrowsableState.Never)]
974 public void AddJavaScriptMessageHandler(string objectName, JavaScriptMessageHandler handler)
976 if (handlerRootMap.ContainsKey(objectName))
981 handlerRootMap.Add(objectName, handler);
983 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(handler);
984 Interop.WebView.AddJavaScriptMessageHandler(SwigCPtr, objectName, new System.Runtime.InteropServices.HandleRef(this, ip));
986 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
990 /// Add a message handler into the WebView.
991 /// <param name="callback">The callback function</param>
993 [EditorBrowsable(EditorBrowsableState.Never)]
994 public void RegisterJavaScriptAlertCallback(JavaScriptAlertCallback callback)
996 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(callback);
997 Interop.WebView.RegisterJavaScriptAlertCallback(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
999 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1003 /// Reply for alert popup.
1005 [EditorBrowsable(EditorBrowsableState.Never)]
1006 public void JavaScriptAlertReply()
1008 Interop.WebView.JavaScriptAlertReply(SwigCPtr);
1009 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 /// Add a message handler into the WebView.
1014 /// <param name="callback">The callback function</param>
1016 [EditorBrowsable(EditorBrowsableState.Never)]
1017 public void RegisterJavaScriptConfirmCallback(JavaScriptConfirmCallback callback)
1019 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(callback);
1020 Interop.WebView.RegisterJavaScriptConfirmCallback(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
1022 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1026 /// Reply for confirm popup.
1027 /// <param name="confirmed">confirmed or not</param>
1029 [EditorBrowsable(EditorBrowsableState.Never)]
1030 public void JavaScriptConfirmReply(bool confirmed)
1032 Interop.WebView.JavaScriptConfirmReply(SwigCPtr, confirmed);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 /// Add a message handler into the WebView.
1038 /// <param name="callback">The callback function</param>
1040 [EditorBrowsable(EditorBrowsableState.Never)]
1041 public void RegisterJavaScriptPromptCallback(JavaScriptPromptCallback callback)
1043 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(callback);
1044 Interop.WebView.RegisterJavaScriptPromptCallback(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
1046 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1050 /// Reply for prompt popup.
1051 /// <param name="result">text in prompt input field.</param>
1053 [EditorBrowsable(EditorBrowsableState.Never)]
1054 public void JavaScriptPromptReply(string result)
1056 Interop.WebView.JavaScriptPromptReply(SwigCPtr, result);
1057 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1061 /// Clears title resources of current WebView.
1063 [EditorBrowsable(EditorBrowsableState.Never)]
1064 public void ClearAllTilesResources()
1066 Interop.WebView.ClearAllTilesResources(SwigCPtr);
1067 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1071 /// Clears the history of current WebView.
1073 [EditorBrowsable(EditorBrowsableState.Never)]
1074 public void ClearHistory()
1076 Interop.WebView.ClearHistory(SwigCPtr);
1077 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1081 /// Deprecated. Clears the cache of current WebView.
1083 [EditorBrowsable(EditorBrowsableState.Never)]
1084 public void ClearCache()
1086 Context.ClearCache();
1090 /// Deprecated. Clears all the cookies of current WebView.
1092 [EditorBrowsable(EditorBrowsableState.Never)]
1093 public void ClearCookies()
1095 CookieManager.ClearCookies();
1098 internal static WebView DownCast(BaseHandle handle)
1100 WebView ret = new WebView(Interop.WebView.DownCast(BaseHandle.getCPtr(handle)), true);
1101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1105 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj)
1107 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1110 internal WebView Assign(WebView webView)
1112 WebView ret = new WebView(Interop.WebView.Assign(SwigCPtr, WebView.getCPtr(webView)), false);
1113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1117 /// This will not be public opened.
1118 /// <param name="swigCPtr"></param>
1119 [EditorBrowsable(EditorBrowsableState.Never)]
1120 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1122 Interop.WebView.DeleteWebView(swigCPtr);
1125 private void OnPageLoadStarted(IntPtr data, string pageUrl)
1127 WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
1129 e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
1130 e.PageUrl = pageUrl;
1132 pageLoadStartedEventHandler?.Invoke(this, e);
1135 private void OnPageLoading(IntPtr data, string pageUrl)
1137 pageLoadingEventHandler?.Invoke(this, new WebViewPageLoadEventArgs());
1140 private void OnPageLoadFinished(IntPtr data, string pageUrl)
1142 WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
1144 e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
1145 e.PageUrl = pageUrl;
1147 pageLoadFinishedEventHandler?.Invoke(this, e);
1150 private void OnPageLoadError(IntPtr data, string pageUrl, int errorCode)
1152 WebViewPageLoadErrorEventArgs e = new WebViewPageLoadErrorEventArgs();
1154 e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
1155 e.PageUrl = pageUrl;
1156 e.ErrorCode = (WebViewPageLoadErrorEventArgs.LoadErrorCode)errorCode;
1158 pageLoadErrorEventHandler?.Invoke(this, e);
1161 private void OnScrollEdgeReached(IntPtr data, int edge)
1163 WebViewScrollEdgeReachedEventArgs arg = new WebViewScrollEdgeReachedEventArgs((WebViewScrollEdgeReachedEventArgs.Edge)edge);
1164 scrollEdgeReachedEventHandler?.Invoke(this, arg);
1167 private void OnUrlChanged(IntPtr data, string pageUrl)
1169 urlChangedEventHandler?.Invoke(this, new WebViewUrlChangedEventArgs(pageUrl));
1172 private void OnFormRepostPolicyDecided(IntPtr data, IntPtr decision)
1174 WebFormRepostPolicyDecisionMaker repostDecision = new WebFormRepostPolicyDecisionMaker(decision, false);
1175 formRepostPolicyDecidedEventHandler?.Invoke(this, new WebViewFormRepostPolicyDecidedEventArgs(repostDecision));
1176 repostDecision.Dispose();
1179 private void OnFrameRendered(IntPtr data)
1181 frameRenderedEventHandler?.Invoke(this, new EventArgs());