OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/renderer/net/net_error_helper.h" | 5 #include "chrome/renderer/net/net_error_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!IsMainFrame(frame)) | 179 if (!IsMainFrame(frame)) |
180 return false; | 180 return false; |
181 | 181 |
182 if (!IsDnsError(error)) | 182 if (!IsDnsError(error)) |
183 return false; | 183 return false; |
184 | 184 |
185 // Get the strings for a fake "DNS probe possible" error. | 185 // Get the strings for a fake "DNS probe possible" error. |
186 LocalizedError::GetStrings( | 186 LocalizedError::GetStrings( |
187 chrome_common_net::DNS_PROBE_POSSIBLE, | 187 chrome_common_net::DNS_PROBE_POSSIBLE, |
188 chrome_common_net::kDnsProbeErrorDomain, | 188 chrome_common_net::kDnsProbeErrorDomain, |
189 error.unreachableURL, | 189 error.unreachableURL, is_failed_post, error.staleCopyInCache, |
190 is_failed_post, locale, accept_languages, error_strings); | 190 locale, accept_languages, error_strings); |
191 return true; | 191 return true; |
192 } | 192 } |
193 | 193 |
194 void NetErrorHelper::OnNetErrorInfo(int status_num) { | 194 void NetErrorHelper::OnNetErrorInfo(int status_num) { |
195 DCHECK(status_num >= 0 && status_num < chrome_common_net::DNS_PROBE_MAX); | 195 DCHECK(status_num >= 0 && status_num < chrome_common_net::DNS_PROBE_MAX); |
196 | 196 |
197 DVLOG(1) << "Received status " << DnsProbeStatusToString(status_num); | 197 DVLOG(1) << "Received status " << DnsProbeStatusToString(status_num); |
198 | 198 |
199 DnsProbeStatus status = static_cast<DnsProbeStatus>(status_num); | 199 DnsProbeStatus status = static_cast<DnsProbeStatus>(status_num); |
200 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, status); | 200 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, status); |
(...skipping 11 matching lines...) Expand all Loading... |
212 | 212 |
213 void NetErrorHelper::UpdateErrorPage() { | 213 void NetErrorHelper::UpdateErrorPage() { |
214 DCHECK(forwarding_probe_results_); | 214 DCHECK(forwarding_probe_results_); |
215 | 215 |
216 blink::WebURLError error = GetUpdatedError(); | 216 blink::WebURLError error = GetUpdatedError(); |
217 base::DictionaryValue error_strings; | 217 base::DictionaryValue error_strings; |
218 LocalizedError::GetStrings(error.reason, | 218 LocalizedError::GetStrings(error.reason, |
219 error.domain.utf8(), | 219 error.domain.utf8(), |
220 error.unreachableURL, | 220 error.unreachableURL, |
221 is_failed_post_, | 221 is_failed_post_, |
| 222 error.staleCopyInCache, |
222 RenderThread::Get()->GetLocale(), | 223 RenderThread::Get()->GetLocale(), |
223 render_view()->GetAcceptLanguages(), | 224 render_view()->GetAcceptLanguages(), |
224 &error_strings); | 225 &error_strings); |
225 | 226 |
226 std::string json; | 227 std::string json; |
227 JSONWriter::Write(&error_strings, &json); | 228 JSONWriter::Write(&error_strings, &json); |
228 | 229 |
229 std::string js = "if (window.updateForDnsProbe) " | 230 std::string js = "if (window.updateForDnsProbe) " |
230 "updateForDnsProbe(" + json + ");"; | 231 "updateForDnsProbe(" + json + ");"; |
231 base::string16 js16; | 232 base::string16 js16; |
(...skipping 23 matching lines...) Expand all Loading... |
255 } | 256 } |
256 | 257 |
257 blink::WebURLError error; | 258 blink::WebURLError error; |
258 error.domain = blink::WebString::fromUTF8( | 259 error.domain = blink::WebString::fromUTF8( |
259 chrome_common_net::kDnsProbeErrorDomain); | 260 chrome_common_net::kDnsProbeErrorDomain); |
260 error.reason = last_probe_status_; | 261 error.reason = last_probe_status_; |
261 error.unreachableURL = last_error_.unreachableURL; | 262 error.unreachableURL = last_error_.unreachableURL; |
262 | 263 |
263 return error; | 264 return error; |
264 } | 265 } |
OLD | NEW |