| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains the implementation of TestWebViewDelegate, which serves | 5 // This file contains the implementation of TestWebViewDelegate, which serves |
| 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to | 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to |
| 7 // have initialized a MessageLoop before these methods are called. | 7 // have initialized a MessageLoop before these methods are called. |
| 8 | 8 |
| 9 #include "config.h" | 9 #include "config.h" |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 std::string GetResponseDescription(const WebURLResponse& response) { | 131 std::string GetResponseDescription(const WebURLResponse& response) { |
| 132 if (response.isNull()) | 132 if (response.isNull()) |
| 133 return "(null)"; | 133 return "(null)"; |
| 134 | 134 |
| 135 return StringPrintf("<NSURLResponse %s, http status code %d>", | 135 return StringPrintf("<NSURLResponse %s, http status code %d>", |
| 136 GURL(response.url()).possibly_invalid_spec().c_str(), | 136 GURL(response.url()).possibly_invalid_spec().c_str(), |
| 137 response.httpStatusCode()); | 137 response.httpStatusCode()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 std::string GetErrorDescription(const WebURLError& error) { | 140 std::string GetErrorDescription(const WebURLError& error) { |
| 141 std::string domain; | 141 std::string domain = UTF16ToASCII(error.domain); |
| 142 int code; | 142 int code = error.reason; |
| 143 | 143 |
| 144 if (EqualsASCII(error.domain, net::kErrorDomain)) { | 144 if (domain == net::kErrorDomain) { |
| 145 domain = "NSURLErrorDomain"; | 145 domain = "NSURLErrorDomain"; |
| 146 switch (error.reason) { | 146 switch (error.reason) { |
| 147 case net::ERR_ABORTED: | 147 case net::ERR_ABORTED: |
| 148 code = -999; | 148 code = -999; |
| 149 break; | 149 break; |
| 150 case net::ERR_UNSAFE_PORT: | 150 case net::ERR_UNSAFE_PORT: |
| 151 // Our unsafe port checking happens at the network stack level, but we | 151 // Our unsafe port checking happens at the network stack level, but we |
| 152 // make this translation here to match the behavior of stock WebKit. | 152 // make this translation here to match the behavior of stock WebKit. |
| 153 domain = "WebKitErrorDomain"; | 153 domain = "WebKitErrorDomain"; |
| 154 code = 103; | 154 code = 103; |
| 155 break; | 155 break; |
| 156 case net::ERR_ADDRESS_INVALID: | 156 case net::ERR_ADDRESS_INVALID: |
| 157 case net::ERR_ADDRESS_UNREACHABLE: |
| 157 code = -1004; | 158 code = -1004; |
| 158 break; | 159 break; |
| 159 default: | |
| 160 code = -1; | |
| 161 } | 160 } |
| 162 } else { | 161 } else { |
| 163 DLOG(WARNING) << "Unknown error domain"; | 162 DLOG(WARNING) << "Unknown error domain"; |
| 164 domain = UTF16ToASCII(error.domain); | |
| 165 code = error.reason; | |
| 166 } | 163 } |
| 167 | 164 |
| 168 return StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", | 165 return StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", |
| 169 domain.c_str(), code, error.unreachableURL.spec().data()); | 166 domain.c_str(), code, error.unreachableURL.spec().data()); |
| 170 } | 167 } |
| 171 | 168 |
| 172 } // namespace | 169 } // namespace |
| 173 | 170 |
| 174 // WebViewDelegate ----------------------------------------------------------- | 171 // WebViewDelegate ----------------------------------------------------------- |
| 175 | 172 |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 return L"main frame \"" + name + L"\""; | 990 return L"main frame \"" + name + L"\""; |
| 994 else | 991 else |
| 995 return L"main frame"; | 992 return L"main frame"; |
| 996 } else { | 993 } else { |
| 997 if (name.length()) | 994 if (name.length()) |
| 998 return L"frame \"" + name + L"\""; | 995 return L"frame \"" + name + L"\""; |
| 999 else | 996 else |
| 1000 return L"frame (anonymous)"; | 997 return L"frame (anonymous)"; |
| 1001 } | 998 } |
| 1002 } | 999 } |
| OLD | NEW |