• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "WebViewClientError.h"
28 
29 #include <cutils/log.h>
30 
31 using namespace net;
32 
33 namespace android {
34 
ToWebViewClientError(net::Error error)35 WebViewClientError ToWebViewClientError(net::Error error) {
36     // Note: many net::Error constants don't have an obvious mapping.
37     // These will be handled by the default case, ERROR_UNKNOWN.
38     switch(error) {
39         case ERR_UNSUPPORTED_AUTH_SCHEME:
40             return ERROR_UNSUPPORTED_AUTH_SCHEME;
41 
42         case ERR_INVALID_AUTH_CREDENTIALS:
43         case ERR_MISSING_AUTH_CREDENTIALS:
44         case ERR_MISCONFIGURED_AUTH_ENVIRONMENT:
45             return ERROR_AUTHENTICATION;
46 
47         case ERR_TOO_MANY_REDIRECTS:
48             return ERROR_REDIRECT_LOOP;
49 
50         case ERR_UPLOAD_FILE_CHANGED:
51             return ERROR_FILE_NOT_FOUND;
52 
53         case ERR_INVALID_URL:
54             return ERROR_BAD_URL;
55 
56         case ERR_DISALLOWED_URL_SCHEME:
57         case ERR_UNKNOWN_URL_SCHEME:
58             return ERROR_UNSUPPORTED_SCHEME;
59 
60         case ERR_IO_PENDING:
61         case ERR_NETWORK_IO_SUSPENDED:
62             return ERROR_IO;
63 
64         case ERR_CONNECTION_TIMED_OUT:
65         case ERR_TIMED_OUT:
66             return ERROR_TIMEOUT;
67 
68         case ERR_FILE_TOO_BIG:
69             return ERROR_FILE;
70 
71         case ERR_HOST_RESOLVER_QUEUE_TOO_LARGE:
72         case ERR_INSUFFICIENT_RESOURCES:
73         case ERR_OUT_OF_MEMORY:
74             return ERROR_TOO_MANY_REQUESTS;
75 
76         case ERR_CONNECTION_CLOSED:
77         case ERR_CONNECTION_RESET:
78         case ERR_CONNECTION_REFUSED:
79         case ERR_CONNECTION_ABORTED:
80         case ERR_CONNECTION_FAILED:
81         case ERR_SOCKET_NOT_CONNECTED:
82         case ERR_CACHE_MISS:
83             return ERROR_CONNECT;
84 
85         case ERR_ADDRESS_INVALID:
86         case ERR_ADDRESS_UNREACHABLE:
87         case ERR_NAME_NOT_RESOLVED:
88         case ERR_NAME_RESOLUTION_FAILED:
89             return ERROR_HOST_LOOKUP;
90 
91         case ERR_SSL_PROTOCOL_ERROR:
92         case ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
93         case ERR_TUNNEL_CONNECTION_FAILED:
94         case ERR_NO_SSL_VERSIONS_ENABLED:
95         case ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
96         case ERR_SSL_RENEGOTIATION_REQUESTED:
97         case ERR_CERT_ERROR_IN_SSL_RENEGOTIATION:
98         case ERR_BAD_SSL_CLIENT_AUTH_CERT:
99         case ERR_SSL_NO_RENEGOTIATION:
100         case ERR_SSL_DECOMPRESSION_FAILURE_ALERT:
101         case ERR_SSL_BAD_RECORD_MAC_ALERT:
102         case ERR_SSL_UNSAFE_NEGOTIATION:
103         case ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
104         case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
105         case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
106             return ERROR_FAILED_SSL_HANDSHAKE;
107 
108         case ERR_PROXY_AUTH_UNSUPPORTED:
109         case ERR_PROXY_AUTH_REQUESTED:
110         case ERR_PROXY_CONNECTION_FAILED:
111         case ERR_UNEXPECTED_PROXY_AUTH:
112             return ERROR_PROXY_AUTHENTICATION;
113 
114         /* The certificate errors are handled by their own dialog
115          * and don't need to be reported to the framework again.
116          */
117         case ERR_CERT_COMMON_NAME_INVALID:
118         case ERR_CERT_DATE_INVALID:
119         case ERR_CERT_AUTHORITY_INVALID:
120         case ERR_CERT_CONTAINS_ERRORS:
121         case ERR_CERT_NO_REVOCATION_MECHANISM:
122         case ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
123         case ERR_CERT_REVOKED:
124         case ERR_CERT_INVALID:
125         case ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
126         case ERR_CERT_NOT_IN_DNS:
127         case ERR_CERT_NON_UNIQUE_NAME:
128             return ERROR_OK;
129 
130         default:
131             android_printLog(ANDROID_LOG_DEBUG, "chromium", "Unknown chromium error: %d", error);
132             return ERROR_UNKNOWN;
133     }
134 }
135 
136 }
137