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 2ed0a9241ac369cc520f1ed29d7ddbdd773bffb3..19a59018faad02893e1d47c1082e382080e139cb 100644 |
--- a/android_webview/renderer/aw_content_renderer_client.cc |
+++ b/android_webview/renderer/aw_content_renderer_client.cc |
@@ -27,7 +27,11 @@ |
#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/supervised_user_error_page.h" |
+#include "components/supervised_user_error_page/supervised_user_gin_wrapper.h" |
#include "components/visitedlink/renderer/visitedlink_slave.h" |
+#include "components/web_restrictions/interfaces/web_restrictions.mojom.h" |
+#include "content/public/common/service_registry.h" |
#include "content/public/common/url_constants.h" |
#include "content/public/renderer/document_state.h" |
#include "content/public/renderer/navigation_state.h" |
@@ -41,6 +45,7 @@ |
#include "third_party/WebKit/public/platform/WebURLError.h" |
#include "third_party/WebKit/public/platform/WebURLRequest.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
+#include "third_party/WebKit/public/web/WebLocalFrame.h" |
#include "third_party/WebKit/public/web/WebNavigationType.h" |
#include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -54,8 +59,9 @@ namespace android_webview { |
AwContentRendererClient::AwContentRendererClient() |
: disable_page_visibility_( |
- base::CommandLine::ForCurrentProcess() |
- ->HasSwitch(switches::kDisablePageVisibility)) {} |
+ base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kDisablePageVisibility)), |
+ weak_ptr_factory_(this) {} |
AwContentRendererClient::~AwContentRendererClient() { |
} |
@@ -171,14 +177,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)); |
@@ -203,6 +209,15 @@ 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->GetServiceRegistry()->ConnectToRemoteService( |
+ mojo::GetProxy(&web_restrictions_service_)); |
+ web_restrictions_service_->GetResult( |
+ mojo::String(url), |
+ base::Bind(&AwContentRendererClient::OnWebRestrictionsDataReceived, |
+ weak_ptr_factory_.GetWeakPtr(), url, render_frame, error)); |
+ } |
} |
if (error_description) { |
if (error.localizedDescription.isEmpty()) |
@@ -261,4 +276,24 @@ bool AwContentRendererClient::ShouldOverridePageVisibilityState( |
return false; |
} |
+void AwContentRendererClient::OnWebRestrictionsDataReceived( |
+ const std::string& url, |
+ content::RenderFrame* render_frame, |
+ const blink::WebURLError& error, |
+ web_restrictions::mojom::ClientResultPtr result) { |
+ if (!result) |
+ return; |
+ std::string html_error = |
+ supervised_user_error_page::BuildHtmlFromWebRestrictionsResult( |
+ result, RenderThread::Get()->GetLocale()); |
+ if (result->intParams["Allow access requests"]) { |
+ supervised_user_error_page::SupervisedUserGinWrapper::Install( |
+ render_frame, url, web_restrictions_service_); |
+ } |
+ // Replace is always true, since this replaces the original error page |
+ render_frame->GetWebFrame()->loadHTMLString( |
jochen (gone - plz use gerrit)
2016/04/17 17:07:05
why does this not override the previously installe
aberent
2016/05/18 20:06:49
I am not sure that it didn't. I have now created a
|
+ html_error, GURL(content::kUnreachableWebDataURL), error.unreachableURL, |
+ true); |
+} |
+ |
} // namespace android_webview |