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

Unified Diff: android_webview/renderer/aw_content_renderer_client.cc

Issue 1890203002: Implement Web Restrictions in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final nits Created 4 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/aw_content_renderer_client.h ('k') | android_webview/webview_repack_locales.gni » ('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 e486795e92d6f3f49ba521c972d314cc457b6d0b..ed4fddf7d1e2ce92710171450798fc8f5db91b10 100644
--- a/android_webview/renderer/aw_content_renderer_client.cc
+++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -27,7 +27,10 @@
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "components/printing/renderer/print_web_view_helper.h"
+#include "components/supervised_user_error_page/gin_wrapper.h"
+#include "components/supervised_user_error_page/supervised_user_error_page_android.h"
#include "components/visitedlink/renderer/visitedlink_slave.h"
+#include "components/web_restrictions/interfaces/web_restrictions.mojom.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/navigation_state.h"
@@ -36,6 +39,7 @@
#include "content/public/renderer/render_view.h"
#include "net/base/escape.h"
#include "net/base/net_errors.h"
+#include "services/shell/public/cpp/interface_provider.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
@@ -167,14 +171,14 @@ bool AwContentRendererClient::HasErrorPage(int http_status_code,
}
void AwContentRendererClient::GetNavigationErrorStrings(
- content::RenderFrame* /* render_frame */,
+ content::RenderFrame* render_frame,
const blink::WebURLRequest& failed_request,
const blink::WebURLError& error,
std::string* error_html,
base::string16* error_description) {
if (error_html) {
- std::string url =
- net::EscapeForHTML(GURL(failed_request.url()).possibly_invalid_spec());
+ GURL gurl(failed_request.url());
+ std::string url = net::EscapeForHTML(gurl.possibly_invalid_spec());
std::string err =
base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription));
@@ -199,6 +203,22 @@ void AwContentRendererClient::GetNavigationErrorStrings(
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_AW_LOAD_ERROR_HTML),
replacements, nullptr);
+ if (error.reason == net::ERR_BLOCKED_BY_ADMINISTRATOR) {
+ // This needs more information
+ render_frame->GetRemoteInterfaces()->GetInterface(
+ &web_restrictions_service_);
+ web_restrictions::mojom::ClientResultPtr result;
+ if (web_restrictions_service_->GetResult(mojo::String(url), &result)) {
+ std::string detailed_error_html =
+ supervised_user_error_page::BuildHtmlFromWebRestrictionsResult(
+ result, RenderThread::Get()->GetLocale());
+ if (!detailed_error_html.empty()) {
+ *error_html = detailed_error_html;
+ supervised_user_error_page::GinWrapper::InstallWhenFrameReady(
+ render_frame, url, web_restrictions_service_);
+ }
+ }
+ }
}
if (error_description) {
if (error.localizedDescription.isEmpty())
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.h ('k') | android_webview/webview_repack_locales.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698