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

Unified Diff: android_webview/renderer/aw_content_renderer_client.cc

Issue 1270793002: [Android WebView] Put error page files into WebView resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added RTL direction support Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/renderer/DEPS ('k') | android_webview/renderer/aw_renderer_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/renderer/aw_content_renderer_client.cc
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc
index f1ccc5d9331defe26d68da50811dd0cb2dd8f83e..a925b87db5fb29eef9fdf7bce4134151d21880df 100644
--- a/android_webview/renderer/aw_content_renderer_client.cc
+++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -4,9 +4,12 @@
#include "android_webview/renderer/aw_content_renderer_client.h"
+#include <vector>
+
#include "android_webview/common/aw_resource.h"
#include "android_webview/common/render_view_messages.h"
#include "android_webview/common/url_constants.h"
+#include "android_webview/grit/aw_renderer_resources.h"
#include "android_webview/renderer/aw_content_settings_client.h"
#include "android_webview/renderer/aw_key_systems.h"
#include "android_webview/renderer/aw_message_port_client.h"
@@ -14,7 +17,9 @@
#include "android_webview/renderer/aw_render_frame_ext.h"
#include "android_webview/renderer/aw_render_view_ext.h"
#include "android_webview/renderer/print_render_frame_observer.h"
+#include "base/i18n/rtl.h"
#include "base/message_loop/message_loop.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
@@ -32,6 +37,8 @@
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
using content::RenderThread;
@@ -110,20 +117,32 @@ void AwContentRendererClient::GetNavigationErrorStrings(
std::string* error_html,
base::string16* error_description) {
if (error_html) {
- GURL error_url(failed_request.url());
+ std::string url =
+ net::EscapeForHTML(GURL(failed_request.url()).possibly_invalid_spec());
std::string err =
base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription));
- std::string contents;
+
+ std::vector<std::string> replacements;
+ replacements.push_back(
+ l10n_util::GetStringUTF8(IDS_AW_WEBPAGE_NOT_AVAILABLE));
if (err.empty()) {
- contents = AwResource::GetNoDomainPageContent();
+ replacements.push_back(l10n_util::GetStringFUTF8(
+ IDS_AW_WEBPAGE_TEMPORARILY_DOWN, base::UTF8ToUTF16(url)));
+ replacements.push_back(
+ l10n_util::GetStringUTF8(IDS_AW_WEBPAGE_DOWN_SUGGESTIONS));
} else {
- contents = AwResource::GetLoadErrorPageContent();
- base::ReplaceSubstringsAfterOffset(&contents, 0, "%e", err);
+ replacements.push_back(l10n_util::GetStringFUTF8(
+ IDS_AW_WEBPAGE_CAN_NOT_BE_LOADED, base::UTF8ToUTF16(url)));
+ replacements.push_back(err);
}
-
- base::ReplaceSubstringsAfterOffset(&contents, 0, "%s",
- net::EscapeForHTML(error_url.possibly_invalid_spec()));
- *error_html = contents;
+ if (base::i18n::IsRTL())
+ replacements.push_back("direction: rtl;");
+ else
+ replacements.push_back("");
+ *error_html = base::ReplaceStringPlaceholders(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_AW_LOAD_ERROR_HTML),
+ replacements, nullptr);
}
if (error_description) {
if (error.localizedDescription.isEmpty())
« no previous file with comments | « android_webview/renderer/DEPS ('k') | android_webview/renderer/aw_renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698