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/base64.h" |
7 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/string16.h" | 10 #include "base/string16.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/common/extensions/api/icons/icons_handler.h" | 15 #include "chrome/common/extensions/api/icons/icons_handler.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 16 #include "chrome/common/extensions/extension_constants.h" |
16 #include "chrome/common/extensions/extension_icon_set.h" | 17 #include "chrome/common/extensions/extension_icon_set.h" |
17 #include "chrome/common/extensions/extension_set.h" | 18 #include "chrome/common/extensions/extension_set.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" |
| 22 #include "grit/theme_resources.h" |
21 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
22 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" |
24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/webui/web_ui_util.h" | 28 #include "ui/webui/web_ui_util.h" |
26 #include "webkit/glue/webkit_glue.h" | 29 #include "webkit/glue/webkit_glue.h" |
27 | 30 |
28 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
29 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
30 #endif | 33 #endif |
31 | 34 |
32 using WebKit::WebURLError; | 35 using WebKit::WebURLError; |
33 | 36 |
34 // Some error pages have no details. | 37 // Some error pages have no details. |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 DictionaryValue* suggest_learn_more = new DictionaryValue; | 665 DictionaryValue* suggest_learn_more = new DictionaryValue; |
663 // There's only a body for this suggestion. | 666 // There's only a body for this suggestion. |
664 suggest_learn_more->SetString("body", | 667 suggest_learn_more->SetString("body", |
665 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 668 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
666 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 669 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
667 suggestions->Append(suggest_learn_more); | 670 suggestions->Append(suggest_learn_more); |
668 } | 671 } |
669 } | 672 } |
670 | 673 |
671 error_strings->Set("suggestions", suggestions); | 674 error_strings->Set("suggestions", suggestions); |
| 675 |
| 676 std::string resource_base64; |
| 677 if (base::Base64Encode( |
| 678 ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
| 679 IDR_ERROR_NETWORK_GENERIC, ui::GetMaxScaleFactor()), |
| 680 &resource_base64)) { |
| 681 base::StringValue* data_url = |
| 682 new base::StringValue("data:image/png;base64," + resource_base64); |
| 683 error_strings->Set("image", data_url); |
| 684 } |
672 } | 685 } |
673 | 686 |
674 string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) { | 687 string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) { |
675 const LocalizedErrorMap* error_map = | 688 const LocalizedErrorMap* error_map = |
676 LookupErrorMap(error.domain.utf8(), error.reason); | 689 LookupErrorMap(error.domain.utf8(), error.reason); |
677 if (error_map) | 690 if (error_map) |
678 return l10n_util::GetStringUTF16(error_map->details_resource_id); | 691 return l10n_util::GetStringUTF16(error_map->details_resource_id); |
679 else | 692 else |
680 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); | 693 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); |
681 } | 694 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 #if defined(OS_CHROMEOS) | 751 #if defined(OS_CHROMEOS) |
739 GURL learn_more_url(kAppWarningLearnMoreUrl); | 752 GURL learn_more_url(kAppWarningLearnMoreUrl); |
740 DictionaryValue* suggest_learn_more = new DictionaryValue(); | 753 DictionaryValue* suggest_learn_more = new DictionaryValue(); |
741 suggest_learn_more->SetString("msg", | 754 suggest_learn_more->SetString("msg", |
742 l10n_util::GetStringUTF16( | 755 l10n_util::GetStringUTF16( |
743 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 756 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
744 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 757 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
745 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 758 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
746 #endif // defined(OS_CHROMEOS) | 759 #endif // defined(OS_CHROMEOS) |
747 } | 760 } |
OLD | NEW |