[NUI] Change all CallingConvention to `Cdecl`
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebView / WebContext.cs
1 /*
2  * Copyright (c) 2021 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.Collections.Generic;
20 using System.ComponentModel;
21 using System.Runtime.InteropServices;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// WebContext is a class for context of web view.
27     /// </summary>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class WebContext : Disposable
30     {
31         private string appId;
32         private string appVersion;
33         private float timeOffset;
34         private ApplicationType applicationType;
35         private WebSecurityOriginList securityOriginList;
36         private SecurityOriginListAcquiredCallback securityOriginListAcquiredCallback;
37         private readonly WebContextSecurityOriginListAcquiredProxyCallback securityOriginListAcquiredProxyCallback;
38         private WebPasswordDataList passwordDataList;
39         private PasswordDataListAcquiredCallback passwordDataListAcquiredCallback;
40         private readonly WebContextPasswordDataListAcquiredProxyCallback passwordDataListAcquiredProxyCallback;
41         private HttpRequestInterceptedCallback httpRequestInterceptedCallback;
42         private readonly WebContextHttpRequestInterceptedProxyCallback httpRequestInterceptedProxyCallback;
43
44         internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
45         {
46             securityOriginListAcquiredProxyCallback = OnSecurityOriginListAcquired;
47             passwordDataListAcquiredProxyCallback = OnPasswordDataListAcquired;
48             httpRequestInterceptedProxyCallback = OnHttpRequestIntercepted;
49         }
50
51         /// <summary>
52         /// Dispose for IDisposable pattern
53         /// </summary>
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         protected override void Dispose(DisposeTypes type)
56         {
57             if (Disposed)
58             {
59                 return;
60             }
61
62             if (type == DisposeTypes.Explicit)
63             {
64                 //Called by User
65                 //Release your own managed resources here.
66                 //You should release all of your own disposable objects here.
67                 if (passwordDataList != null)
68                 {
69                     passwordDataList.Dispose();
70                 }
71                 if (securityOriginList != null)
72                 {
73                     securityOriginList.Dispose();
74                 }
75             }
76
77             base.Dispose(type);
78         }
79
80         /// <summary>
81         /// The callback function that is invoked when security origin list is acquired.
82         /// </summary>
83         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public delegate void SecurityOriginListAcquiredCallback(IList<WebSecurityOrigin> list);
86
87         /// <summary>
88         /// The callback function that is invoked when storage usage is acquired.
89         /// </summary>
90         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public delegate void StorageUsageAcquiredCallback(ulong usage);
93
94         /// <summary>
95         /// The callback function that is invoked when password data list is acquired.
96         /// </summary>
97         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public delegate void PasswordDataListAcquiredCallback(IList<WebPasswordData> list);
100
101         /// <summary>
102         /// The callback function that is invoked when download is started.
103         /// </summary>
104         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public delegate void DownloadStartedCallback(string url);
107
108         /// <summary>
109         /// The callback function that is invoked when current mime type need be overridden.
110         /// </summary>
111         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
112         [EditorBrowsable(EditorBrowsableState.Never)]
113         public delegate bool MimeOverriddenCallback(string url, string currentMime, out string newMime);
114
115         /// <summary>
116         /// The callback function that is invoked when http request need be intercepted.
117         /// </summary>
118         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
119         [EditorBrowsable(EditorBrowsableState.Never)]
120         public delegate void HttpRequestInterceptedCallback(WebHttpRequestInterceptor interceptor);
121
122         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
123         private delegate void WebContextSecurityOriginListAcquiredProxyCallback(IntPtr list);
124
125         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
126         private delegate void WebContextPasswordDataListAcquiredProxyCallback(IntPtr list);
127
128         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
129         private delegate void WebContextHttpRequestInterceptedProxyCallback(IntPtr interceptor);
130
131         /// <summary>
132         /// Cache model
133         /// </summary>
134         [EditorBrowsable(EditorBrowsableState.Never)]
135         public enum CacheModelType
136         {
137             /// <summary>
138             /// The smallest cache capacity
139             /// </summary>
140             [EditorBrowsable(EditorBrowsableState.Never)]
141             DocumentViewer,
142
143             /// <summary>
144             /// The bigger cache capacity than DocumentBrowser
145             /// </summary>
146             [EditorBrowsable(EditorBrowsableState.Never)]
147             DocumentBrowser,
148
149             /// <summary>
150             /// The biggest cache capacity.
151             /// </summary>
152             [EditorBrowsable(EditorBrowsableState.Never)]
153             PrimaryWebBrowser,
154         }
155
156         /// <summary>
157         /// Application type
158         /// </summary>
159         [EditorBrowsable(EditorBrowsableState.Never)]
160         public enum ApplicationType
161         {
162             /// <summary>
163             /// Web browser.
164             /// </summary>
165             [EditorBrowsable(EditorBrowsableState.Never)]
166             WebBrowser,
167
168             /// <summary>
169             /// Hbb tv.
170             /// </summary>
171             [EditorBrowsable(EditorBrowsableState.Never)]
172             HbbTv,
173
174             /// <summary>
175             /// Web runtime.
176             /// </summary>
177             [EditorBrowsable(EditorBrowsableState.Never)]
178             WebRuntime,
179
180             /// <summary>
181             /// Other.
182             /// </summary>
183             [EditorBrowsable(EditorBrowsableState.Never)]
184             Other,
185         }
186
187         /// <summary>
188         /// Cache model
189         /// </summary>
190         [EditorBrowsable(EditorBrowsableState.Never)]
191         public CacheModelType CacheModel
192         {
193             get
194             {
195                 return (CacheModelType)Interop.WebContext.GetCacheModel(SwigCPtr);
196             }
197             set
198             {
199                 Interop.WebContext.SetCacheModel(SwigCPtr, (int)value);
200                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             }
202         }
203
204         /// <summary>
205         /// Proxy URL.
206         /// </summary>
207         [EditorBrowsable(EditorBrowsableState.Never)]
208         public string ProxyUrl
209         {
210             get
211             {
212                 return Interop.WebContext.GetProxyUri(SwigCPtr);
213             }
214             set
215             {
216                 if (value != null)
217                 {
218                     Interop.WebContext.SetProxyUri(SwigCPtr, value);
219                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220                 }
221             }
222         }
223
224         /// <summary>
225         /// Certificate file path.
226         /// </summary>
227         [EditorBrowsable(EditorBrowsableState.Never)]
228         public string CertificateFilePath
229         {
230             get
231             {
232                 return Interop.WebContext.GetCertificateFilePath(SwigCPtr);
233             }
234             set
235             {
236                 Interop.WebContext.SetCertificateFilePath(SwigCPtr, value);
237                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238             }
239         }
240
241         /// <summary>
242         /// Enables cache or not.
243         /// </summary>
244         [EditorBrowsable(EditorBrowsableState.Never)]
245         public bool CacheEnabled
246         {
247             get
248             {
249                 return Interop.WebContext.IsCacheEnabled(SwigCPtr);
250             }
251             set
252             {
253                 Interop.WebContext.EnableCache(SwigCPtr, value);
254                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255             }
256         }
257
258         /// <summary>
259         /// App ID.
260         /// </summary>
261         [EditorBrowsable(EditorBrowsableState.Never)]
262         public string AppId
263         {
264             get
265             {
266                 return appId;
267             }
268             set
269             {
270                 Interop.WebContext.SetAppId(SwigCPtr, value);
271                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272                 appId = value;
273             }
274         }
275
276         /// <summary>
277         /// App version.
278         /// </summary>
279         [EditorBrowsable(EditorBrowsableState.Never)]
280         public string AppVersion
281         {
282             get
283             {
284                 return appVersion;
285             }
286             set
287             {
288                 Interop.WebContext.SetAppVersion(SwigCPtr, value);
289                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290                 appVersion = value;
291             }
292         }
293
294         /// <summary>
295         /// App type.
296         /// </summary>
297         [EditorBrowsable(EditorBrowsableState.Never)]
298         public ApplicationType AppType
299         {
300             get
301             {
302                 return applicationType;
303             }
304             set
305             {
306                 Interop.WebContext.SetApplicationType(SwigCPtr, (int)value);
307                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308                 applicationType = value;
309             }
310         }
311
312         /// <summary>
313         /// Time offset.
314         /// </summary>
315         [EditorBrowsable(EditorBrowsableState.Never)]
316         public float TimeOffset
317         {
318             get
319             {
320                 return timeOffset;
321             }
322             set
323             {
324                 Interop.WebContext.SetTimeOffset(SwigCPtr, value);
325                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326                 timeOffset = value;
327             }
328         }
329
330         /// <summary>
331         /// Default zoom factor.
332         /// </summary>
333         [EditorBrowsable(EditorBrowsableState.Never)]
334         public float DefaultZoomFactor
335         {
336             get
337             {
338                 return Interop.WebContext.GetDefaultZoomFactor(SwigCPtr);
339             }
340             set
341             {
342                 Interop.WebContext.SetDefaultZoomFactor(SwigCPtr, value);
343                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344             }
345         }
346
347         /// <summary>
348         /// Deprecated. Gets context proxy.
349         /// </summary>
350         [EditorBrowsable(EditorBrowsableState.Never)]
351         public string ContextProxy
352         {
353             get
354             {
355                 return Interop.WebContext.GetProxyUri(SwigCPtr);
356             }
357         }
358
359         /// <summary>
360         /// Gets proxy bypass rule.
361         /// </summary>
362         [EditorBrowsable(EditorBrowsableState.Never)]
363         public string ProxyBypassRule
364         {
365             get
366             {
367                 return Interop.WebContext.GetProxyBypassRule(SwigCPtr);
368             }
369         }
370
371         /// <summary>
372         /// Sets default proxy auth.
373         /// </summary>
374         /// <param name="username">Default username for proxy</param>
375         /// <param name="password">Default password for proxy</param>
376         [EditorBrowsable(EditorBrowsableState.Never)]
377         public void SetDefaultProxyAuth(string username, string password)
378         {
379             Interop.WebContext.SetDefaultProxyAuth(SwigCPtr, username, password);
380             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381         }
382
383         /// <summary>
384         /// Deletes all web database.
385         /// </summary>
386         [EditorBrowsable(EditorBrowsableState.Never)]
387         public void DeleteAllWebDatabase()
388         {
389             Interop.WebContext.DeleteAllWebDatabase(SwigCPtr);
390             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391         }
392
393         /// <summary>
394         /// Gets security origins of web database asynchronously.
395         /// </summary>
396         /// <param name="callback">callback for acquiring security origins</param>
397         [EditorBrowsable(EditorBrowsableState.Never)]
398         public bool GetWebDatabaseOrigins(SecurityOriginListAcquiredCallback callback)
399         {
400             securityOriginListAcquiredCallback = callback;
401             IntPtr ip = Marshal.GetFunctionPointerForDelegate(securityOriginListAcquiredProxyCallback);
402             bool result = Interop.WebContext.GetWebDatabaseOrigins(SwigCPtr, new HandleRef(this, ip));
403             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404             return result;
405         }
406
407         /// <summary>
408         /// Deletes web databases by origin.
409         /// </summary>
410         /// <param name="origin">security origin of web database</param>
411         [EditorBrowsable(EditorBrowsableState.Never)]
412         public bool DeleteWebDatabase(WebSecurityOrigin origin)
413         {
414             bool result = Interop.WebContext.DeleteWebDatabase(SwigCPtr, WebSecurityOrigin.getCPtr(origin));
415             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416             return result;
417         }
418
419         /// <summary>
420         /// Gets a list of security origins of web storage asynchronously.
421         /// </summary>
422         /// <param name="callback">callback for acquiring security origins</param>
423         [EditorBrowsable(EditorBrowsableState.Never)]
424         public bool GetWebStorageOrigins(SecurityOriginListAcquiredCallback callback)
425         {
426             securityOriginListAcquiredCallback = callback;
427             IntPtr ip = Marshal.GetFunctionPointerForDelegate(securityOriginListAcquiredProxyCallback);
428             bool result = Interop.WebContext.GetWebStorageOrigins(SwigCPtr, new HandleRef(this, ip));
429             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430             return result;
431         }
432
433         /// <summary>
434         /// Gets a list of security origins of web storage asynchronously.
435         /// </summary>
436         /// <param name="origin">security origin of web storage</param>
437         /// <param name="callback">callback for acquiring storage usage</param>
438         [EditorBrowsable(EditorBrowsableState.Never)]
439         public bool GetWebStorageUsageForOrigin(WebSecurityOrigin origin, StorageUsageAcquiredCallback callback)
440         {
441             IntPtr ip = Marshal.GetFunctionPointerForDelegate(callback);
442             bool result = Interop.WebContext.GetWebStorageUsageForOrigin(SwigCPtr, WebSecurityOrigin.getCPtr(origin), new HandleRef(this, ip));
443             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444             return result;
445         }
446
447         /// <summary>
448         /// Deletes all web storage.
449         /// </summary>
450         [EditorBrowsable(EditorBrowsableState.Never)]
451         public void DeleteAllWebStorage()
452         {
453             Interop.WebContext.DeleteAllWebStorage(SwigCPtr);
454             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455         }
456
457         /// <summary>
458         /// Deletes web storage by origin.
459         /// </summary>
460         /// <param name="origin">security origin of web storage</param>
461         [EditorBrowsable(EditorBrowsableState.Never)]
462         public bool DeleteWebStorage(WebSecurityOrigin origin)
463         {
464             bool result = Interop.WebContext.DeleteWebStorage(SwigCPtr, WebSecurityOrigin.getCPtr(origin));
465             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466             return result;
467         }
468
469         /// <summary>
470         /// Deletes directories and files in local file system.
471         /// </summary>
472         [EditorBrowsable(EditorBrowsableState.Never)]
473         public void DeleteLocalFileSystem()
474         {
475             Interop.WebContext.DeleteLocalFileSystem(SwigCPtr);
476             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
477         }
478
479         /// <summary>
480         /// Clears cache.
481         /// </summary>
482         [EditorBrowsable(EditorBrowsableState.Never)]
483         public void ClearCache()
484         {
485             Interop.WebContext.ClearCache(SwigCPtr);
486             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487         }
488
489         /// <summary>
490         /// Deletes web application cache by origin.
491         /// </summary>
492         /// <param name="origin">security origin of web application</param>
493         [EditorBrowsable(EditorBrowsableState.Never)]
494         public bool DeleteApplicationCache(WebSecurityOrigin origin)
495         {
496             bool result = Interop.WebContext.DeleteApplicationCache(SwigCPtr, WebSecurityOrigin.getCPtr(origin));
497             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498             return result;
499         }
500
501         /// <summary>
502         /// Gets a list of all password data asynchronously.
503         /// </summary>
504         /// <param name="callback">callback for acquiring password data list</param>
505         [EditorBrowsable(EditorBrowsableState.Never)]
506         public void GetFormPasswordList(PasswordDataListAcquiredCallback callback)
507         {
508             passwordDataListAcquiredCallback = callback;
509             IntPtr ip = Marshal.GetFunctionPointerForDelegate(passwordDataListAcquiredProxyCallback);
510             Interop.WebContext.GetFormPasswordList(SwigCPtr, new HandleRef(this, ip));
511             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
512         }
513
514         /// <summary>
515         /// Registers callback for download started.
516         /// </summary>
517         /// <param name="callback">callback for download started</param>
518         [EditorBrowsable(EditorBrowsableState.Never)]
519         public void RegisterDownloadStartedCallback(DownloadStartedCallback callback)
520         {
521             IntPtr ip = IntPtr.Zero;
522             if (callback != null)
523             {
524                 ip = Marshal.GetFunctionPointerForDelegate(callback);
525             }
526             Interop.WebContext.RegisterDownloadStartedCallback(SwigCPtr, new HandleRef(this, ip));
527             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528         }
529
530         /// <summary>
531         /// Registers callback for overriding MIME type.
532         /// </summary>
533         /// <param name="callback">callback for overriding MIME type</param>
534         [EditorBrowsable(EditorBrowsableState.Never)]
535         public void RegisterMimeOverriddenCallback(MimeOverriddenCallback callback)
536         {
537             IntPtr ip = IntPtr.Zero;
538             if (callback != null)
539             {
540                 ip = Marshal.GetFunctionPointerForDelegate(callback);
541             }
542             Interop.WebContext.RegisterMimeOverriddenCallback(SwigCPtr, new HandleRef(this, ip));
543             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544         }
545
546         /// <summary>
547         /// Registers callback for http request interceptor.
548         /// This callback is not called on UI(Main) thread, so users should be cautious
549         /// when accessing their data also used on UI thread.
550         /// No other than WebEngineRequestInterceptor API should be used in the callback.
551         /// </summary>
552         /// <param name="callback">callback for intercepting http request</param>
553         [EditorBrowsable(EditorBrowsableState.Never)]
554         public void RegisterHttpRequestInterceptedCallback(HttpRequestInterceptedCallback callback)
555         {
556             httpRequestInterceptedCallback = callback;
557             IntPtr ip = IntPtr.Zero;
558             if (httpRequestInterceptedCallback != null)
559             {
560                 ip = Marshal.GetFunctionPointerForDelegate(httpRequestInterceptedProxyCallback);
561             }
562             Interop.WebContext.RegisterRequestInterceptedCallback(SwigCPtr, new HandleRef(this, ip));
563             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564         }
565
566         /// <summary>
567         /// Sets context time zone offset.
568         /// </summary>
569         /// <param name="offset">Time offset</param>
570         /// <param name="time">Daylight saving time</param>
571         [EditorBrowsable(EditorBrowsableState.Never)]
572         public void SetTimeZoneOffset(float offset, float time)
573         {
574             Interop.WebContext.SetTimeZoneOffset(SwigCPtr, offset, time);
575             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576         }
577
578         /// <summary>
579         /// Deprecated. Sets context time zone offset.
580         /// </summary>
581         /// <param name="offset">Time offset</param>
582         /// <param name="time">Daylight saving time</param>
583         [EditorBrowsable(EditorBrowsableState.Never)]
584         public void SetContextTimeZoneOffset(float offset, float time)
585         {
586             SetTimeZoneOffset(offset, time);
587         }
588
589         /// <summary>
590         /// Registers URL schemes enabled.
591         /// </summary>
592         /// <param name="schemes">The string array of schemes</param>
593         [EditorBrowsable(EditorBrowsableState.Never)]
594         public void RegisterUrlSchemesAsCorsEnabled(string[] schemes)
595         {
596             if (schemes != null)
597             {
598                 Interop.WebContext.RegisterUrlSchemesAsCorsEnabled(SwigCPtr, schemes, (uint)schemes.Length);
599                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600             }
601         }
602
603         /// <summary>
604         /// Registers JS plugin mime types.
605         /// </summary>
606         /// <param name="mimes">The string array of types</param>
607         [EditorBrowsable(EditorBrowsableState.Never)]
608         public void RegisterJsPluginMimeTypes(string[] mimes)
609         {
610             if (mimes != null)
611             {
612                 Interop.WebContext.RegisterJsPluginMimeTypes(SwigCPtr, mimes, (uint)mimes.Length);
613                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614             }
615         }
616
617         /// <summary>
618         /// Deletes all application cache.
619         /// </summary>
620         [EditorBrowsable(EditorBrowsableState.Never)]
621         public bool DeleteAllApplicationCache()
622         {
623             bool ret = Interop.WebContext.DeleteAllApplicationCache(SwigCPtr);
624             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625             return ret;
626         }
627
628         /// <summary>
629         /// Deletes all web indexed database.
630         /// </summary>
631         [EditorBrowsable(EditorBrowsableState.Never)]
632         public bool DeleteAllWebIndexedDatabase()
633         {
634             bool ret = Interop.WebContext.DeleteAllWebIndexedDatabase(SwigCPtr);
635             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636             return ret;
637         }
638
639         /// <summary>
640         /// Deletes password dataList.
641         /// </summary>
642         /// <param name="passwords">The string array of data list</param>
643         [EditorBrowsable(EditorBrowsableState.Never)]
644         public void DeleteFormPasswordDataList(string[] passwords)
645         {
646             if (passwords != null)
647             {
648                 Interop.WebContext.DeleteFormPasswordDataList(SwigCPtr, passwords, (uint)passwords.Length);
649                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650             }
651         }
652
653         /// <summary>
654         /// Deletes all password data.
655         /// </summary>
656         [EditorBrowsable(EditorBrowsableState.Never)]
657         public void DeleteAllFormPasswordData()
658         {
659             Interop.WebContext.DeleteAllFormPasswordData(SwigCPtr);
660             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661         }
662
663         /// <summary>
664         /// Deletes all candidate data.
665         /// </summary>
666         [EditorBrowsable(EditorBrowsableState.Never)]
667         public void DeleteAllFormCandidateData()
668         {
669             Interop.WebContext.DeleteAllFormCandidateData(SwigCPtr);
670             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671         }
672
673         /// <summary>
674         /// Sets proxy bypass rule.
675         /// </summary>
676         /// <param name="proxy">The proxy string</param>
677         /// <param name="rule">Bypass rule</param>
678         [EditorBrowsable(EditorBrowsableState.Never)]
679         public void SetProxyBypassRule(string proxy, string rule)
680         {
681             Interop.WebContext.SetProxyBypassRule(SwigCPtr, proxy, rule);
682             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683         }
684
685         /// <summary>
686         /// Deprecated. Sets proxy bypass rule.
687         /// </summary>
688         /// <param name="proxy">The proxy string</param>
689         /// <param name="rule">Bypass rule</param>
690         [EditorBrowsable(EditorBrowsableState.Never)]
691         public void SetContextProxy(string proxy, string rule)
692         {
693             SetProxyBypassRule(proxy, rule);
694         }
695
696         /// <summary>
697         /// Frees unused memory.
698         /// </summary>
699         [EditorBrowsable(EditorBrowsableState.Never)]
700         public bool FreeUnusedMemory()
701         {
702             bool ret = Interop.WebContext.FreeUnusedMemory(SwigCPtr);
703             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704             return ret;
705         }
706
707         private void OnSecurityOriginListAcquired(IntPtr alist)
708         {
709             if (securityOriginList != null)
710             {
711                 securityOriginList.Dispose();
712             }
713             securityOriginList = new WebSecurityOriginList(alist, true);
714             List<WebSecurityOrigin> originList = new List<WebSecurityOrigin>();
715             for (uint i = 0; i < securityOriginList.ItemCount; i++)
716             {
717                 originList.Add(securityOriginList.GetItemAtIndex(i));
718             }
719             securityOriginListAcquiredCallback?.Invoke(originList);
720         }
721
722         private void OnPasswordDataListAcquired(IntPtr alist)
723         {
724             if (passwordDataList != null)
725             {
726                 passwordDataList.Dispose();
727             }
728             passwordDataList = new WebPasswordDataList(alist, true);
729             List<WebPasswordData> pList = new List<WebPasswordData>();
730             for(uint i = 0; i < passwordDataList.ItemCount; i++)
731             {
732                 pList.Add(passwordDataList.GetItemAtIndex(i));
733             }
734             passwordDataListAcquiredCallback?.Invoke(pList);
735         }
736
737         private void OnHttpRequestIntercepted(IntPtr interceptor)
738         {
739 #pragma warning disable CA2000 // Dispose objects before losing scope
740             httpRequestInterceptedCallback?.Invoke(new WebHttpRequestInterceptor(interceptor, true));
741 #pragma warning restore CA2000 // Dispose objects before losing scope
742         }
743     }
744 }