summaryrefslogtreecommitdiff
path: root/Tizen.WebView/Tizen.WebView/SmartCallbackLoadErrorArgs.cs
blob: 8ade295f1593cd839e503d9a857bb4643469c7cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Runtime.InteropServices;

namespace Tizen.WebView
{
    /// <summary>
    /// Enumeration that provides an option to error codes.
    /// </summary>
    public enum LoadErrorCode
    {
        /// <summary>
        /// Unknown
        /// </summary>
        Unknown = 0,
        /// <summary>
        /// User canceled
        /// </summary>
        Canceled,
        /// <summary>
        /// Can't show page for this MIME Type
        /// </summary>
        CantSupportMimetype,
        /// <summary>
        /// File IO error
        /// </summary>
        FailedFileIo,
        /// <summary>
        /// Cannot connect to network
        /// </summary>
        CantConnect,
        /// <summary>
        /// Fail to look up host from DNS
        /// </summary>
        CantLookupHost,
        /// <summary>
        /// Fail to SSL/TLS handshake
        /// </summary>
        FailedTlsHandshake,
        /// <summary>
        /// Received certificate is invalid
        /// </summary>
        InvalidCertificate,
        /// <summary>
        /// Connection timeout
        /// </summary>
        RequestTimeout,
        /// <summary>
        /// Too many redirects
        /// </summary>
        TooManyRedirects,
        /// <summary>
        /// Too many requests during this load
        /// </summary>
        TooManyRequests,
        /// <summary>
        /// Malformed url
        /// </summary>
        BadUrl,
        /// <summary>
        /// Unsupported scheme
        /// </summary>
        UnsupportedScheme,
        /// <summary>
        /// User authentication failed on server
        /// </summary>
        Authentication,
        /// <summary>
        /// Web server has internal server error
        /// </summary>
        InternalServer,
    }

    /// <summary>
    /// Argument from the LoadError SmartCallback.
    /// </summary>
    public class SmartCallbackLoadErrorArgs : EventArgs
    {
        IntPtr _handle;

        internal SmartCallbackLoadErrorArgs(IntPtr handle)
        {
            _handle = handle;
        }

        /// <summary>
        /// Failing URL for the error.
        /// </summary>
        public string Url
        {
            get
            {
                return Interop.ChromiumEwk.ewk_error_url_get(_handle);
            }
        }

        /// <summary>
        /// The error code.
        /// </summary>
        public LoadErrorCode Code
        {
            get
            {
                return (LoadErrorCode)Interop.ChromiumEwk.ewk_error_code_get(_handle);
            }
        }

        /// <summary>
        /// The description for the error.
        /// </summary>
        public string Description
        {
            get
            {
                return Interop.ChromiumEwk.ewk_error_description_get(_handle);
            }
        }

        /// <summary>
        /// Whether the error should be treated as a cancellation.
        /// </summary>
        public bool Cancellation
        {
            get
            {
                return Interop.ChromiumEwk.ewk_error_cancellation_get(_handle);
            }
        }

        internal static SmartCallbackLoadErrorArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
        {
            return new SmartCallbackLoadErrorArgs(info);
        }
    }
}