Commit 24a37c7f authored by Stefan Teodorescu's avatar Stefan Teodorescu Committed by Commit Bot

Create about:management page for management disclosure project

Create basic chrome://management page to contain the template for the
disclosure page, which describes administrator's capabilities in a
managed environment, like policies which report information, local
trust roots or force installed extensions.

Bug: 879146
Change-Id: I621bed79843b2a677ed1df82b90043bc8937e44a
Reviewed-on: https://chromium-review.googlesource.com/1196548
Commit-Queue: Stefan Teodorescu <fane@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588911}
parent d73de1b4
......@@ -399,6 +399,9 @@
<include name="IDR_POLICY_BASE_JS" file="resources\policy_base.js" type="BINDATA" compress="gzip" />
<include name="IDR_POLICY_JS" file="resources\policy.js" type="BINDATA" compress="gzip" />
<include name="IDR_POLICY_COMMON_CSS" file="resources\policy_common.css" type="BINDATA" compress="gzip" />
<include name="IDR_MANAGEMENT_HTML" file="resources\management.html" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_MANAGEMENT_JS" file="resources\management.js" type="BINDATA" compress="gzip" />
<include name="IDR_MANAGEMENT_CSS" file="resources\management.css" type="BINDATA" compress="gzip" />
<if expr="not is_android">
<include name="IDR_POLICY_TOOL_HTML" file="resources\policy_tool.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_POLICY_TOOL_CSS" file="resources\policy_tool.css" type="BINDATA" compress="gzip" />
......
/* Copyright 2018 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. */
body {
margin-inline-start: 23px;
}
body > .page {
margin-inline-end: 0;
padding-inline-end: 24px;
}
body header {
left: 23px;
max-width: none;
}
html[dir='rtl'] body header {
right: 23px;
}
body section {
max-width: none;
}
#main-section {
padding-inline-start: 0;
}
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>$i18n{title}</title>
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="management.css">
<script src="chrome://resources/js/action_link.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/ui.js"></script>
<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="strings.js"></script>
<script src="management.js"></script>
</head>
<body>
<div class="page">
<header>
<h1>$i18n{title}</h1>
</header>
<section id="main-section">
<!-- This is where page content gets dynamically added. -->
</section>
</div>
</body>
</html>
// Copyright 2018 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.
cr.define('management', function() {
/**
* A singleton object that handles communication between browser and WebUI.
* @constructor
*/
function Page() {}
// Make Page a singleton.
cr.addSingletonGetter(Page);
Page.prototype = {
/**
* Main initialization function. Called by the browser on page load.
*/
initialize: function() {
cr.ui.FocusOutlineManager.forDocument(document);
this.mainSection_ = $('main-section');
// Notify the browser that the page has loaded, causing it to send the
// management data.
chrome.send('initialized');
},
};
Page.showDeviceManagedStatus = function(managedString) {
var page = this.getInstance();
var string = document.createElement('p');
string.textContent = managedString;
page.mainSection_.appendChild(string);
};
return {Page: Page};
});
// Have the main initialization function be called when the page finishes
// loading.
document.addEventListener(
'DOMContentLoaded',
management.Page.prototype.initialize.bind(management.Page.getInstance()));
......@@ -721,6 +721,10 @@ jumbo_split_static_library("ui") {
"webui/local_state/local_state_ui.h",
"webui/log_web_ui_url.cc",
"webui/log_web_ui_url.h",
"webui/management_ui.cc",
"webui/management_ui.h",
"webui/management_ui_handler.cc",
"webui/management_ui_handler.h",
"webui/media/media_engagement_ui.cc",
"webui/media/media_engagement_ui.h",
"webui/media/webrtc_logs_ui.cc",
......
......@@ -41,6 +41,7 @@
#include "chrome/browser/ui/webui/invalidations_ui.h"
#include "chrome/browser/ui/webui/local_state/local_state_ui.h"
#include "chrome/browser/ui/webui/log_web_ui_url.h"
#include "chrome/browser/ui/webui/management_ui.h"
#include "chrome/browser/ui/webui/media/media_engagement_ui.h"
#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h"
#include "chrome/browser/ui/webui/memory_internals_ui.h"
......@@ -379,6 +380,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<InvalidationsUI>;
if (url.host_piece() == chrome::kChromeUILocalStateHost)
return &NewWebUI<LocalStateUI>;
if (url.host_piece() == chrome::kChromeUIManagementHost)
return &NewWebUI<ManagementUI>;
if (url.host_piece() == chrome::kChromeUIMemoryInternalsHost)
return &NewWebUI<MemoryInternalsUI>;
if (url.host_piece() == chrome::kChromeUINetExportHost)
......
// Copyright 2018 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/management_ui.h"
#include <memory>
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/management_ui_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
namespace {
content::WebUIDataSource* CreateManagementUIHtmlSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIManagementHost);
source->AddLocalizedString("title", IDS_MANAGEMENT_TITLE);
source->SetJsonPath("strings.js");
// Add required resources.
source->AddResourcePath("management.css", IDR_MANAGEMENT_CSS);
source->AddResourcePath("management.js", IDR_MANAGEMENT_JS);
source->SetDefaultResource(IDR_MANAGEMENT_HTML);
source->UseGzip();
return source;
}
} // namespace
ManagementUI::ManagementUI(content::WebUI* web_ui) : WebUIController(web_ui) {
web_ui->AddMessageHandler(std::make_unique<ManagementUIHandler>());
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
CreateManagementUIHtmlSource());
}
ManagementUI::~ManagementUI() {}
// Copyright 2018 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_MANAGEMENT_UI_H_
#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
namespace content {
class WebUI;
}
// The Web UI controller for the chrome://management page.
class ManagementUI : public content::WebUIController {
public:
explicit ManagementUI(content::WebUI* web_ui);
~ManagementUI() override;
private:
DISALLOW_COPY_AND_ASSIGN(ManagementUI);
};
#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_
// Copyright 2018 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/management_ui_handler.h"
#include <string>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#endif // defined(OS_CHROMEOS)
namespace {
#if defined(OS_CHROMEOS)
base::string16 GetEnterpriseDisplayDomain(
policy::BrowserPolicyConnectorChromeOS* connector) {
if (!connector->IsEnterpriseManaged())
return l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_NOT_MANAGED);
std::string display_domain = connector->GetEnterpriseDisplayDomain();
if (display_domain.empty()) {
if (!connector->IsActiveDirectoryManaged())
return l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED);
display_domain = connector->GetRealm();
}
return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_BY,
base::UTF8ToUTF16(display_domain));
}
#endif // defined(OS_CHROMEOS)
} // namespace
ManagementUIHandler::ManagementUIHandler() {}
ManagementUIHandler::~ManagementUIHandler() {}
void ManagementUIHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"initialized",
base::BindRepeating(&ManagementUIHandler::HandleInitialized,
base::Unretained(this)));
}
void ManagementUIHandler::HandleInitialized(const base::ListValue* /* args */) {
AllowJavascript();
ShowDeviceManagementStatus();
}
void ManagementUIHandler::ShowDeviceManagementStatus() {
#if defined(OS_CHROMEOS)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
CallJavascriptFunction("management.Page.showDeviceManagedStatus",
base::Value(GetEnterpriseDisplayDomain(connector)));
#endif // defined(OS_CHROMEOS)
}
// Copyright 2018 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_MANAGEMENT_UI_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_
#include "base/strings/string16.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace base {
class ListValue;
} // namespace base
// The JavaScript message handler for the chrome://management page.
class ManagementUIHandler : public content::WebUIMessageHandler {
public:
ManagementUIHandler();
~ManagementUIHandler() override;
// content::WebUIMessageHandler implementation.
void RegisterMessages() override;
private:
void HandleInitialized(const base::ListValue* args);
void ShowDeviceManagementStatus();
DISALLOW_COPY_AND_ASSIGN(ManagementUIHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_
......@@ -87,6 +87,8 @@ const char kChromeUIInterventionsInternalsHost[] = "interventions-internals";
const char kChromeUIInvalidationsHost[] = "invalidations";
const char kChromeUIKillHost[] = "kill";
const char kChromeUILocalStateHost[] = "local-state";
const char kChromeUIManagementHost[] = "management";
const char kChromeUIManagementURL[] = "chrome://management";
const char kChromeUIMdUserManagerHost[] = "md-user-manager";
const char kChromeUIMdUserManagerUrl[] = "chrome://md-user-manager/";
const char kChromeUIMediaEngagementHost[] = "media-engagement";
......
......@@ -92,6 +92,8 @@ extern const char kChromeUIInterventionsInternalsHost[];
extern const char kChromeUIInvalidationsHost[];
extern const char kChromeUIKillHost[];
extern const char kChromeUILocalStateHost[];
extern const char kChromeUIManagementHost[];
extern const char kChromeUIManagementURL[];
extern const char kChromeUIMdUserManagerHost[];
extern const char kChromeUIMdUserManagerUrl[];
extern const char kChromeUIMediaEngagementHost[];
......
......@@ -12,6 +12,7 @@ per-file browsing_data_strings.grdp=file://components/browsing_data/OWNERS
per-file crash_strings.grdp=file://components/crash/OWNERS
per-file dom_distiller_strings.grdp=file://components/dom_distiller/OWNERS
per-file error_page_strings.grdp=file://components/error_page/OWNERS
per-file management_strings.grdp=file://components/policy/OWNERS
per-file ntp_snippets_strings.grdp=file://components/ntp_snippets/OWNERS
per-file nux_email_strings.grdp=file://components/nux/OWNERS
per-file nux_google_apps_strings.grdp=file://components/nux/OWNERS
......
......@@ -195,6 +195,7 @@
<part file="find_in_page_strings.grdp" />
<part file="history_strings.grdp" />
<part file="login_dialog_strings.grdp" />
<part file="management_strings.grdp" />
<part file="new_or_sad_tab_strings.grdp" />
<part file="nux_google_apps_strings.grdp" />
<part file="nux_email_strings.grdp" />
......
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<message name="IDS_MANAGEMENT_TITLE" desc="Title of chrome://management page, which shows the administrator's capabilities in a managed environment" translateable="false">
Management
</message>
<message name="IDS_MANAGEMENT_DEVICE_NOT_MANAGED" desc="Message indicating that the device is not managed" translateable="false">
Your device is not managed by an administrator
</message>
<message name="IDS_MANAGEMENT_DEVICE_MANAGED_BY" desc="Message indicating that the device is enterprise enrolled to be managed by an administrator, from a specific domain" translateable="false">
Your device is managed by <ph name="ENROLLMENT_DOMAIN">$1<ex>example.com</ex></ph>
</message>
<message name="IDS_MANAGEMENT_DEVICE_MANAGED" desc="Message indicating that the device is enterprise enrolled to be managed by an administrator" translateable="false">
Your device is managed by an administrator
</message>
</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