[NUI] Fix Svace issue (#949)
[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         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34
35         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
36         private delegate void WebViewPageLoadCallbackDelegate(IntPtr data, string pageUrl);
37
38         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
39         private delegate void WebViewPageLoadErrorCallbackDelegate(IntPtr data, string pageUrl, int errorCode);
40
41         private readonly WebViewPageLoadSignal pageLoadStartedSignal;
42         private EventHandler<WebViewPageLoadEventArgs> pageLoadStartedEventHandler;
43         private WebViewPageLoadCallbackDelegate pageLoadStartedCallback;
44
45         private readonly WebViewPageLoadSignal pageLoadFinishedSignal;
46         private EventHandler<WebViewPageLoadEventArgs> pageLoadFinishedEventHandler;
47         private WebViewPageLoadCallbackDelegate pageLoadFinishedCallback;
48
49         private readonly WebViewPageLoadErrorSignal pageLoadErrorSignal;
50         private EventHandler<WebViewPageLoadErrorEventArgs> pageLoadErrorEventHandler;
51         private WebViewPageLoadErrorCallbackDelegate pageLoadErrorCallback;
52
53         internal WebView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WebView.WebView_SWIGUpcast(cPtr), cMemoryOwn)
54         {
55             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
56
57             pageLoadStartedSignal = new WebViewPageLoadSignal(Interop.WebView.new_WebViewPageLoadSignal_PageLoadStarted(swigCPtr));
58             pageLoadFinishedSignal = new WebViewPageLoadSignal(Interop.WebView.new_WebViewPageLoadSignal_PageLoadFinished(swigCPtr));
59             pageLoadErrorSignal = new WebViewPageLoadErrorSignal(Interop.WebView.new_WebViewPageLoadErrorSignal_PageLoadError(swigCPtr));
60         }
61
62         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebView obj)
63         {
64             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
65         }
66
67         internal WebView Assign(WebView webView)
68         {
69             WebView ret = new WebView(Interop.WebView.WebView_Assign(swigCPtr, WebView.getCPtr(webView)), false);
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71             return ret;
72         }
73
74         internal static WebView DownCast(BaseHandle handle)
75         {
76             WebView ret = new WebView(Interop.WebView.WebView_DownCast(BaseHandle.getCPtr(handle)), true);
77             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78             return ret;
79         }
80
81         /// <summary>
82         /// Dispose for IDisposable pattern
83         /// </summary>
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         protected override void Dispose(DisposeTypes type)
86         {
87             if (disposed)
88             {
89                 return;
90             }
91
92             if (type == DisposeTypes.Explicit)
93             {
94                 //Called by User
95                 //Release your own managed resources here.
96                 //You should release all of your own disposable objects here.
97                 pageLoadStartedSignal.Dispose();
98                 pageLoadFinishedSignal.Dispose();
99                 pageLoadErrorSignal.Dispose();
100             }
101
102             //Release your own unmanaged resources here.
103             //You should not access any managed member here except static instance.
104             //because the execution order of Finalizes is non-deterministic.
105
106             if (swigCPtr.Handle != global::System.IntPtr.Zero)
107             {
108                 if (swigCMemOwn)
109                 {
110                     swigCMemOwn = false;
111                     Interop.WebView.delete_WebView(swigCPtr);
112                 }
113                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
114             }
115
116             base.Dispose(type);
117         }
118
119         private void OnPageLoadStarted(IntPtr data, string pageUrl)
120         {
121             WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
122
123             e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
124             e.PageUrl = pageUrl;
125
126             if (pageLoadStartedEventHandler != null)
127             {
128                 pageLoadStartedEventHandler(this, e);
129             }
130         }
131
132         private void OnPageLoadFinished(IntPtr data, string pageUrl)
133         {
134             WebViewPageLoadEventArgs e = new WebViewPageLoadEventArgs();
135
136             e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
137             e.PageUrl = pageUrl;
138
139             if (pageLoadFinishedEventHandler != null)
140             {
141                 pageLoadFinishedEventHandler(this, e);
142             }
143         }
144
145         private void OnPageLoadError(IntPtr data, string pageUrl, int errorCode)
146         {
147             WebViewPageLoadErrorEventArgs e = new WebViewPageLoadErrorEventArgs();
148
149             e.WebView = Registry.GetManagedBaseHandleFromNativePtr(data) as WebView;
150             e.PageUrl = pageUrl;
151             e.ErrorCode = (WebViewPageLoadErrorEventArgs.LoadErrorCode)errorCode;
152
153             if (pageLoadErrorEventHandler != null)
154             {
155                 pageLoadErrorEventHandler(this, e);
156             }
157         }
158
159         internal static new class Property
160         {
161             internal static readonly int URL = Interop.WebView.WebView_Property_URL_get();
162             internal static readonly int CACHE_MODEL = Interop.WebView.WebView_Property_CACHE_MODEL_get();
163             internal static readonly int COOKIE_ACCEPT_POLICY = Interop.WebView.WebView_Property_COOKIE_ACCEPT_POLICY_get();
164             internal static readonly int USER_AGENT = Interop.WebView.WebView_Property_USER_AGENT_get();
165             internal static readonly int ENABLE_JAVASCRIPT = Interop.WebView.WebView_Property_ENABLE_JAVASCRIPT_get();
166             internal static readonly int LOAD_IMAGES_AUTOMATICALLY = Interop.WebView.WebView_Property_LOAD_IMAGES_AUTOMATICALLY_get();
167             internal static readonly int DEFAULT_TEXT_ENCODING_NAME = Interop.WebView.WebView_Property_DEFAULT_TEXT_ENCODING_NAME_get();
168             internal static readonly int DEFAULT_FONT_SIZE = Interop.WebView.WebView_Property_DEFAULT_FONT_SIZE_get();
169         }
170
171         private static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
172         {
173             var webview = (WebView)bindable;
174             if (newValue != null)
175             {
176                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.URL, new Tizen.NUI.PropertyValue((string)newValue));
177             }
178         },
179         defaultValueCreator: (bindable) =>
180         {
181             var webview = (WebView)bindable;
182             string temp;
183             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.URL).Get(out temp);
184             return temp;
185         });
186
187         private static readonly BindableProperty CacheModelProperty = BindableProperty.Create(nameof(CacheModel), typeof(CacheModel), typeof(WebView), CacheModel.DocumentViewer, propertyChanged: (bindable, oldValue, newValue) =>
188         {
189             var webview = (WebView)bindable;
190             if (newValue != null)
191             {
192                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.CACHE_MODEL, new Tizen.NUI.PropertyValue((int)newValue));
193             }
194         },
195         defaultValueCreator: (bindable) =>
196         {
197             var webview = (WebView)bindable;
198             string temp;
199             if (Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.CACHE_MODEL).Get(out temp) == false)
200             {
201                 NUILog.Error("CacheModel get error!");
202             }
203             switch (temp)
204             {
205                 case "DOCUMENT_VIEWER": return CacheModel.DocumentViewer;
206                 case "DOCUMENT_BROWSER": return CacheModel.DocumentBrowser;
207                 default: return CacheModel.PrimaryWebBrowser;
208             }
209         });
210
211         private static readonly BindableProperty CookieAcceptPolicyProperty = BindableProperty.Create(nameof(CookieAcceptPolicy), typeof(CookieAcceptPolicy), typeof(WebView), CookieAcceptPolicy.NoThirdParty, propertyChanged: (bindable, oldValue, newValue) =>
212         {
213             var webview = (WebView)bindable;
214             if (newValue != null)
215             {
216                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.COOKIE_ACCEPT_POLICY, new Tizen.NUI.PropertyValue((int)newValue));
217             }
218         },
219         defaultValueCreator: (bindable) =>
220         {
221             var webview = (WebView)bindable;
222             string temp;
223             if (Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.COOKIE_ACCEPT_POLICY).Get(out temp) == false)
224             {
225                 NUILog.Error("CookieAcceptPolicy get error!");
226             }
227             switch (temp)
228             {
229                 case "ALWAYS": return CookieAcceptPolicy.Always;
230                 case "NEVER": return CookieAcceptPolicy.Never;
231                 default: return CookieAcceptPolicy.NoThirdParty;
232             }
233         });
234
235         private static readonly BindableProperty UserAgentProperty = BindableProperty.Create(nameof(UserAgent), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
236         {
237             var webview = (WebView)bindable;
238             if (newValue != null)
239             {
240                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.USER_AGENT, new Tizen.NUI.PropertyValue((string)newValue));
241             }
242         },
243         defaultValueCreator: (bindable) =>
244         {
245             var webview = (WebView)bindable;
246             string temp;
247             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.USER_AGENT).Get(out temp);
248             return temp;
249         });
250
251         private static readonly BindableProperty EnableJavaScriptProperty = BindableProperty.Create(nameof(EnableJavaScript), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
252         {
253             var webview = (WebView)bindable;
254             if (newValue != null)
255             {
256                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.ENABLE_JAVASCRIPT, new Tizen.NUI.PropertyValue((bool)newValue));
257             }
258         },
259         defaultValueCreator: (bindable) =>
260         {
261             var webview = (WebView)bindable;
262             bool temp;
263             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.ENABLE_JAVASCRIPT).Get(out temp);
264             return temp;
265         });
266
267         private static readonly BindableProperty LoadImagesAutomaticallyProperty = BindableProperty.Create(nameof(LoadImagesAutomatically), typeof(bool), typeof(WebView), true, propertyChanged: (bindable, oldValue, newValue) =>
268         {
269             var webview = (WebView)bindable;
270             if (newValue != null)
271             {
272                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.LOAD_IMAGES_AUTOMATICALLY, new Tizen.NUI.PropertyValue((bool)newValue));
273             }
274         },
275         defaultValueCreator: (bindable) =>
276         {
277             var webview = (WebView)bindable;
278             bool temp;
279             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.LOAD_IMAGES_AUTOMATICALLY).Get(out temp);
280             return temp;
281         });
282
283         private static readonly BindableProperty DefaultTextEncodingNameProperty = BindableProperty.Create(nameof(DefaultTextEncodingName), typeof(string), typeof(WebView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
284         {
285             var webview = (WebView)bindable;
286             if (newValue != null)
287             {
288                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.DEFAULT_TEXT_ENCODING_NAME, new Tizen.NUI.PropertyValue((string)newValue));
289             }
290         },
291         defaultValueCreator: (bindable) =>
292         {
293             var webview = (WebView)bindable;
294             string temp;
295             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.DEFAULT_TEXT_ENCODING_NAME).Get(out temp);
296             return temp;
297         });
298
299         private static readonly BindableProperty DefaultFontSizeProperty = BindableProperty.Create(nameof(DefaultFontSize), typeof(int), typeof(WebView), 16, propertyChanged: (bindable, oldValue, newValue) =>
300         {
301             var webview = (WebView)bindable;
302             if (newValue != null)
303             {
304                 Tizen.NUI.Object.SetProperty(webview.swigCPtr, WebView.Property.DEFAULT_FONT_SIZE, new Tizen.NUI.PropertyValue((int)newValue));
305             }
306         },
307         defaultValueCreator: (bindable) =>
308         {
309             var webview = (WebView)bindable;
310             int temp;
311             Tizen.NUI.Object.GetProperty(webview.swigCPtr, WebView.Property.DEFAULT_FONT_SIZE).Get(out temp);
312             return temp;
313         });
314
315         /// <summary>
316         /// Creates an uninitialized WebView.
317         /// </summary>
318         [EditorBrowsable(EditorBrowsableState.Never)]
319         public WebView() : this(Interop.WebView.WebView_New(), true)
320         {
321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322
323         }
324
325         /// <summary>
326         /// Creates an uninitialized WebView.
327         /// <param name="locale">The locale of Web</param>
328         /// <param name="timezoneId">The timezoneId of Web</param>
329         /// </summary>
330         [EditorBrowsable(EditorBrowsableState.Never)]
331         public WebView(string locale, string timezoneId) : this(Interop.WebView.WebView_New_2(locale, timezoneId), true)
332         {
333             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334         }
335
336         /// <summary>
337         /// Copy constructor.
338         /// <param name="webView">WebView to copy. The copied WebView will point at the same implementation</param>
339         /// </summary>
340         [EditorBrowsable(EditorBrowsableState.Never)]
341         public WebView(WebView webView) : this(Interop.WebView.new_WebView__SWIG_1(WebView.getCPtr(webView)), true)
342         {
343             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344         }
345
346         /// <summary>
347         /// The url to load.
348         /// </summary>
349         [EditorBrowsable(EditorBrowsableState.Never)]
350         public string Url
351         {
352             get
353             {
354                 return (string)GetValue(UrlProperty);
355             }
356             set
357             {
358                 SetValue(UrlProperty, value);
359                 NotifyPropertyChanged();
360             }
361         }
362
363         /// <summary>
364         /// The cache model of the current WebView.
365         /// </summary>
366         [EditorBrowsable(EditorBrowsableState.Never)]
367         public CacheModel CacheModel
368         {
369             get
370             {
371                 return (CacheModel)GetValue(CacheModelProperty);
372             }
373             set
374             {
375                 SetValue(CacheModelProperty, value);
376                 NotifyPropertyChanged();
377             }
378         }
379
380         /// <summary>
381         /// The cookie acceptance policy.
382         /// </summary>
383         [EditorBrowsable(EditorBrowsableState.Never)]
384         public CookieAcceptPolicy CookieAcceptPolicy
385         {
386             get
387             {
388                 return (CookieAcceptPolicy)GetValue(CookieAcceptPolicyProperty);
389             }
390             set
391             {
392                 SetValue(CookieAcceptPolicyProperty, value);
393                 NotifyPropertyChanged();
394             }
395         }
396
397         /// <summary>
398         /// The user agent string.
399         /// </summary>
400         [EditorBrowsable(EditorBrowsableState.Never)]
401         public string UserAgent
402         {
403             get
404             {
405                 return (string)GetValue(UserAgentProperty);
406             }
407             set
408             {
409                 SetValue(UserAgentProperty, value);
410                 NotifyPropertyChanged();
411             }
412         }
413
414         /// <summary>
415         /// Whether JavaScript is enabled.
416         /// </summary>
417         [EditorBrowsable(EditorBrowsableState.Never)]
418         public bool EnableJavaScript
419         {
420             get
421             {
422                 return (bool)GetValue(EnableJavaScriptProperty);
423             }
424             set
425             {
426                 SetValue(EnableJavaScriptProperty, value);
427                 NotifyPropertyChanged();
428             }
429         }
430
431         /// <summary>
432         /// Whether images can be loaded automatically.
433         /// </summary>
434         [EditorBrowsable(EditorBrowsableState.Never)]
435         public bool LoadImagesAutomatically
436         {
437             get
438             {
439                 return (bool)GetValue(LoadImagesAutomaticallyProperty);
440             }
441             set
442             {
443                 SetValue(LoadImagesAutomaticallyProperty, value);
444                 NotifyPropertyChanged();
445             }
446         }
447
448         /// <summary>
449         /// The default text encoding name.<br />
450         /// e.g. "UTF-8"<br />
451         /// </summary>
452         [EditorBrowsable(EditorBrowsableState.Never)]
453         public string DefaultTextEncodingName
454         {
455             get
456             {
457                 return (string)GetValue(DefaultTextEncodingNameProperty);
458             }
459             set
460             {
461                 SetValue(DefaultTextEncodingNameProperty, value);
462                 NotifyPropertyChanged();
463             }
464         }
465
466         /// <summary>
467         /// The default font size in pixel.
468         /// </summary>
469         [EditorBrowsable(EditorBrowsableState.Never)]
470         public int DefaultFontSize
471         {
472             get
473             {
474                 return (int)GetValue(DefaultFontSizeProperty);
475             }
476             set
477             {
478                 SetValue(DefaultFontSizeProperty, value);
479                 NotifyPropertyChanged();
480             }
481         }
482
483         /// <summary>
484         /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
485         /// This signal is emitted when page loading has started.<br />
486         /// </summary>
487         [EditorBrowsable(EditorBrowsableState.Never)]
488         public event EventHandler<WebViewPageLoadEventArgs> PageLoadStarted
489         {
490             add
491             {
492                 if (pageLoadStartedEventHandler == null)
493                 {
494                     pageLoadStartedCallback = (OnPageLoadStarted);
495                     pageLoadStartedSignal.Connect(pageLoadStartedCallback);
496                 }
497                 pageLoadStartedEventHandler += value;
498             }
499             remove
500             {
501                 pageLoadStartedEventHandler -= value;
502                 if (pageLoadStartedEventHandler == null && pageLoadStartedCallback != null)
503                 {
504                     pageLoadStartedSignal.Disconnect(pageLoadStartedCallback);
505                 }
506             }
507         }
508
509         /// <summary>
510         /// Event for the PageLoadFinished signal which can be used to subscribe or unsubscribe the event handler.<br />
511         /// This signal is emitted when page loading has finished.<br />
512         /// </summary>
513         [EditorBrowsable(EditorBrowsableState.Never)]
514         public event EventHandler<WebViewPageLoadEventArgs> PageLoadFinished
515         {
516             add
517             {
518                 if (pageLoadFinishedEventHandler == null)
519                 {
520                     pageLoadFinishedCallback = (OnPageLoadFinished);
521                     pageLoadFinishedSignal.Connect(pageLoadFinishedCallback);
522                 }
523                 pageLoadFinishedEventHandler += value;
524             }
525             remove
526             {
527                 pageLoadFinishedEventHandler -= value;
528                 if (pageLoadFinishedEventHandler == null && pageLoadFinishedCallback != null)
529                 {
530                     pageLoadFinishedSignal.Disconnect(pageLoadFinishedCallback);
531                 }
532             }
533         }
534
535         /// <summary>
536         /// Event for the PageLoadError signal which can be used to subscribe or unsubscribe the event handler.<br />
537         /// This signal is emitted when there's an error in page loading.<br />
538         /// </summary>
539         [EditorBrowsable(EditorBrowsableState.Never)]
540         public event EventHandler<WebViewPageLoadErrorEventArgs> PageLoadError
541         {
542             add
543             {
544                 if (pageLoadErrorEventHandler == null)
545                 {
546                     pageLoadErrorCallback = (OnPageLoadError);
547                     pageLoadErrorSignal.Connect(pageLoadErrorCallback);
548                 }
549                 pageLoadErrorEventHandler += value;
550             }
551             remove
552             {
553                 pageLoadErrorEventHandler -= value;
554                 if (pageLoadErrorEventHandler == null && pageLoadErrorCallback != null)
555                 {
556                     pageLoadErrorSignal.Disconnect(pageLoadErrorCallback);
557                 }
558             }
559         }
560
561         /// <summary>
562         /// Loads a html.
563         /// <param name="url">The path of Web</param>
564         /// </summary>
565         [EditorBrowsable(EditorBrowsableState.Never)]
566         public void LoadUrl(string url)
567         {
568             Interop.WebView.WebView_LoadUrl(swigCPtr, url);
569             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
570         }
571
572         /// <summary>
573         /// Returns the URL of the Web
574         /// <param name="data">The data of Web</param>
575         /// </summary>
576         [EditorBrowsable(EditorBrowsableState.Never)]
577         public void LoadHTMLString(string data)
578         {
579             Interop.WebView.WebView_LoadHTMLString(swigCPtr, data);
580             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581         }
582
583         /// <summary>
584         /// Reloads the Web
585         /// </summary>
586         [EditorBrowsable(EditorBrowsableState.Never)]
587         public void Reload()
588         {
589             Interop.WebView.WebView_Reload(swigCPtr);
590             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
591         }
592
593         /// <summary>
594         /// Stops loading the Web
595         /// </summary>
596         [EditorBrowsable(EditorBrowsableState.Never)]
597         public void StopLoading()
598         {
599             Interop.WebView.WebView_StopLoading(swigCPtr);
600             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601         }
602
603         /// <summary>
604         /// Suspends the operation.
605         /// </summary>
606         [EditorBrowsable(EditorBrowsableState.Never)]
607         public void Suspend()
608         {
609             Interop.WebView.WebView_Suspend(swigCPtr);
610             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611         }
612
613         /// <summary>
614         /// Resumes the operation after calling Suspend()
615         /// </summary>
616         [EditorBrowsable(EditorBrowsableState.Never)]
617         public void Resume()
618         {
619             Interop.WebView.WebView_Resume(swigCPtr);
620             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621         }
622
623         /// <summary>
624         /// Goes to the back
625         /// </summary>
626         [EditorBrowsable(EditorBrowsableState.Never)]
627         public void GoBack()
628         {
629             Interop.WebView.WebView_GoBack(swigCPtr);
630             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631         }
632
633         /// <summary>
634         /// Goes to the forward
635         /// </summary>
636         [EditorBrowsable(EditorBrowsableState.Never)]
637         public void GoForward()
638         {
639             Interop.WebView.WebView_GoForward(swigCPtr);
640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641         }
642
643         /// <summary>
644         /// Returns whether backward is possible.
645         /// <returns>True if backward is possible, false otherwise</returns>
646         /// </summary>
647         [EditorBrowsable(EditorBrowsableState.Never)]
648         public bool CanGoBack()
649         {
650             bool ret = Interop.WebView.WebView_CanGoBack(swigCPtr);
651             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652             return ret;
653         }
654
655         /// <summary>
656         /// Returns whether forward is possible.
657         /// <returns>True if forward is possible, false otherwise</returns>
658         /// </summary>
659         [EditorBrowsable(EditorBrowsableState.Never)]
660         public bool CanGoForward()
661         {
662             bool ret = Interop.WebView.WebView_CanGoForward(swigCPtr);
663             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664             return ret;
665         }
666
667         /// <summary>
668         /// The callback function that is invoked when the message is received from the script.
669         /// </summary>
670         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
671         [EditorBrowsable(EditorBrowsableState.Never)]
672         public delegate void JavaScriptMessageHandler(string message);
673
674         /// <summary>
675         /// Evaluates JavaScript code represented as a string.
676         /// <param name="script">The JavaScript code</param>
677         /// </summary>
678         [EditorBrowsable(EditorBrowsableState.Never)]
679         public void EvaluateJavaScript(string script)
680         {
681             Interop.WebView.WebView_EvaluateJavaScript(swigCPtr, script, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
682             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683         }
684
685         // For rooting handlers
686         internal Dictionary<string, JavaScriptMessageHandler> handlerRootMap = new Dictionary<string, JavaScriptMessageHandler>();
687
688         /// <summary>
689         /// Add a message handler into the WebView.
690         /// <param name="objectName">The name of exposed object</param>
691         /// <param name="handler">The callback function</param>
692         /// </summary>
693         [EditorBrowsable(EditorBrowsableState.Never)]
694         public void AddJavaScriptMessageHandler(string objectName, JavaScriptMessageHandler handler)
695         {
696             if (handlerRootMap.ContainsKey(objectName))
697             {
698                 return;
699             }
700
701             handlerRootMap.Add(objectName, handler);
702
703             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(handler);
704             Interop.WebView.WebView_AddJavaScriptMessageHandler(swigCPtr, objectName, new System.Runtime.InteropServices.HandleRef(this, ip));
705
706             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707         }
708
709         /// <summary>
710         /// Clears the history of current WebView.
711         /// </summary>
712         [EditorBrowsable(EditorBrowsableState.Never)]
713         public void ClearHistory()
714         {
715             Interop.WebView.WebView_ClearHistory(swigCPtr);
716             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717         }
718
719         /// <summary>
720         /// Clears the cache of current WebView.
721         /// </summary>
722         [EditorBrowsable(EditorBrowsableState.Never)]
723         public void ClearCache()
724         {
725             Interop.WebView.WebView_ClearCache(swigCPtr);
726             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727         }
728
729         /// <summary>
730         /// Clears all the cookies of current WebView.
731         /// </summary>
732         [EditorBrowsable(EditorBrowsableState.Never)]
733         public void ClearCookies()
734         {
735             Interop.WebView.WebView_ClearCookies(swigCPtr);
736             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737         }
738     }
739 }