Commit 3fbc1b32 authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Added a new WebUI to disable chrome urls

This WebUI should be loaded instead on any chrome://* if it's set to be
disabled by an admin policy.

The html page to be loaded is a basic page, and will be changed upon UI
review.

Bug: 1061859
Change-Id: I50c72c744458b141fb777cf9758ca970c2638a66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098906
Commit-Queue: Aya Elsayed <ayaelattar@google.com>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751378}
parent b1735400
...@@ -136,6 +136,8 @@ ...@@ -136,6 +136,8 @@
<include name="IDR_PAGE_NOT_AVAILABLE_FOR_GUEST_APP_HTML" file="resources\page_not_available_for_guest\app.html" type="BINDATA" /> <include name="IDR_PAGE_NOT_AVAILABLE_FOR_GUEST_APP_HTML" file="resources\page_not_available_for_guest\app.html" type="BINDATA" />
</if> </if>
<include name="IDR_CHROME_URLS_DISABLED_PAGE_HTML" file="resources\chrome_urls_disabled_page\app.html" type="BINDATA" />
<include name="IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST" file="resources\identity_scope_approval_dialog\manifest.json" type="BINDATA" /> <include name="IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST" file="resources\identity_scope_approval_dialog\manifest.json" type="BINDATA" />
<include name="IDR_INLINE_LOGIN_HTML" file="resources\inline_login\inline_login.html" compress="gzip" flattenhtml="true" allowexternalscript="true" type="BINDATA" preprocess="true" /> <include name="IDR_INLINE_LOGIN_HTML" file="resources\inline_login\inline_login.html" compress="gzip" flattenhtml="true" allowexternalscript="true" type="BINDATA" preprocess="true" />
......
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="initial-scale=1, minimum-scale=1,width=device-width">
<title>$i18n{disabledPageTitle}</title>
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
</head>
<body id="chrome-urls-disabled-block">
<div class ="frame-disabled">
<div id="information-container">
<div id="main-message">
<h1 id="disabled-page-header">$i18n{disabledPageHeader}</h1>
<p id="disabled-message"> $i18n{disabledPageMessage}</p>
</div>
</div>
</div>
</body>
</html>
...@@ -209,6 +209,8 @@ jumbo_static_library("ui") { ...@@ -209,6 +209,8 @@ jumbo_static_library("ui") {
"webui/autofill_and_password_manager_internals/internals_ui_handler.h", "webui/autofill_and_password_manager_internals/internals_ui_handler.h",
"webui/autofill_and_password_manager_internals/password_manager_internals_ui.cc", "webui/autofill_and_password_manager_internals/password_manager_internals_ui.cc",
"webui/autofill_and_password_manager_internals/password_manager_internals_ui.h", "webui/autofill_and_password_manager_internals/password_manager_internals_ui.h",
"webui/chrome_url_disabled_ui.cc",
"webui/chrome_url_disabled_ui.h",
"webui/chrome_web_ui_controller_factory.cc", "webui/chrome_web_ui_controller_factory.cc",
"webui/chrome_web_ui_controller_factory.h", "webui/chrome_web_ui_controller_factory.h",
"webui/components/components_handler.cc", "webui/components/components_handler.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chrome_url_disabled_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/browser_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
ChromeURLDisabledUI::ChromeURLDisabledUI(content::WebUI* web_ui,
const std::string& host_name)
: content::WebUIController(web_ui), weak_factory_(this) {
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(host_name);
html_source->UseStringsJs();
html_source->AddLocalizedString("disabledPageHeader",
IDS_CHROME_URLS_DISABLED_PAGE_HEADER);
html_source->AddLocalizedString("disabledPageTitle",
IDS_CHROME_URLS_DISABLED_PAGE_TITLE);
html_source->AddLocalizedString("disabledPageMessage",
IDS_CHROME_URLS_DISABLED_PAGE_MESSAGE);
html_source->SetDefaultResource(IDR_CHROME_URLS_DISABLED_PAGE_HTML);
html_source->SetDefaultResource(IDR_CHROME_URLS_DISABLED_PAGE_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
}
ChromeURLDisabledUI::~ChromeURLDisabledUI() = default;
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROME_URL_DISABLED_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DISABLED_UI_H_
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_ui_controller.h"
// For chrome:://.* error page when disabled by admin policy.
class ChromeURLDisabledUI : public content::WebUIController {
public:
explicit ChromeURLDisabledUI(content::WebUI* web_ui,
const std::string& host_name);
~ChromeURLDisabledUI() override;
private:
base::WeakPtrFactory<ChromeURLDisabledUI> weak_factory_;
};
#endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DISABLED_UI_H_
...@@ -525,4 +525,15 @@ Additional details: ...@@ -525,4 +525,15 @@ Additional details:
<message name="IDS_POLICY_SIGNIN_PROFILE" desc="Label to indicate that the policy is for the sign-in screen profile."> <message name="IDS_POLICY_SIGNIN_PROFILE" desc="Label to indicate that the policy is for the sign-in screen profile.">
sign-in screen profile sign-in screen profile
</message> </message>
<!-- Strings for Disabled chrome://.* screen -->
<message name="IDS_CHROME_URLS_DISABLED_PAGE_HEADER" desc="A heading for the user when the application is blocked.">
Application is blocked
</message>
<message name="IDS_CHROME_URLS_DISABLED_PAGE_TITLE" desc="The title for the blocked chrome URLs page.">
Application blocked by your administrator
</message>
<message name="IDS_CHROME_URLS_DISABLED_PAGE_MESSAGE" desc="A paragraph informing the user that the application is blocked.">
The application has been blocked by your administrator
</message>
</grit-part> </grit-part>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment