236ffe3e3c20252c6325289a7a1a8a212104af89
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebView.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20 using System.Collections.Generic;
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Binding;
24
25 namespace Tizen.NUI
26 {
27     /// <summary>
28     /// WebView
29     /// </summary>
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class WebView : View
32     {
33         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
34         private delegate void WebViewPageLoadCallback(string pageUrl);
35
36         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
37         private delegate void WebViewPageLoadErrorCallback(string pageUrl, int errorCode);
38
39         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
40         private delegate void WebViewScrollEdgeReachedCallback(int edge);
41
42         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
43         private delegate void WebViewPolicyDecidedCallback(IntPtr maker);
44
45         private EventHandler<WebViewPageLoadEventArgs> pageLoadStartedEventHandler;
46         private WebViewPageLoadCallback pageLoadStartedCallback;
47
48         private EventHandler<WebViewPageLoadEventArgs> pageLoadFinishedEventHandler;
49         private WebViewPageLoadCallback pageLoadFinishedCallback;
50
51         private EventHandler<WebViewPageLoadErrorEventArgs> pageLoadErrorEventHandler;
52         private WebViewPageLoadErrorCallback pageLoadErrorCallback;
53
54         private EventHandler<WebViewScrollEdgeReachedEventArgs> scrollEdgeReachedEventHandler;
55         private WebViewScrollEdgeReachedCallback scrollEdgeReachedCallback;
56
57         private EventHandler<WebViewPolicyDecidedEventArgs> navigationPolicyDecidedEventHandler;
58         private WebViewPolicyDecidedCallback navigationPolicyDecidedCallback;
59
60         private PlainTextReceivedCallback plainTextReceivedCallback;
61
62         /// <summary>
63         /// The callback function that is invoked when the plain text of the current page is received.
64         /// </summary>
65         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public delegate void PlainTextReceivedCallback(string plainText);
68
69         internal WebView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WebView.WebView_SWIGUpcast(cPtr), cMemoryOwn)
70         {
71             BackForwardList = new WebBackForwardList(Interop.WebView.GetWebBackForwardList(SwigCPtr), false);
72             Context = new WebContext(Interop.WebView.GetWebContext(SwigCPtr), false);
73             CookieManager = new WebCookieManager(Interop.WebView.GetWebCookieManager(SwigCPtr), false);
74             Settings = new WebSettings(Interop.WebView.GetWebSettings(SwigCPtr), false);
75         }
76
77         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj)
78         {
79             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
80         }
81
82         internal WebView Assign(WebView webView)
83         {
84             WebView ret = new WebView(Interop.WebView.WebView_Assign(swigCPtr, WebView.getCPtr(webView)), false);
85             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         internal static WebView DownCast(BaseHandle handle)
90         {
91             WebView ret = new WebView(Interop.WebView.WebView_DownCast(BaseHandle.getCPtr(handle)), true);
92             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93             return ret;
94         }
95
96         /// <summary>
97         /// Dispose for IDisposable pattern
98         /// </summary>
99         [EditorBrowsable(EditorBrowsableState.Never)]
100         protected override void Dispose(DisposeTypes type)
101         {
102             if (disposed)
103             {
104                 return;
105             }
106
107             if (type == DisposeTypes.Explicit)
108             {
109                 //Called by User
110                 //Release your own managed resources here.
111                 //You should release all of your own disposable objects here.
112                 BackForwardList.Dispose();
113                 Context.Dispose();
114                 CookieManager.Dispose();
115                 Settings.Dispose();
116             }
117
118             base.Dispose(type);
119         }
120
121         /// This will not be public opened.
122         /// <param name="swigCPtr"></param>
123         [EditorBrowsable(EditorBrowsableState.Never)]
124         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
125         {
126             Interop.WebView.delete_WebView(swigCPtr);
127         }
128
129         private void OnPageLoadStarted(string pageUrl)
130         {
131             WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
132
133             e.WebView = this;
134             e.PageUrl = pageUrl;
135
136             pageLoadStartedEventHandler?.Invoke(this, e);
137         }
138
139         private void OnPageLoadFinished(string pageUrl)
140         {
141             WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
142
143             e.WebView = this;
144             e.PageUrl = pageUrl;
145
146             pageLoadFinishedEventHandler?.Invoke(this, e);
147         }
148
149         private void OnPageLoadError(string pageUrl, int errorCode)
150         {
151             WebViewPageLoadErrorEventArgs e = new WebViewPageLoadErrorEventArgs();
152
153             e.WebView = this;
154             e.PageUrl = pageUrl;
155             e.ErrorCode = (WebViewPageLoadErrorEventArgs.LoadErrorCode)errorCode;
156
157             pageLoadErrorEventHandler?.Invoke(this, e);
158         }
159
160         private void OnScrollEdgeReached(int edge)
161         {
162             scrollEdgeReachedEventHandler?.Invoke(this, new WebViewScrollEdgeReachedEventArgs((WebViewScrollEdgeReachedEventArgs.Edge)edge));
163         }
164
165         private void OnNavigationPolicyDecided(IntPtr maker)
166         {
167             navigationPolicyDecidedEventHandler?.Invoke(this, new WebViewPolicyDecidedEventArgs(new WebPolicyDecisionMaker(maker, true)));
168         }
169
170         internal static new class Property
171         {
172             internal static readonly int URL = Interop.WebView.WebView_Property_URL_get();
173             internal static readonly int USER_AGENT = Interop.WebView.WebView_Property_USER_AGENT_get();
174             internal static readonly int ScrollPosition = Interop.WebView.ScrollPositionGet();
175             internal static readonly int ScrollSize = Interop.WebView.ScrollSizeGet();
176             internal static readonly int ContentSize = Interop.WebView.ContentSizeGet();
177             internal static readonly int Title = Interop.WebView.TitleGet();
178             internal static readonly int VideoHoleEnabled = Interop.WebView.VideoHoleEnabledGet();
179         }
180
181         private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
182         {
183             var webview = (WebView)bindable;
184             if (newValue != null)
185             {
186                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.URL, new Tizen.NUI.PropertyValue((string)newValue));
187             }
188         },
189         defaultValueCreator: (bindable) =>
190         {
191             var webview = (WebView)bindable;
192             string temp;
193             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.URL).Get(out temp);
194             return temp;
195         });
196
197         private static readonly BindableProperty UserAgentProperty = BindableProperty.Create(nameof(UserAgent), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
198         {
199             var webview = (WebView)bindable;
200             if (newValue != null)
201             {
202                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.USER_AGENT, new Tizen.NUI.PropertyValue((string)newValue));
203             }
204         },
205         defaultValueCreator: (bindable) =>
206         {
207             var webview = (WebView)bindable;
208             string temp;
209             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.USER_AGENT).Get(out temp);
210             return temp;
211         });
212
213         private static readonly BindableProperty ScrollPositionProperty = BindableProperty.Create(nameof(ScrollPosition), typeof(Vector2), typeof(WebView), null, propertyChanged: (bindable, oldValue, newValue) =>
214         {
215             var webview = (WebView)bindable;
216             if (newValue != null)
217             {
218                 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition, new Tizen.NUI.PropertyValue((Vector2)newValue));
219             }
220         },
221         defaultValueCreator: (bindable) =>
222         {
223             var webview = (WebView)bindable;
224             Vector2 temp = new Vector2(0.0f, 0.0f);
225             Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollPosition).Get(temp);
226             return temp;
227         });
228
229         private static readonly BindableProperty ScrollSizeProperty = BindableProperty.Create(nameof(ScrollSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
230         {
231             var webview = (WebView)bindable;
232             Vector2 temp = new Vector2(0.0f, 0.0f);
233             Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ScrollSize).Get(temp);
234             return temp;
235         });
236
237         private static readonly BindableProperty ContentSizeProperty = BindableProperty.Create(nameof(ContentSize), typeof(Vector2), typeof(WebView), null, defaultValueCreator: (bindable) =>
238         {
239             var webview = (WebView)bindable;
240             Vector2 temp = new Vector2(0.0f, 0.0f);
241             Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.ContentSize).Get(temp);
242             return temp;
243         });
244
245         private static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(WebView), null, defaultValueCreator: (bindable) =>
246         {
247             var webview = (WebView)bindable;
248             string title;
249             Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.Title).Get(out title);
250             return title;
251         });
252
253         private static readonly BindableProperty VideoHoleEnabledProperty = BindableProperty.Create(nameof(VideoHoleEnabled), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
254         {
255             var webview = (WebView)bindable;
256             if (newValue != null)
257             {
258                 Tizen.NUI.Object.SetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled, new Tizen.NUI.PropertyValue((bool)newValue));
259             }
260         },
261         defaultValueCreator: (bindable) =>
262         {
263             var webview = (WebView)bindable;
264             bool temp;
265             Tizen.NUI.Object.GetProperty(webview.SwigCPtr, WebView.Property.VideoHoleEnabled).Get(out temp);
266             return temp;
267         });
268
269         /// <summary>
270         /// Creates a WebView.
271         /// </summary>
272         [EditorBrowsable(EditorBrowsableState.Never)]
273         public WebView() : this(Interop.WebView.WebView_New(), true)
274         {
275             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276         }
277
278         /// <summary>
279         /// Creates a WebView with local language and time zone.
280         /// <param name="locale">The locale language of Web</param>
281         /// <param name="timezoneId">The time zone Id of Web</param>
282         /// </summary>
283         [EditorBrowsable(EditorBrowsableState.Never)]
284         public WebView(string locale, string timezoneId) : this(Interop.WebView.WebView_New_2(locale, timezoneId), true)
285         {
286             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287         }
288
289         /// <summary>
290         /// Creates a WebView with an args list.
291         /// <param name="args">args array. The first value of array must be program's name.</param>
292         /// </summary>
293         [EditorBrowsable(EditorBrowsableState.Never)]
294         public WebView(string[] args) : this(Interop.WebView.WebView_New_3(args?.Length ?? 0, args), true)
295         {
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297         }
298
299         /// <summary>
300         /// Copy constructor.
301         /// <param name="webView">WebView to copy. The copied WebView will point at the same implementation</param>
302         /// </summary>
303         [EditorBrowsable(EditorBrowsableState.Never)]
304         public WebView(WebView webView) : this(Interop.WebView.new_WebView__SWIG_1(WebView.getCPtr(webView)), true)
305         {
306             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307         }
308
309         /// <summary>
310         /// BackForwardList.
311         /// </summary>
312         [EditorBrowsable(EditorBrowsableState.Never)]
313         public WebBackForwardList BackForwardList { get; }
314
315         /// <summary>
316         /// Context.
317         /// </summary>
318         [EditorBrowsable(EditorBrowsableState.Never)]
319         public WebContext Context { get; }
320
321         /// <summary>
322         /// CookieManager.
323         /// </summary>
324         [EditorBrowsable(EditorBrowsableState.Never)]
325         public WebCookieManager CookieManager { get; }
326
327         /// <summary>
328         /// BackForwardList.
329         /// </summary>
330         [EditorBrowsable(EditorBrowsableState.Never)]
331         public WebSettings Settings { get; }
332
333         /// <summary>
334         /// The url to load.
335         /// </summary>
336         [EditorBrowsable(EditorBrowsableState.Never)]
337         public string Url
338         {
339             get
340             {
341                 return (string)GetValue(UrlProperty);
342             }
343             set
344             {
345                 SetValue(UrlProperty, value);
346                 NotifyPropertyChanged();
347             }
348         }
349
350         /// <summary>
351         /// Deprecated. The cache model of the current WebView.
352         /// </summary>
353         [EditorBrowsable(EditorBrowsableState.Never)]
354         public CacheModel CacheModel
355         {
356             get
357             {
358                 return (CacheModel)Context.CacheModel;
359             }
360             set
361             {
362                 Context.CacheModel = (WebContext.CacheModelType)value;
363             }
364         }
365
366         /// <summary>
367         /// Deprecated. The cookie acceptance policy.
368         /// </summary>
369         [EditorBrowsable(EditorBrowsableState.Never)]
370         public CookieAcceptPolicy CookieAcceptPolicy
371         {
372             get
373             {
374                 return (CookieAcceptPolicy)CookieManager.CookieAcceptPolicy;
375             }
376             set
377             {
378                 CookieManager.CookieAcceptPolicy = (WebCookieManager.CookieAcceptPolicyType)value;
379             }
380         }
381
382         /// <summary>
383         /// The user agent string.
384         /// </summary>
385         [EditorBrowsable(EditorBrowsableState.Never)]
386         public string UserAgent
387         {
388             get
389             {
390                 return (string)GetValue(UserAgentProperty);
391             }
392             set
393             {
394                 SetValue(UserAgentProperty, value);
395                 NotifyPropertyChanged();
396             }
397         }
398
399         /// <summary>
400         /// Deprecated. Whether JavaScript is enabled.
401         /// </summary>
402         [EditorBrowsable(EditorBrowsableState.Never)]
403         public bool EnableJavaScript
404         {
405             get
406             {
407                 return Settings.EnableJavaScript;
408             }
409             set
410             {
411                 Settings.EnableJavaScript = value;
412             }
413         }
414
415         /// <summary>
416         /// Deprecated. Whether images can be loaded automatically.
417         /// </summary>
418         [EditorBrowsable(EditorBrowsableState.Never)]
419         public bool LoadImagesAutomatically
420         {
421             get
422             {
423                 return Settings.AllowImagesLoadAutomatically;
424             }
425             set
426             {
427                 Settings.AllowImagesLoadAutomatically = value;
428             }
429         }
430
431         /// <summary>
432         /// The default text encoding name.<br />
433         /// e.g. "UTF-8"<br />
434         /// </summary>
435         [EditorBrowsable(EditorBrowsableState.Never)]
436         public string DefaultTextEncodingName
437         {
438             get
439             {
440                 return Settings.DefaultTextEncodingName;
441             }
442             set
443             {
444                 Settings.DefaultTextEncodingName = value;
445             }
446         }
447
448         /// <summary>
449         /// The default font size in pixel.
450         /// </summary>
451         [EditorBrowsable(EditorBrowsableState.Never)]
452         public int DefaultFontSize
453         {
454             get
455             {
456                 return Settings.DefaultFontSize;
457             }
458             set
459             {
460                 Settings.DefaultFontSize = value;
461             }
462         }
463
464         /// <summary>
465         /// The postion of scroll.
466         /// </summary>
467         [EditorBrowsable(EditorBrowsableState.Never)]
468         public Position ScrollPosition
469         {
470             get
471             {
472                 Vector2 pv = (Vector2)GetValue(ScrollPositionProperty);
473                 return new Position(pv.X, pv.Y);
474             }
475             set
476             {
477                 if (value != null)
478                 {
479                     Position pv = value;
480                     Vector2 vpv = new Vector2(pv.X, pv.Y);
481                     SetValue(ScrollPositionProperty, vpv);
482                     NotifyPropertyChanged();
483                 }
484             }
485         }
486
487         /// <summary>
488         /// The size of scroll, read-only.
489         /// </summary>
490         [EditorBrowsable(EditorBrowsableState.Never)]
491         public Size ScrollSize
492         {
493             get
494             {
495                 Vector2 sv = (Vector2)GetValue(ScrollSizeProperty);
496                 return new Size(sv.Width, sv.Height);
497             }
498         }
499
500         /// <summary>
501         /// The size of content, read-only.
502         /// </summary>
503         [EditorBrowsable(EditorBrowsableState.Never)]
504         public Size ContentSize
505         {
506             get
507             {
508                 Vector2 sv = (Vector2)GetValue(ContentSizeProperty);
509                 return new Size(sv.Width, sv.Height);
510             }
511         }
512
513         /// <summary>
514         /// Whether video hole is enabled or not.
515         /// </summary>
516         [EditorBrowsable(EditorBrowsableState.Never)]
517         public bool VideoHoleEnabled
518         {
519             get
520             {
521                 return (bool)GetValue(VideoHoleEnabledProperty);
522             }
523             set
524             {
525                 SetValue(VideoHoleEnabledProperty, value);
526                 NotifyPropertyChanged();
527             }
528         }
529
530         /// <summary>
531         /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
532         /// This signal is emitted when page loading has started.<br />
533         /// </summary>
534         [EditorBrowsable(EditorBrowsableState.Never)]
535         public event EventHandler<WebViewPageLoadEventArgs> PageLoadStarted
536         {
537             add
538             {
539                 if (pageLoadStartedEventHandler == null)
540                 {
541                     pageLoadStartedCallback = OnPageLoadStarted;
542                     IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadStartedCallback);
543                     Interop.WebView.RegisterPageLoadStartedCallback(SwigCPtr, new HandleRef(this, ip));
544                 }
545                 pageLoadStartedEventHandler += value;
546             }
547             remove
548             {
549                 pageLoadStartedEventHandler -= value;
550             }
551         }
552
553         /// <summary>
554         /// Event for the PageLoadFinished signal which can be used to subscribe or unsubscribe the event handler.<br />
555         /// This signal is emitted when page loading has finished.<br />
556         /// </summary>
557         [EditorBrowsable(EditorBrowsableState.Never)]
558         public event EventHandler<WebViewPageLoadEventArgs> PageLoadFinished
559         {
560             add
561             {
562                 if (pageLoadFinishedEventHandler == null)
563                 {
564                     pageLoadFinishedCallback = OnPageLoadFinished;
565                     IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadFinishedCallback);
566                     Interop.WebView.RegisterPageLoadFinishedCallback(SwigCPtr, new HandleRef(this, ip));
567                 }
568                 pageLoadFinishedEventHandler += value;
569             }
570             remove
571             {
572                 pageLoadFinishedEventHandler -= value;
573             }
574         }
575
576         /// <summary>
577         /// Event for the PageLoadError signal which can be used to subscribe or unsubscribe the event handler.<br />
578         /// This signal is emitted when there's an error in page loading.<br />
579         /// </summary>
580         [EditorBrowsable(EditorBrowsableState.Never)]
581         public event EventHandler<WebViewPageLoadErrorEventArgs> PageLoadError
582         {
583             add
584             {
585                 pageLoadErrorCallback = OnPageLoadError;
586                 IntPtr ip = Marshal.GetFunctionPointerForDelegate(pageLoadErrorCallback);
587                 Interop.WebView.RegisterPageLoadErrorCallback(SwigCPtr, new HandleRef(this, ip));
588             }
589             remove
590             {
591                 pageLoadErrorEventHandler -= value;
592             }
593         }
594
595         /// <summary>
596         /// Event for the ScrollEdgeReached signal which can be used to subscribe or unsubscribe the event handler.<br />
597         /// This signal is emitted when web view is scrolled to edge.<br />
598         /// </summary>
599         [EditorBrowsable(EditorBrowsableState.Never)]
600         public event EventHandler<WebViewScrollEdgeReachedEventArgs> ScrollEdgeReached
601         {
602             add
603             {
604                 scrollEdgeReachedCallback = OnScrollEdgeReached;
605                 IntPtr ip = Marshal.GetFunctionPointerForDelegate(scrollEdgeReachedCallback);
606                 Interop.WebView.RegisterScrollEdgeReachedCallback(SwigCPtr, new HandleRef(this, ip));
607             }
608             remove
609             {
610                 scrollEdgeReachedEventHandler -= value;
611             }
612         }
613
614         /// <summary>
615         /// Event for the NavigationPolicyDecided signal which can be used to subscribe or unsubscribe the event handler.<br />
616         /// This signal is emitted when response policy would be decided.<br />
617         /// </summary>
618         [EditorBrowsable(EditorBrowsableState.Never)]
619         public event EventHandler<WebViewPolicyDecidedEventArgs> NavigationPolicyDecided
620         {
621             add
622             {
623                 if (navigationPolicyDecidedEventHandler == null)
624                 {
625                     navigationPolicyDecidedCallback = OnNavigationPolicyDecided;
626                     IntPtr ip = Marshal.GetFunctionPointerForDelegate(navigationPolicyDecidedCallback);
627                     Interop.WebView.RegisterNavigationPolicyDecidedCallback(SwigCPtr, new HandleRef(this, ip));
628                 }
629                 navigationPolicyDecidedEventHandler += value;
630             }
631             remove
632             {
633                 navigationPolicyDecidedEventHandler -= value;
634             }
635         }
636
637         /// <summary>
638         /// Gets title of web page.
639         /// </summary>
640         [EditorBrowsable(EditorBrowsableState.Never)]
641         public string Title
642         {
643             get
644             {
645                 return (string)GetValue(TitleProperty);
646             }
647         }
648
649         /// <summary>
650         /// Gets fav icon.
651         /// </summary>
652         [EditorBrowsable(EditorBrowsableState.Never)]
653         public ImageView Favicon
654         {
655             get
656             {
657                 global::System.IntPtr imageView = Interop.WebView.WebView_GetFavicon(swigCPtr);
658                 if (imageView == IntPtr.Zero)
659                     return null;
660                 return new ImageView(imageView, false);
661             }
662         }
663
664         /// <summary>
665         /// Loads a html.
666         /// <param name="url">The path of Web</param>
667         /// </summary>
668         [EditorBrowsable(EditorBrowsableState.Never)]
669         public void LoadUrl(string url)
670         {
671             Interop.WebView.WebView_LoadUrl(swigCPtr, url);
672             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
673         }
674
675         /// <summary>
676         /// Deprecated. Loads a html by string.
677         /// <param name="data">The data of Web</param>
678         /// </summary>
679         [EditorBrowsable(EditorBrowsableState.Never)]
680         public void LoadHTMLString(string data)
681         {
682             Interop.WebView.LoadHtmlString(SwigCPtr, data);
683             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684         }
685
686         /// <summary>
687         /// Loads a html by string.
688         /// <param name="data">The data of Web</param>
689         /// </summary>
690         [EditorBrowsable(EditorBrowsableState.Never)]
691         public void LoadHtmlString(string data)
692         {
693             Interop.WebView.LoadHtmlString(SwigCPtr, data);
694             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
695         }
696
697         /// <summary>
698         /// Reloads the Web
699         /// </summary>
700         [EditorBrowsable(EditorBrowsableState.Never)]
701         public void Reload()
702         {
703             Interop.WebView.WebView_Reload(swigCPtr);
704             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
705         }
706
707         /// <summary>
708         /// Stops loading the Web
709         /// </summary>
710         [EditorBrowsable(EditorBrowsableState.Never)]
711         public void StopLoading()
712         {
713             Interop.WebView.WebView_StopLoading(swigCPtr);
714             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715         }
716
717         /// <summary>
718         /// Suspends the operation.
719         /// </summary>
720         [EditorBrowsable(EditorBrowsableState.Never)]
721         public void Suspend()
722         {
723             Interop.WebView.WebView_Suspend(swigCPtr);
724             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725         }
726
727         /// <summary>
728         /// Resumes the operation after calling Suspend()
729         /// </summary>
730         [EditorBrowsable(EditorBrowsableState.Never)]
731         public void Resume()
732         {
733             Interop.WebView.WebView_Resume(swigCPtr);
734             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735         }
736
737         /// <summary>
738         /// Scroll web view by deltaX and detlaY.
739         /// <param name="deltaX">The deltaX of scroll</param>
740         /// <param name="deltaY">The deltaY of scroll</param>
741         /// </summary>
742         [EditorBrowsable(EditorBrowsableState.Never)]
743         public void ScrollBy(int deltaX, int deltaY)
744         {
745             Interop.WebView.ScrollBy(SwigCPtr, deltaX, deltaY);
746             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747         }
748
749         /// <summary>
750         /// Goes to the back
751         /// </summary>
752         [EditorBrowsable(EditorBrowsableState.Never)]
753         public void GoBack()
754         {
755             Interop.WebView.WebView_GoBack(swigCPtr);
756             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757         }
758
759         /// <summary>
760         /// Goes to the forward
761         /// </summary>
762         [EditorBrowsable(EditorBrowsableState.Never)]
763         public void GoForward()
764         {
765             Interop.WebView.WebView_GoForward(swigCPtr);
766             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767         }
768
769         /// <summary>
770         /// Returns whether backward is possible.
771         /// <returns>True if backward is possible, false otherwise</returns>
772         /// </summary>
773         [EditorBrowsable(EditorBrowsableState.Never)]
774         public bool CanGoBack()
775         {
776             bool ret = Interop.WebView.WebView_CanGoBack(swigCPtr);
777             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778             return ret;
779         }
780
781         /// <summary>
782         /// Returns whether forward is possible.
783         /// <returns>True if forward is possible, false otherwise</returns>
784         /// </summary>
785         [EditorBrowsable(EditorBrowsableState.Never)]
786         public bool CanGoForward()
787         {
788             bool ret = Interop.WebView.WebView_CanGoForward(swigCPtr);
789             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790             return ret;
791         }
792
793         /// <summary>
794         /// The callback function that is invoked when the message is received from the script.
795         /// </summary>
796         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
797         [EditorBrowsable(EditorBrowsableState.Never)]
798         public delegate void JavaScriptMessageHandler(string message);
799
800         /// <summary>
801         /// Evaluates JavaScript code represented as a string.
802         /// <param name="script">The JavaScript code</param>
803         /// </summary>
804         [EditorBrowsable(EditorBrowsableState.Never)]
805         public void EvaluateJavaScript(string script)
806         {
807             Interop.WebView.WebView_EvaluateJavaScript(swigCPtr, script, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
808             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
809         }
810
811         // For rooting handlers
812         internal Dictionary<string, JavaScriptMessageHandler> handlerRootMap = new Dictionary<string, JavaScriptMessageHandler>();
813
814         /// <summary>
815         /// Add a message handler into the WebView.
816         /// <param name="objectName">The name of exposed object</param>
817         /// <param name="handler">The callback function</param>
818         /// </summary>
819         [EditorBrowsable(EditorBrowsableState.Never)]
820         public void AddJavaScriptMessageHandler(string objectName, JavaScriptMessageHandler handler)
821         {
822             if (handlerRootMap.ContainsKey(objectName))
823             {
824                 return;
825             }
826
827             handlerRootMap.Add(objectName, handler);
828
829             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(handler);
830             Interop.WebView.WebView_AddJavaScriptMessageHandler(swigCPtr, objectName, new System.Runtime.InteropServices.HandleRef(this, ip));
831
832             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
833         }
834
835         /// <summary>
836         /// Clears title resources of current WebView.
837         /// </summary>
838         [EditorBrowsable(EditorBrowsableState.Never)]
839         public void ClearAllTilesResources()
840         {
841             Interop.WebView.WebView_ClearAllTilesResources(swigCPtr);
842             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
843         }
844
845         /// <summary>
846         /// Clears the history of current WebView.
847         /// </summary>
848         [EditorBrowsable(EditorBrowsableState.Never)]
849         public void ClearHistory()
850         {
851             Interop.WebView.WebView_ClearHistory(swigCPtr);
852             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853         }
854
855         /// <summary>
856         /// Deprecated. Clears the cache of current WebView.
857         /// </summary>
858         [EditorBrowsable(EditorBrowsableState.Never)]
859         public void ClearCache()
860         {
861             Context.ClearCache();
862         }
863
864         /// <summary>
865         /// Deprecated. Clears all the cookies of current WebView.
866         /// </summary>
867         [EditorBrowsable(EditorBrowsableState.Never)]
868         public void ClearCookies()
869         {
870             CookieManager.ClearCookies();
871         }
872
873         /// <summary>
874         /// Sets the tts focus to the webview.
875         /// Please note that it only works when the webview does not have keyinput focus.
876         /// If the webview has a keyinput focus, it also has tts focus so calling SetTtsFocus(false) is ignored.
877         /// </summary>
878         [EditorBrowsable(EditorBrowsableState.Never)]
879         public void SetTtsFocus(bool focused)
880         {
881             Interop.WebView.SetTtsFocus(SwigCPtr, focused);
882             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883         }
884
885         /// <summary>
886         /// Get a plain text of current web page asynchronously.
887         /// Please note that it gets plain text of currently loaded page so please call this method after page load finished.
888         /// <param name="callback">The callback for getting plain text</param>
889         /// </summary>
890         [EditorBrowsable(EditorBrowsableState.Never)]
891         public void GetPlainTextAsynchronously(PlainTextReceivedCallback callback)
892         {
893             plainTextReceivedCallback = callback;
894             System.IntPtr ip = Marshal.GetFunctionPointerForDelegate(plainTextReceivedCallback);
895             Interop.WebView.GetPlainTextAsynchronously(SwigCPtr, new HandleRef(this, ip));
896             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
897         }
898     }
899 }