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 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
34 private delegate void WebViewPageLoadCallback(string pageUrl);
36 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
37 private delegate void WebViewPageLoadErrorCallback(string pageUrl, int errorCode);
39 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
40 private delegate void WebViewScrollEdgeReachedCallback(int edge);
42 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
43 private delegate void WebViewUrlChangedCallbackDelegate(string pageUrl);
45 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
46 private delegate void WebViewPolicyDecidedCallback(IntPtr maker);
48 private EventHandler<WebViewPageLoadEventArgs> pageLoadStartedEventHandler;
49 private WebViewPageLoadCallback pageLoadStartedCallback;
51 private EventHandler<WebViewPageLoadEventArgs> pageLoadFinishedEventHandler;
52 private WebViewPageLoadCallback pageLoadFinishedCallback;
54 private EventHandler<WebViewPageLoadErrorEventArgs> pageLoadErrorEventHandler;
55 private WebViewPageLoadErrorCallback pageLoadErrorCallback;
57 private EventHandler<WebViewScrollEdgeReachedEventArgs> scrollEdgeReachedEventHandler;
58 private WebViewScrollEdgeReachedCallback scrollEdgeReachedCallback;
60 private EventHandler<WebViewUrlChangedEventArgs> urlChangedEventHandler;
61 private WebViewUrlChangedCallbackDelegate urlChangedCallback;
63 private EventHandler<WebViewPolicyDecidedEventArgs> navigationPolicyDecidedEventHandler;
64 private WebViewPolicyDecidedCallback navigationPolicyDecidedCallback;
66 private PlainTextReceivedCallback plainTextReceivedCallback;
69 /// The callback function that is invoked when the plain text of the current page is received.
71 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72 [EditorBrowsable(EditorBrowsableState.Never)]
73 public delegate void PlainTextReceivedCallback(string plainText);
75 internal WebView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WebView.WebView_SWIGUpcast(cPtr), cMemoryOwn)
77 BackForwardList = new WebBackForwardList(Interop.WebView.GetWebBackForwardList(SwigCPtr), false);
78 Context = new WebContext(Interop.WebView.GetWebContext(SwigCPtr), false);
79 CookieManager = new WebCookieManager(Interop.WebView.GetWebCookieManager(SwigCPtr), false);
80 Settings = new WebSettings(Interop.WebView.GetWebSettings(SwigCPtr), false);
83 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj)
85 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
88 internal WebView Assign(WebView webView)
90 WebView ret = new WebView(Interop.WebView.WebView_Assign(swigCPtr, WebView.getCPtr(webView)), false);
91 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95 internal static WebView DownCast(BaseHandle handle)
97 WebView ret = new WebView(Interop.WebView.WebView_DownCast(BaseHandle.getCPtr(handle)), true);
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103 /// Dispose for IDisposable pattern
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 protected override void Dispose(DisposeTypes type)
113 if (type == DisposeTypes.Explicit)
116 //Release your own managed resources here.
117 //You should release all of your own disposable objects here.
118 BackForwardList.Dispose();
120 CookieManager.Dispose();
127 /// This will not be public opened.
128 /// <param name="swigCPtr"></param>
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
132 Interop.WebView.delete_WebView(swigCPtr);
135 private void OnPageLoadStarted(string pageUrl)
137 WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
142 pageLoadStartedEventHandler?.Invoke(this, e);
145 private void OnPageLoadFinished(string pageUrl)
147 WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
152 pageLoadFinishedEventHandler?.Invoke(this, e);
155 private void OnPageLoadError(string pageUrl, int errorCode)
157 WebViewPageLoadErrorEventArgs e = new WebViewPageLoadErrorEventArgs();
161 e.ErrorCode = (WebViewPageLoadErrorEventArgs.LoadErrorCode)errorCode;
163 pageLoadErrorEventHandler?.Invoke(this, e);
166 private void OnScrollEdgeReached(int edge)
168 scrollEdgeReachedEventHandler?.Invoke(this, new WebViewScrollEdgeReachedEventArgs((WebViewScrollEdgeReachedEventArgs.Edge)edge));
171 private void OnUrlChanged(string pageUrl)
173 urlChangedEventHandler?.Invoke(this, new WebViewUrlChangedEventArgs(pageUrl));
176 private void OnNavigationPolicyDecided(IntPtr maker)
178 navigationPolicyDecidedEventHandler?.Invoke(this, new WebViewPolicyDecidedEventArgs(new WebPolicyDecisionMaker(maker, true)));
181 internal static new class Property
183 internal static readonly int URL = Interop.WebView.WebView_Property_URL_get();
184 internal static readonly int USER_AGENT = Interop.WebView.WebView_Property_USER_AGENT_get();
185 internal static readonly int ScrollPosition = Interop.WebView.ScrollPositionGet();
186 internal static readonly int ScrollSize = Interop.WebView.ScrollSizeGet();
187 internal static readonly int ContentSize = Interop.WebView.ContentSizeGet();
188 internal static readonly int Title = Interop.WebView.TitleGet();
189 internal static readonly int VideoHoleEnabled = Interop.WebView.VideoHoleEnabledGet();
192 private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
194 var webview = (WebView)bindable;
195 if (newValue != null)
197 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.URL, new Tizen.NUI.PropertyValue((string)newValue));
200 defaultValueCreator: (bindable) =>
202 var webview = (WebView)bindable;
204 Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.URL).Get(out temp);
208 private static readonly BindableProperty UserAgentProperty = BindableProperty.Create(nameof(UserAgent), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
210 var webview = (WebView)bindable;
211 if (newValue != null)
213 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.USER_AGENT, new Tizen.NUI.PropertyValue((string)newValue));
216 defaultValueCreator: (bindable) =>
218 var webview = (WebView)bindable;
220 Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.USER_AGENT).Get(out temp);
224 private static readonly BindableProperty ScrollPositionProperty = BindableProperty.Create(nameof(ScrollPosition), typeof(Vector2), typeof(WebView), null, propertyChanged: (bindable, oldValue, newValue) =>
226 var webview = (WebView)bindable;
227 if (newValue != null)
229 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition, new Tizen.NUI.PropertyValue((Vector2)newValue));
232 defaultValueCreator: (bindable) =>
234 var webview = (WebView)bindable;
235 Vector2 temp = new Vector2(0.0f, 0.0f);
236 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition).Get(temp);
240 private static readonly BindableProperty ScrollSizeProperty = BindableProperty.Create(nameof(ScrollSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
242 var webview = (WebView)bindable;
243 Vector2 temp = new Vector2(0.0f, 0.0f);
244 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollSize).Get(temp);
248 private static readonly BindableProperty ContentSizeProperty = BindableProperty.Create(nameof(ContentSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
250 var webview = (WebView)bindable;
251 Vector2 temp = new Vector2(0.0f, 0.0f);
252 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ContentSize).Get(temp);
256 private static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(WebView), null, defaultValueCreator: (bindable) =>
258 var webview = (WebView)bindable;
260 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.Title).Get(out title);
264 private static readonly BindableProperty VideoHoleEnabledProperty = BindableProperty.Create(nameof(VideoHoleEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
266 var webview = (WebView)bindable;
267 if (newValue != null)
269 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
272 defaultValueCreator: (bindable) =>
274 var webview = (WebView)bindable;
276 Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled).Get(out temp);
281 /// Creates a WebView.
283 [EditorBrowsable(EditorBrowsableState.Never)]
284 public WebView() : this(Interop.WebView.WebView_New(), true)
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 /// Creates a WebView with local language and time zone.
291 /// <param name="locale">The locale language of Web</param>
292 /// <param name="timezoneId">The time zone Id of Web</param>
294 [EditorBrowsable(EditorBrowsableState.Never)]
295 public WebView(string locale, string timezoneId) : this(Interop.WebView.WebView_New_2(locale, timezoneId), true)
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 /// Creates a WebView with an args list.
302 /// <param name="args">args array. The first value of array must be program's name.</param>
304 [EditorBrowsable(EditorBrowsableState.Never)]
305 public WebView(string[] args) : this(Interop.WebView.WebView_New_3(args?.Length ?? 0, args), true)
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 /// Copy constructor.
312 /// <param name="webView">WebView to copy. The copied WebView will point at the same implementation</param>
314 [EditorBrowsable(EditorBrowsableState.Never)]
315 public WebView(WebView webView) : this(Interop.WebView.new_WebView__SWIG_1(WebView.getCPtr(webView)), true)
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 [EditorBrowsable(EditorBrowsableState.Never)]
324 public WebBackForwardList BackForwardList { get; }
329 [EditorBrowsable(EditorBrowsableState.Never)]
330 public WebContext Context { get; }
335 [EditorBrowsable(EditorBrowsableState.Never)]
336 public WebCookieManager CookieManager { get; }
341 [EditorBrowsable(EditorBrowsableState.Never)]
342 public WebSettings Settings { get; }
347 [EditorBrowsable(EditorBrowsableState.Never)]
352 return (string)GetValue(UrlProperty);
356 SetValue(UrlProperty, value);
357 NotifyPropertyChanged();
362 /// Deprecated. The cache model of the current WebView.
364 [EditorBrowsable(EditorBrowsableState.Never)]
365 public CacheModel CacheModel
369 return (CacheModel)Context.CacheModel;
373 Context.CacheModel = (WebContext.CacheModelType)value;
378 /// Deprecated. The cookie acceptance policy.
380 [EditorBrowsable(EditorBrowsableState.Never)]
381 public CookieAcceptPolicy CookieAcceptPolicy
385 return (CookieAcceptPolicy)CookieManager.CookieAcceptPolicy;
389 CookieManager.CookieAcceptPolicy = (WebCookieManager.CookieAcceptPolicyType)value;
394 /// The user agent string.
396 [EditorBrowsable(EditorBrowsableState.Never)]
397 public string UserAgent
401 return (string)GetValue(UserAgentProperty);
405 SetValue(UserAgentProperty, value);
406 NotifyPropertyChanged();
411 /// Deprecated. Whether JavaScript is enabled.
413 [EditorBrowsable(EditorBrowsableState.Never)]
414 public bool EnableJavaScript
418 return Settings.EnableJavaScript;
422 Settings.EnableJavaScript = value;
427 /// Deprecated. Whether images can be loaded automatically.
429 [EditorBrowsable(EditorBrowsableState.Never)]
430 public bool LoadImagesAutomatically
434 return Settings.AllowImagesLoadAutomatically;
438 Settings.AllowImagesLoadAutomatically = value;
443 /// The default text encoding name.<br />
444 /// e.g. "UTF-8"<br />
446 [EditorBrowsable(EditorBrowsableState.Never)]
447 public string DefaultTextEncodingName
451 return Settings.DefaultTextEncodingName;
455 Settings.DefaultTextEncodingName = value;
460 /// The default font size in pixel.
462 [EditorBrowsable(EditorBrowsableState.Never)]
463 public int DefaultFontSize
467 return Settings.DefaultFontSize;
471 Settings.DefaultFontSize = value;
476 /// The postion of scroll.
478 [EditorBrowsable(EditorBrowsableState.Never)]
479 public Position ScrollPosition
483 Vector2 pv = (Vector2)GetValue(ScrollPositionProperty);
484 return new Position(pv.X, pv.Y);
491 Vector2 vpv = new Vector2(pv.X, pv.Y);
492 SetValue(ScrollPositionProperty, vpv);
493 NotifyPropertyChanged();
499 /// The size of scroll, read-only.
501 [EditorBrowsable(EditorBrowsableState.Never)]
502 public Size ScrollSize
506 Vector2 sv = (Vector2)GetValue(ScrollSizeProperty);
507 return new Size(sv.Width, sv.Height);
512 /// The size of content, read-only.
514 [EditorBrowsable(EditorBrowsableState.Never)]
515 public Size ContentSize
519 Vector2 sv = (Vector2)GetValue(ContentSizeProperty);
520 return new Size(sv.Width, sv.Height);
525 /// Whether video hole is enabled or not.
527 [EditorBrowsable(EditorBrowsableState.Never)]
528 public bool VideoHoleEnabled
532 return (bool)GetValue(VideoHoleEnabledProperty);
536 SetValue(VideoHoleEnabledProperty, value);
537 NotifyPropertyChanged();
542 /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
543 /// This signal is emitted when page loading has started.<br />
545 [EditorBrowsable(EditorBrowsableState.Never)]
546 public event EventHandler<WebViewPageLoadEventArgs> PageLoadStarted
550 if (pageLoadStartedEventHandler == null)
552 pageLoadStartedCallback = OnPageLoadStarted;
553 IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadStartedCallback);
554 Interop.WebView.RegisterPageLoadStartedCallback(SwigCPtr, new HandleRef(this, ip));
556 pageLoadStartedEventHandler += value;
560 pageLoadStartedEventHandler -= value;
565 /// Event for the PageLoadFinished signal which can be used to subscribe or unsubscribe the event handler.<br />
566 /// This signal is emitted when page loading has finished.<br />
568 [EditorBrowsable(EditorBrowsableState.Never)]
569 public event EventHandler<WebViewPageLoadEventArgs> PageLoadFinished
573 if (pageLoadFinishedEventHandler == null)
575 pageLoadFinishedCallback = OnPageLoadFinished;
576 IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadFinishedCallback);
577 Interop.WebView.RegisterPageLoadFinishedCallback(SwigCPtr, new HandleRef(this, ip));
579 pageLoadFinishedEventHandler += value;
583 pageLoadFinishedEventHandler -= value;
588 /// Event for the PageLoadError signal which can be used to subscribe or unsubscribe the event handler.<br />
589 /// This signal is emitted when there's an error in page loading.<br />
591 [EditorBrowsable(EditorBrowsableState.Never)]
592 public event EventHandler<WebViewPageLoadErrorEventArgs> PageLoadError
596 pageLoadErrorCallback = OnPageLoadError;
597 IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadErrorCallback);
598 Interop.WebView.RegisterPageLoadErrorCallback(SwigCPtr, new HandleRef(this, ip));
602 pageLoadErrorEventHandler -= value;
607 /// Event for the ScrollEdgeReached signal which can be used to subscribe or unsubscribe the event handler.<br />
608 /// This signal is emitted when web view is scrolled to edge.<br />
610 [EditorBrowsable(EditorBrowsableState.Never)]
611 public event EventHandler<WebViewScrollEdgeReachedEventArgs> ScrollEdgeReached
615 scrollEdgeReachedCallback = OnScrollEdgeReached;
616 IntPtr ip = Marshal.GetFunctionPointerForDelegate(scrollEdgeReachedCallback);
617 Interop.WebView.RegisterScrollEdgeReachedCallback(SwigCPtr, new HandleRef(this, ip));
621 scrollEdgeReachedEventHandler -= value;
626 /// Event for the UrlChanged signal which can be used to subscribe or unsubscribe the event handler.<br />
627 /// This signal is emitted when url is changed.<br />
629 [EditorBrowsable(EditorBrowsableState.Never)]
630 public event EventHandler<WebViewUrlChangedEventArgs> UrlChanged
634 if (urlChangedEventHandler == null)
636 urlChangedCallback = OnUrlChanged;
637 IntPtr ip = Marshal.GetFunctionPointerForDelegate(urlChangedCallback);
638 Interop.WebView.RegisterUrlChangedCallback(SwigCPtr, new HandleRef(this, ip));
640 urlChangedEventHandler += value;
644 urlChangedEventHandler -= value;
649 /// Event for the NavigationPolicyDecided signal which can be used to subscribe or unsubscribe the event handler.<br />
650 /// This signal is emitted when response policy would be decided.<br />
652 [EditorBrowsable(EditorBrowsableState.Never)]
653 public event EventHandler<WebViewPolicyDecidedEventArgs> NavigationPolicyDecided
657 if (navigationPolicyDecidedEventHandler == null)
659 navigationPolicyDecidedCallback = OnNavigationPolicyDecided;
660 IntPtr ip = Marshal.GetFunctionPointerForDelegate(navigationPolicyDecidedCallback);
661 Interop.WebView.RegisterNavigationPolicyDecidedCallback(SwigCPtr, new HandleRef(this, ip));
663 navigationPolicyDecidedEventHandler += value;
667 navigationPolicyDecidedEventHandler -= value;
672 /// Gets title of web page.
674 [EditorBrowsable(EditorBrowsableState.Never)]
679 return (string)GetValue(TitleProperty);
686 [EditorBrowsable(EditorBrowsableState.Never)]
687 public ImageView Favicon
691 global::System.IntPtr imageView = Interop.WebView.WebView_GetFavicon(swigCPtr);
692 if (imageView == IntPtr.Zero)
694 return new ImageView(imageView, false);
700 /// <param name="url">The path of Web</param>
702 [EditorBrowsable(EditorBrowsableState.Never)]
703 public void LoadUrl(string url)
705 Interop.WebView.WebView_LoadUrl(swigCPtr, url);
706 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 /// Deprecated. Loads a html by string.
711 /// <param name="data">The data of Web</param>
713 [EditorBrowsable(EditorBrowsableState.Never)]
714 public void LoadHTMLString(string data)
716 Interop.WebView.LoadHtmlString(SwigCPtr, data);
717 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 /// Loads a html by string.
722 /// <param name="data">The data of Web</param>
724 [EditorBrowsable(EditorBrowsableState.Never)]
725 public void LoadHtmlString(string data)
727 Interop.WebView.LoadHtmlString(SwigCPtr, data);
728 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 [EditorBrowsable(EditorBrowsableState.Never)]
737 Interop.WebView.WebView_Reload(swigCPtr);
738 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 /// Stops loading the Web
744 [EditorBrowsable(EditorBrowsableState.Never)]
745 public void StopLoading()
747 Interop.WebView.WebView_StopLoading(swigCPtr);
748 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752 /// Suspends the operation.
754 [EditorBrowsable(EditorBrowsableState.Never)]
755 public void Suspend()
757 Interop.WebView.WebView_Suspend(swigCPtr);
758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 /// Resumes the operation after calling Suspend()
764 [EditorBrowsable(EditorBrowsableState.Never)]
767 Interop.WebView.WebView_Resume(swigCPtr);
768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 /// Scroll web view by deltaX and detlaY.
773 /// <param name="deltaX">The deltaX of scroll</param>
774 /// <param name="deltaY">The deltaY of scroll</param>
776 [EditorBrowsable(EditorBrowsableState.Never)]
777 public void ScrollBy(int deltaX, int deltaY)
779 Interop.WebView.ScrollBy(SwigCPtr, deltaX, deltaY);
780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
786 [EditorBrowsable(EditorBrowsableState.Never)]
789 Interop.WebView.WebView_GoBack(swigCPtr);
790 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
794 /// Goes to the forward
796 [EditorBrowsable(EditorBrowsableState.Never)]
797 public void GoForward()
799 Interop.WebView.WebView_GoForward(swigCPtr);
800 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
804 /// Returns whether backward is possible.
805 /// <returns>True if backward is possible, false otherwise</returns>
807 [EditorBrowsable(EditorBrowsableState.Never)]
808 public bool CanGoBack()
810 bool ret = Interop.WebView.WebView_CanGoBack(swigCPtr);
811 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816 /// Returns whether forward is possible.
817 /// <returns>True if forward is possible, false otherwise</returns>
819 [EditorBrowsable(EditorBrowsableState.Never)]
820 public bool CanGoForward()
822 bool ret = Interop.WebView.WebView_CanGoForward(swigCPtr);
823 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
828 /// The callback function that is invoked when the message is received from the script.
830 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
831 [EditorBrowsable(EditorBrowsableState.Never)]
832 public delegate void JavaScriptMessageHandler(string message);
835 /// Evaluates JavaScript code represented as a string.
836 /// <param name="script">The JavaScript code</param>
838 [EditorBrowsable(EditorBrowsableState.Never)]
839 public void EvaluateJavaScript(string script)
841 Interop.WebView.WebView_EvaluateJavaScript(swigCPtr, script, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
842 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
845 // For rooting handlers
846 internal Dictionary<string, JavaScriptMessageHandler> handlerRootMap = new Dictionary<string, JavaScriptMessageHandler>();
849 /// Add a message handler into the WebView.
850 /// <param name="objectName">The name of exposed object</param>
851 /// <param name="handler">The callback function</param>
853 [EditorBrowsable(EditorBrowsableState.Never)]
854 public void AddJavaScriptMessageHandler(string objectName, JavaScriptMessageHandler handler)
856 if (handlerRootMap.ContainsKey(objectName))
861 handlerRootMap.Add(objectName, handler);
863 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(handler);
864 Interop.WebView.WebView_AddJavaScriptMessageHandler(swigCPtr, objectName, new System.Runtime.InteropServices.HandleRef(this, ip));
866 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
870 /// Clears title resources of current WebView.
872 [EditorBrowsable(EditorBrowsableState.Never)]
873 public void ClearAllTilesResources()
875 Interop.WebView.WebView_ClearAllTilesResources(swigCPtr);
876 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
880 /// Clears the history of current WebView.
882 [EditorBrowsable(EditorBrowsableState.Never)]
883 public void ClearHistory()
885 Interop.WebView.WebView_ClearHistory(swigCPtr);
886 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890 /// Deprecated. Clears the cache of current WebView.
892 [EditorBrowsable(EditorBrowsableState.Never)]
893 public void ClearCache()
895 Context.ClearCache();
899 /// Deprecated. Clears all the cookies of current WebView.
901 [EditorBrowsable(EditorBrowsableState.Never)]
902 public void ClearCookies()
904 CookieManager.ClearCookies();
908 /// Sets the tts focus to the webview.
909 /// Please note that it only works when the webview does not have keyinput focus.
910 /// If the webview has a keyinput focus, it also has tts focus so calling SetTtsFocus(false) is ignored.
912 [EditorBrowsable(EditorBrowsableState.Never)]
913 public void SetTtsFocus(bool focused)
915 Interop.WebView.SetTtsFocus(SwigCPtr, focused);
916 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920 /// Get a plain text of current web page asynchronously.
921 /// Please note that it gets plain text of currently loaded page so please call this method after page load finished.
922 /// <param name="callback">The callback for getting plain text</param>
924 [EditorBrowsable(EditorBrowsableState.Never)]
925 public void GetPlainTextAsynchronously(PlainTextReceivedCallback callback)
927 plainTextReceivedCallback = callback;
928 System.IntPtr ip = Marshal.GetFunctionPointerForDelegate(plainTextReceivedCallback);
929 Interop.WebView.GetPlainTextAsynchronously(SwigCPtr, new HandleRef(this, ip));
930 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();