Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: chrome/common/localized_error.cc

Issue 13270005: Display DNS probe results. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactor a bit again (DnsProbeRunner is now tied to a single DnsClient), other fixes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/localized_error.h" 5 #include "chrome/common/localized_error.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/extensions/extension_constants.h" 14 #include "chrome/common/extensions/extension_constants.h"
15 #include "chrome/common/extensions/extension_icon_set.h" 15 #include "chrome/common/extensions/extension_icon_set.h"
16 #include "chrome/common/extensions/extension_set.h" 16 #include "chrome/common/extensions/extension_set.h"
17 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" 17 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
18 #include "chrome/common/net/net_error_info.h"
18 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
19 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "net/base/escape.h" 22 #include "net/base/escape.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "third_party/WebKit/public/platform/WebURLError.h" 24 #include "third_party/WebKit/public/platform/WebURLError.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/webui/web_ui_util.h" 26 #include "ui/webui/web_ui_util.h"
26 #include "webkit/glue/webkit_glue.h" 27 #include "webkit/glue/webkit_glue.h"
27 28
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 }, 363 },
363 {505, 364 {505,
364 IDS_ERRORPAGES_TITLE_LOAD_FAILED, 365 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
365 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR, 366 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
366 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE, 367 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE,
367 IDS_ERRORPAGES_DETAILS_HTTP_VERSION_NOT_SUPPORTED, 368 IDS_ERRORPAGES_DETAILS_HTTP_VERSION_NOT_SUPPORTED,
368 SUGGEST_NONE, 369 SUGGEST_NONE,
369 }, 370 },
370 }; 371 };
371 372
373 const LocalizedErrorMap dns_probe_error_options[] = {
mmenke 2013/06/12 19:17:12 Hmm...Naming scheme used for these is wrong, for c
Deprecated (see juliatuttle) 2013/06/13 14:37:04 It is, but so is the one used for the other const
mmenke 2013/06/13 15:00:12 Sorry, my comment about fixing that meant fixing i
374 {chrome_common_net::DNS_PROBE_POSSIBLE,
375 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
376 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
377 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING,
378 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING,
379 SUGGEST_RELOAD,
380 },
381
382 // DNS_PROBE_NOT_RUN is not here; NetErrorHelper will restore the original
383 // error, which might be one of several DNS-related errors.
384
385 {chrome_common_net::DNS_PROBE_STARTED,
386 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
387 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
388 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING,
389 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING,
390 // Include SUGGEST_RELOAD so the More button doesn't jump when we update.
391 SUGGEST_RELOAD,
392 },
393
394 // DNS_PROBE_FINISHED_UNKNOWN is not here; NetErrorHelper will restore the
395 // original error, which might be one of several DNS-related errors.
396
397 {chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET,
398 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
399 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
400 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED,
401 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED,
402 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG,
403 },
404 {chrome_common_net::DNS_PROBE_FINISHED_BAD_CONFIG,
405 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
406 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
407 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED,
408 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED,
409 SUGGEST_RELOAD | SUGGEST_DNS_CONFIG | SUGGEST_FIREWALL_CONFIG,
410 },
411 {chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
412 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
413 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
414 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED,
415 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED,
416 SUGGEST_RELOAD,
417 },
418 };
419
372 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, 420 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps,
373 size_t num_maps, 421 size_t num_maps,
374 int error_code) { 422 int error_code) {
375 for (size_t i = 0; i < num_maps; ++i) { 423 for (size_t i = 0; i < num_maps; ++i) {
376 if (maps[i].error_code == error_code) 424 if (maps[i].error_code == error_code)
377 return &maps[i]; 425 return &maps[i];
378 } 426 }
379 return NULL; 427 return NULL;
380 } 428 }
381 429
382 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, 430 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
383 int error_code, bool is_post) { 431 int error_code, bool is_post) {
384 if (error_domain == net::kErrorDomain) { 432 if (error_domain == net::kErrorDomain) {
385 // Display a different page in the special case of navigating through the 433 // Display a different page in the special case of navigating through the
386 // history to an uncached page created by a POST. 434 // history to an uncached page created by a POST.
387 if (is_post && error_code == net::ERR_CACHE_MISS) 435 if (is_post && error_code == net::ERR_CACHE_MISS)
388 return &repost_error; 436 return &repost_error;
389 return FindErrorMapInArray(net_error_options, 437 return FindErrorMapInArray(net_error_options,
390 arraysize(net_error_options), 438 arraysize(net_error_options),
391 error_code); 439 error_code);
392 } else if (error_domain == LocalizedError::kHttpErrorDomain) { 440 } else if (error_domain == LocalizedError::kHttpErrorDomain) {
393 return FindErrorMapInArray(http_error_options, 441 return FindErrorMapInArray(http_error_options,
394 arraysize(http_error_options), 442 arraysize(http_error_options),
395 error_code); 443 error_code);
444 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
445 return FindErrorMapInArray(dns_probe_error_options,
446 arraysize(dns_probe_error_options),
447 error_code);
mmenke 2013/06/12 19:17:12 We should DCHECK that this succeeds.
Deprecated (see juliatuttle) 2013/06/13 14:37:04 Done.
396 } else { 448 } else {
397 NOTREACHED(); 449 NOTREACHED();
398 return NULL; 450 return NULL;
399 } 451 }
400 } 452 }
401 453
402 bool LocaleIsRTL() { 454 bool LocaleIsRTL() {
403 #if defined(TOOLKIT_GTK) 455 #if defined(TOOLKIT_GTK)
404 // base::i18n::IsRTL() uses the GTK text direction, which doesn't work within 456 // base::i18n::IsRTL() uses the GTK text direction, which doesn't work within
405 // the renderer sandbox. 457 // the renderer sandbox.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id)); 547 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id));
496 } 548 }
497 549
498 string16 error_string; 550 string16 error_string;
499 if (error_domain == net::kErrorDomain) { 551 if (error_domain == net::kErrorDomain) {
500 // Non-internationalized error string, for debugging Chrome itself. 552 // Non-internationalized error string, for debugging Chrome itself.
501 std::string ascii_error_string = net::ErrorToString(error_code); 553 std::string ascii_error_string = net::ErrorToString(error_code);
502 // Remove the leading "net::" from the returned string. 554 // Remove the leading "net::" from the returned string.
503 RemoveChars(ascii_error_string, "net:", &ascii_error_string); 555 RemoveChars(ascii_error_string, "net:", &ascii_error_string);
504 error_string = ASCIIToUTF16(ascii_error_string); 556 error_string = ASCIIToUTF16(ascii_error_string);
557 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
558 std::string ascii_error_string =
559 chrome_common_net::DnsProbeStatusToString(error_code);
560 error_string = ASCIIToUTF16(ascii_error_string);
505 } else { 561 } else {
506 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); 562 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain);
507 error_string = base::IntToString16(error_code); 563 error_string = base::IntToString16(error_code);
508 } 564 }
509 error_strings->SetString("errorCode", 565 error_strings->SetString("errorCode",
510 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); 566 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string));
511 567
512 base::ListValue* suggestions = new base::ListValue(); 568 base::ListValue* suggestions = new base::ListValue();
513 569
514 // Platform specific instructions for diagnosing network issues on OSX and 570 // Platform specific instructions for diagnosing network issues on OSX and
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 #if defined(OS_CHROMEOS) 795 #if defined(OS_CHROMEOS)
740 GURL learn_more_url(kAppWarningLearnMoreUrl); 796 GURL learn_more_url(kAppWarningLearnMoreUrl);
741 DictionaryValue* suggest_learn_more = new DictionaryValue(); 797 DictionaryValue* suggest_learn_more = new DictionaryValue();
742 suggest_learn_more->SetString("msg", 798 suggest_learn_more->SetString("msg",
743 l10n_util::GetStringUTF16( 799 l10n_util::GetStringUTF16(
744 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 800 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
745 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 801 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
746 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 802 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
747 #endif // defined(OS_CHROMEOS) 803 #endif // defined(OS_CHROMEOS)
748 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698