Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.WebView / Tizen.WebView / SmartCallbackLoadErrorArgs.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18 using System.Runtime.InteropServices;
19
20 namespace Tizen.WebView
21 {
22     /// <summary>
23     /// Enumeration that provides an option to error codes.
24     /// </summary>
25     public enum LoadErrorCode
26     {
27         /// <summary>
28         /// Unknown
29         /// </summary>
30         Unknown = 0,
31         /// <summary>
32         /// User canceled
33         /// </summary>
34         Canceled,
35         /// <summary>
36         /// Can't show page for this MIME Type
37         /// </summary>
38         CantSupportMimetype,
39         /// <summary>
40         /// File IO error
41         /// </summary>
42         FailedFileIo,
43         /// <summary>
44         /// Cannot connect to network
45         /// </summary>
46         CantConnect,
47         /// <summary>
48         /// Fail to look up host from DNS
49         /// </summary>
50         CantLookupHost,
51         /// <summary>
52         /// Fail to SSL/TLS handshake
53         /// </summary>
54         FailedTlsHandshake,
55         /// <summary>
56         /// Received certificate is invalid
57         /// </summary>
58         InvalidCertificate,
59         /// <summary>
60         /// Connection timeout
61         /// </summary>
62         RequestTimeout,
63         /// <summary>
64         /// Too many redirects
65         /// </summary>
66         TooManyRedirects,
67         /// <summary>
68         /// Too many requests during this load
69         /// </summary>
70         TooManyRequests,
71         /// <summary>
72         /// Malformed url
73         /// </summary>
74         BadUrl,
75         /// <summary>
76         /// Unsupported scheme
77         /// </summary>
78         UnsupportedScheme,
79         /// <summary>
80         /// User authentication failed on server
81         /// </summary>
82         Authentication,
83         /// <summary>
84         /// Web server has internal server error
85         /// </summary>
86         InternalServer,
87     }
88
89     /// <summary>
90     /// Argument from the LoadError SmartCallback.
91     /// </summary>
92     public class SmartCallbackLoadErrorArgs : EventArgs
93     {
94         IntPtr _handle;
95
96         internal SmartCallbackLoadErrorArgs(IntPtr handle)
97         {
98             _handle = handle;
99         }
100
101         /// <summary>
102         /// Failing URL for the error.
103         /// </summary>
104         public string Url
105         {
106             get
107             {
108                 return Interop.ChromiumEwk.ewk_error_url_get(_handle);
109             }
110         }
111
112         /// <summary>
113         /// The error code.
114         /// </summary>
115         public LoadErrorCode Code
116         {
117             get
118             {
119                 return (LoadErrorCode)Interop.ChromiumEwk.ewk_error_code_get(_handle);
120             }
121         }
122
123         /// <summary>
124         /// The description for the error.
125         /// </summary>
126         public string Description
127         {
128             get
129             {
130                 return Interop.ChromiumEwk.ewk_error_description_get(_handle);
131             }
132         }
133
134         /// <summary>
135         /// Whether the error should be treated as a cancellation.
136         /// </summary>
137         public bool Cancellation
138         {
139             get
140             {
141                 return Interop.ChromiumEwk.ewk_error_cancellation_get(_handle);
142             }
143         }
144
145         internal static SmartCallbackLoadErrorArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
146         {
147             return new SmartCallbackLoadErrorArgs(info);
148         }
149     }
150 }