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

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

Issue 10830218: Move localized_error from chrome/renderer into chrome/common. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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/renderer/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_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/common/extensions/extension_icon_set.h" 13 #include "chrome/common/extensions/extension_icon_set.h"
14 #include "chrome/common/extensions/extension_set.h" 14 #include "chrome/common/extensions/extension_set.h"
15 #include "content/public/renderer/render_thread.h"
16 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
17 #include "grit/chromium_strings.h" 16 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
19 #include "net/base/escape.h" 18 #include "net/base/escape.h"
20 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
23 #include "webkit/glue/webkit_glue.h" 22 #include "webkit/glue/webkit_glue.h"
24 23
25 #if defined(OS_WIN) 24 #if defined(OS_WIN)
26 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
27 #endif 26 #endif
28 27
29 using WebKit::WebURLError; 28 using WebKit::WebURLError;
30 using content::RenderThread;
31 29
32 namespace { 30 namespace {
33 31
34 static const char kRedirectLoopLearnMoreUrl[] = 32 static const char kRedirectLoopLearnMoreUrl[] =
35 "https://www.google.com/support/chrome/bin/answer.py?answer=95626"; 33 "https://www.google.com/support/chrome/bin/answer.py?answer=95626";
36 static const char kWeakDHKeyLearnMoreUrl[] = 34 static const char kWeakDHKeyLearnMoreUrl[] =
37 "http://sites.google.com/a/chromium.org/dev/" 35 "http://sites.google.com/a/chromium.org/dev/"
38 "err_ssl_weak_server_ephemeral_dh_key"; 36 "err_ssl_weak_server_ephemeral_dh_key";
39 static const char kESETLearnMoreUrl[] = 37 static const char kESETLearnMoreUrl[] =
40 "http://kb.eset.com/esetkb/index?page=content&id=SOLN2588"; 38 "http://kb.eset.com/esetkb/index?page=content&id=SOLN2588";
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 standard_menu_items_text->SetString("advancedTitle", 433 standard_menu_items_text->SetString("advancedTitle",
436 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); 434 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS));
437 return standard_menu_items_text; 435 return standard_menu_items_text;
438 } 436 }
439 437
440 } // namespace 438 } // namespace
441 439
442 const char LocalizedError::kHttpErrorDomain[] = "http"; 440 const char LocalizedError::kHttpErrorDomain[] = "http";
443 441
444 void LocalizedError::GetStrings(const WebKit::WebURLError& error, 442 void LocalizedError::GetStrings(const WebKit::WebURLError& error,
445 DictionaryValue* error_strings) { 443 DictionaryValue* error_strings,
444 const std::string& locale) {
446 bool rtl = LocaleIsRTL(); 445 bool rtl = LocaleIsRTL();
447 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 446 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
448 447
449 // Grab the strings and settings that depend on the error type. Init 448 // Grab the strings and settings that depend on the error type. Init
450 // options with default values. 449 // options with default values.
451 LocalizedErrorMap options = { 450 LocalizedErrorMap options = {
452 0, 451 0,
453 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, 452 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
454 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, 453 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
455 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, 454 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 break; 646 break;
648 case net::ERR_ESET_ANTI_VIRUS_SSL_INTERCEPTION: 647 case net::ERR_ESET_ANTI_VIRUS_SSL_INTERCEPTION:
649 learn_more_url = GURL(kESETLearnMoreUrl); 648 learn_more_url = GURL(kESETLearnMoreUrl);
650 break; 649 break;
651 default: 650 default:
652 break; 651 break;
653 } 652 }
654 653
655 if (learn_more_url.is_valid()) { 654 if (learn_more_url.is_valid()) {
656 // Add the language parameter to the URL. 655 // Add the language parameter to the URL.
657 std::string query = learn_more_url.query() + "&hl=" + 656 std::string query = learn_more_url.query() + "&hl=" + locale;
658 RenderThread::Get()->GetLocale();
659
660 GURL::Replacements repl; 657 GURL::Replacements repl;
661 repl.SetQueryStr(query); 658 repl.SetQueryStr(query);
662 learn_more_url = learn_more_url.ReplaceComponents(repl); 659 learn_more_url = learn_more_url.ReplaceComponents(repl);
663 660
664 DictionaryValue* suggest_learn_more = new DictionaryValue; 661 DictionaryValue* suggest_learn_more = new DictionaryValue;
665 suggest_learn_more->SetString("msg", 662 suggest_learn_more->SetString("msg",
666 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); 663 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
667 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 664 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
668 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 665 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
669 } 666 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 #if defined(OS_CHROMEOS) 730 #if defined(OS_CHROMEOS)
734 GURL learn_more_url(kAppWarningLearnMoreUrl); 731 GURL learn_more_url(kAppWarningLearnMoreUrl);
735 DictionaryValue* suggest_learn_more = new DictionaryValue(); 732 DictionaryValue* suggest_learn_more = new DictionaryValue();
736 suggest_learn_more->SetString("msg", 733 suggest_learn_more->SetString("msg",
737 l10n_util::GetStringUTF16( 734 l10n_util::GetStringUTF16(
738 IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); 735 IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
739 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 736 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
740 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 737 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
741 #endif // defined(OS_CHROMEOS) 738 #endif // defined(OS_CHROMEOS)
742 } 739 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698