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

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

Issue 23434002: DNS probes: several tweaks to error page updating (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nits, plus indent neterror.html consistently. Created 7 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
« no previous file with comments | « no previous file | chrome/renderer/resources/neterror.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // wrench, and the advanced settings button. 468 // wrench, and the advanced settings button.
469 base::DictionaryValue* GetStandardMenuItemsText() { 469 base::DictionaryValue* GetStandardMenuItemsText() {
470 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); 470 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue();
471 standard_menu_items_text->SetString("settingsTitle", 471 standard_menu_items_text->SetString("settingsTitle",
472 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); 472 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
473 standard_menu_items_text->SetString("advancedTitle", 473 standard_menu_items_text->SetString("advancedTitle",
474 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); 474 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS));
475 return standard_menu_items_text; 475 return standard_menu_items_text;
476 } 476 }
477 477
478 // Gets the icon class for a given |error_domain| and |error_code|.
479 const char* GetIconClassForError(const std::string& error_domain,
480 int error_code) {
481 if ((error_code == net::ERR_INTERNET_DISCONNECTED &&
482 error_domain == net::kErrorDomain) ||
483 (error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET &&
484 error_domain == chrome_common_net::kDnsProbeErrorDomain))
485 return "icon-offline";
486
487 return "icon-generic";
488 }
489
478 } // namespace 490 } // namespace
479 491
480 const char LocalizedError::kHttpErrorDomain[] = "http"; 492 const char LocalizedError::kHttpErrorDomain[] = "http";
481 493
482 void LocalizedError::GetStrings(const WebKit::WebURLError& error, 494 void LocalizedError::GetStrings(const WebKit::WebURLError& error,
483 bool is_post, 495 bool is_post,
484 const std::string& locale, 496 const std::string& locale,
485 base::DictionaryValue* error_strings) { 497 base::DictionaryValue* error_strings) {
486 bool rtl = LocaleIsRTL(); 498 bool rtl = LocaleIsRTL();
487 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 499 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 534
523 string16 failed_url_string(UTF8ToUTF16(failed_url.spec())); 535 string16 failed_url_string(UTF8ToUTF16(failed_url.spec()));
524 // URLs are always LTR. 536 // URLs are always LTR.
525 if (rtl) 537 if (rtl)
526 base::i18n::WrapStringWithLTRFormatting(&failed_url_string); 538 base::i18n::WrapStringWithLTRFormatting(&failed_url_string);
527 error_strings->SetString("title", 539 error_strings->SetString("title",
528 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string)); 540 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string));
529 error_strings->SetString("heading", 541 error_strings->SetString("heading",
530 l10n_util::GetStringUTF16(options.heading_resource_id)); 542 l10n_util::GetStringUTF16(options.heading_resource_id));
531 543
532 std::string icon_class = (error_code == net::ERR_INTERNET_DISCONNECTED && 544 std::string icon_class = GetIconClassForError(error_domain, error_code);
533 error_domain == net::kErrorDomain)
534 ? "icon-offline"
535 : "icon-generic";
536 error_strings->SetString("iconClass", icon_class); 545 error_strings->SetString("iconClass", icon_class);
537 546
538 base::DictionaryValue* summary = new base::DictionaryValue; 547 base::DictionaryValue* summary = new base::DictionaryValue;
539 summary->SetString("msg", 548 summary->SetString("msg",
540 l10n_util::GetStringUTF16(options.summary_resource_id)); 549 l10n_util::GetStringUTF16(options.summary_resource_id));
541 // TODO(tc): We want the unicode url and host here since they're being 550 // TODO(tc): We want the unicode url and host here since they're being
542 // displayed. 551 // displayed.
543 summary->SetString("failedUrl", failed_url_string); 552 summary->SetString("failedUrl", failed_url_string);
544 summary->SetString("hostName", failed_url.host()); 553 summary->SetString("hostName", failed_url.host());
545 summary->SetString("productName", 554 summary->SetString("productName",
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 #if defined(OS_CHROMEOS) 820 #if defined(OS_CHROMEOS)
812 GURL learn_more_url(kAppWarningLearnMoreUrl); 821 GURL learn_more_url(kAppWarningLearnMoreUrl);
813 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 822 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
814 suggest_learn_more->SetString("msg", 823 suggest_learn_more->SetString("msg",
815 l10n_util::GetStringUTF16( 824 l10n_util::GetStringUTF16(
816 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 825 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
817 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 826 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
818 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 827 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
819 #endif // defined(OS_CHROMEOS) 828 #endif // defined(OS_CHROMEOS)
820 } 829 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/resources/neterror.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698