| OLD | NEW |
| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // history to an uncached page created by a POST. | 466 // history to an uncached page created by a POST. |
| 467 if (is_post && error_code == net::ERR_CACHE_MISS) | 467 if (is_post && error_code == net::ERR_CACHE_MISS) |
| 468 return &repost_error; | 468 return &repost_error; |
| 469 return FindErrorMapInArray(net_error_options, | 469 return FindErrorMapInArray(net_error_options, |
| 470 arraysize(net_error_options), | 470 arraysize(net_error_options), |
| 471 error_code); | 471 error_code); |
| 472 } else if (error_domain == LocalizedError::kHttpErrorDomain) { | 472 } else if (error_domain == LocalizedError::kHttpErrorDomain) { |
| 473 return FindErrorMapInArray(http_error_options, | 473 return FindErrorMapInArray(http_error_options, |
| 474 arraysize(http_error_options), | 474 arraysize(http_error_options), |
| 475 error_code); | 475 error_code); |
| 476 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) { | 476 } else if (error_domain == error_page::kDnsProbeErrorDomain) { |
| 477 const LocalizedErrorMap* map = | 477 const LocalizedErrorMap* map = |
| 478 FindErrorMapInArray(dns_probe_error_options, | 478 FindErrorMapInArray(dns_probe_error_options, |
| 479 arraysize(dns_probe_error_options), | 479 arraysize(dns_probe_error_options), |
| 480 error_code); | 480 error_code); |
| 481 DCHECK(map); | 481 DCHECK(map); |
| 482 return map; | 482 return map; |
| 483 } else { | 483 } else { |
| 484 NOTREACHED(); | 484 NOTREACHED(); |
| 485 return NULL; | 485 return NULL; |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| 489 // Returns a dictionary containing the strings for the settings menu under the | 489 // Returns a dictionary containing the strings for the settings menu under the |
| 490 // wrench, and the advanced settings button. | 490 // wrench, and the advanced settings button. |
| 491 base::DictionaryValue* GetStandardMenuItemsText() { | 491 base::DictionaryValue* GetStandardMenuItemsText() { |
| 492 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); | 492 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); |
| 493 standard_menu_items_text->SetString("settingsTitle", | 493 standard_menu_items_text->SetString("settingsTitle", |
| 494 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | 494 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); |
| 495 standard_menu_items_text->SetString("advancedTitle", | 495 standard_menu_items_text->SetString("advancedTitle", |
| 496 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); | 496 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); |
| 497 return standard_menu_items_text; | 497 return standard_menu_items_text; |
| 498 } | 498 } |
| 499 | 499 |
| 500 // Gets the icon class for a given |error_domain| and |error_code|. | 500 // Gets the icon class for a given |error_domain| and |error_code|. |
| 501 const char* GetIconClassForError(const std::string& error_domain, | 501 const char* GetIconClassForError(const std::string& error_domain, |
| 502 int error_code) { | 502 int error_code) { |
| 503 if ((error_code == net::ERR_INTERNET_DISCONNECTED && | 503 if ((error_code == net::ERR_INTERNET_DISCONNECTED && |
| 504 error_domain == net::kErrorDomain) || | 504 error_domain == net::kErrorDomain) || |
| 505 (error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET && | 505 (error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET && |
| 506 error_domain == chrome_common_net::kDnsProbeErrorDomain)) | 506 error_domain == error_page::kDnsProbeErrorDomain)) |
| 507 return "icon-offline"; | 507 return "icon-offline"; |
| 508 | 508 |
| 509 return "icon-generic"; | 509 return "icon-generic"; |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace | 512 } // namespace |
| 513 | 513 |
| 514 const char LocalizedError::kHttpErrorDomain[] = "http"; | 514 const char LocalizedError::kHttpErrorDomain[] = "http"; |
| 515 | 515 |
| 516 void LocalizedError::GetStrings(int error_code, | 516 void LocalizedError::GetStrings(int error_code, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 | 608 |
| 609 if (options.details_resource_id != kErrorPagesNoDetails) { | 609 if (options.details_resource_id != kErrorPagesNoDetails) { |
| 610 error_strings->SetString( | 610 error_strings->SetString( |
| 611 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id)); | 611 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id)); |
| 612 } | 612 } |
| 613 | 613 |
| 614 base::string16 error_string; | 614 base::string16 error_string; |
| 615 if (error_domain == net::kErrorDomain) { | 615 if (error_domain == net::kErrorDomain) { |
| 616 // Non-internationalized error string, for debugging Chrome itself. | 616 // Non-internationalized error string, for debugging Chrome itself. |
| 617 error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code)); | 617 error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code)); |
| 618 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) { | 618 } else if (error_domain == error_page::kDnsProbeErrorDomain) { |
| 619 std::string ascii_error_string = | 619 std::string ascii_error_string = |
| 620 chrome_common_net::DnsProbeStatusToString(error_code); | 620 error_page::DnsProbeStatusToString(error_code); |
| 621 error_string = base::ASCIIToUTF16(ascii_error_string); | 621 error_string = base::ASCIIToUTF16(ascii_error_string); |
| 622 } else { | 622 } else { |
| 623 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); | 623 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); |
| 624 error_string = base::IntToString16(error_code); | 624 error_string = base::IntToString16(error_code); |
| 625 } | 625 } |
| 626 error_strings->SetString("errorCode", | 626 error_strings->SetString("errorCode", |
| 627 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); | 627 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); |
| 628 | 628 |
| 629 // Platform specific information for diagnosing network issues on OSX and | 629 // Platform specific information for diagnosing network issues on OSX and |
| 630 // Windows. | 630 // Windows. |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 cache_button->SetString("cacheUrl", cache_url); | 928 cache_button->SetString("cacheUrl", cache_url); |
| 929 cache_button->SetInteger("trackingId", cache_tracking_id); | 929 cache_button->SetInteger("trackingId", cache_tracking_id); |
| 930 error_strings->Set("cacheButton", cache_button.release()); | 930 error_strings->Set("cacheButton", cache_button.release()); |
| 931 | 931 |
| 932 // Remove the item from suggestions dictionary so that it does not get | 932 // Remove the item from suggestions dictionary so that it does not get |
| 933 // displayed by the template in the details section. | 933 // displayed by the template in the details section. |
| 934 suggestions->Remove(0, nullptr); | 934 suggestions->Remove(0, nullptr); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 } | 937 } |
| OLD | NEW |