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

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

Issue 570253002: Componentize NetErrorHelperCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win64 Created 6 years, 3 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/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.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/net/net_error_info.h"
15 #include "chrome/grit/chromium_strings.h" 14 #include "chrome/grit/chromium_strings.h"
16 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/error_page/common/error_page_params.h"
17 #include "components/error_page/common/net_error_info.h"
17 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
18 #include "extensions/common/extension_icon_set.h" 19 #include "extensions/common/extension_icon_set.h"
19 #include "extensions/common/manifest_handlers/icons_handler.h" 20 #include "extensions/common/manifest_handlers/icons_handler.h"
20 #include "net/base/escape.h" 21 #include "net/base/escape.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/base/net_util.h" 23 #include "net/base/net_util.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/base/webui/web_ui_util.h" 26 #include "ui/base/webui/web_ui_util.h"
26 27
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 error_domain == chrome_common_net::kDnsProbeErrorDomain)) 484 error_domain == chrome_common_net::kDnsProbeErrorDomain))
484 return "icon-offline"; 485 return "icon-offline";
485 486
486 return "icon-generic"; 487 return "icon-generic";
487 } 488 }
488 489
489 } // namespace 490 } // namespace
490 491
491 const char LocalizedError::kHttpErrorDomain[] = "http"; 492 const char LocalizedError::kHttpErrorDomain[] = "http";
492 493
493 LocalizedError::ErrorPageParams::ErrorPageParams()
494 : suggest_reload(false),
495 reload_tracking_id(-1),
496 search_tracking_id(-1) {
497 }
498
499 LocalizedError::ErrorPageParams::~ErrorPageParams() {
500 }
501
502 void LocalizedError::GetStrings(int error_code, 494 void LocalizedError::GetStrings(int error_code,
503 const std::string& error_domain, 495 const std::string& error_domain,
504 const GURL& failed_url, 496 const GURL& failed_url,
505 bool is_post, 497 bool is_post,
506 bool show_stale_load_button, 498 bool show_stale_load_button,
507 const std::string& locale, 499 const std::string& locale,
508 const std::string& accept_languages, 500 const std::string& accept_languages,
509 scoped_ptr<ErrorPageParams> params, 501 scoped_ptr<error_page::ErrorPageParams> params,
510 base::DictionaryValue* error_strings) { 502 base::DictionaryValue* error_strings) {
511 bool rtl = LocaleIsRTL(); 503 bool rtl = LocaleIsRTL();
512 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 504 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
513 505
514 // Grab the strings and settings that depend on the error type. Init 506 // Grab the strings and settings that depend on the error type. Init
515 // options with default values. 507 // options with default values.
516 LocalizedErrorMap options = { 508 LocalizedErrorMap options = {
517 0, 509 0,
518 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, 510 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
519 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, 511 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 summary->SetString("msg", 608 summary->SetString("msg",
617 l10n_util::GetStringFUTF16( 609 l10n_util::GetStringFUTF16(
618 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE, 610 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE,
619 l10n_util::GetStringUTF16(options.summary_resource_id), 611 l10n_util::GetStringUTF16(options.summary_resource_id),
620 l10n_util::GetStringUTF16(platform_string_id))); 612 l10n_util::GetStringUTF16(platform_string_id)));
621 } 613 }
622 #endif // defined(OS_MACOSX) || defined(OS_WIN) 614 #endif // defined(OS_MACOSX) || defined(OS_WIN)
623 615
624 // If no parameters were provided, use the defaults. 616 // If no parameters were provided, use the defaults.
625 if (!params) { 617 if (!params) {
626 params.reset(new ErrorPageParams()); 618 params.reset(new error_page::ErrorPageParams());
627 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); 619 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD);
628 } 620 }
629 621
630 base::ListValue* suggestions = NULL; 622 base::ListValue* suggestions = NULL;
631 bool use_default_suggestions = true; 623 bool use_default_suggestions = true;
632 if (!params->override_suggestions) { 624 if (!params->override_suggestions) {
633 suggestions = new base::ListValue(); 625 suggestions = new base::ListValue();
634 } else { 626 } else {
635 suggestions = params->override_suggestions.release(); 627 suggestions = params->override_suggestions.release();
636 use_default_suggestions = false; 628 use_default_suggestions = false;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 #if defined(OS_CHROMEOS) 859 #if defined(OS_CHROMEOS)
868 GURL learn_more_url(kAppWarningLearnMoreUrl); 860 GURL learn_more_url(kAppWarningLearnMoreUrl);
869 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 861 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
870 suggest_learn_more->SetString("msg", 862 suggest_learn_more->SetString("msg",
871 l10n_util::GetStringUTF16( 863 l10n_util::GetStringUTF16(
872 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 864 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
873 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 865 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
874 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 866 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
875 #endif // defined(OS_CHROMEOS) 867 #endif // defined(OS_CHROMEOS)
876 } 868 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698