Commit 85de6d1d authored by Nicolas Ouellet-payeur's avatar Nicolas Ouellet-payeur Committed by Commit Bot

Add 'Managed by' UI on chrome://extensions

Adds a message for managed users at the top of the
chrome://extensions page.

Enterprise users will now see a message that says "Your browser is
managed by your organization", with a link they can click to view a help
center article.

The new UI is hidden behind a flag so that most users don't see this WIP
feature just yet.

Bug: 893628
Change-Id: Ib8aac65759880b3cd3509b2f57990affb3aafc4f
Reviewed-on: https://chromium-review.googlesource.com/c/1352496Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615990}
parent ca2cd262
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_components/managed_footnote/managed_footnote.html">
<link rel="import" href="chrome://resources/cr_elements/cr_container_shadow_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
......@@ -62,8 +63,23 @@
padding-bottom: 4px;
padding-top: 8px;
}
managed-footnote {
border-top: none;
/* #content-wrapper has a 24px margin-top. This overrides that
* margin-top, so the only space left is this element's 12px
* padding-bottom.
*/
margin-bottom: -24px;
padding-bottom: 12px;
padding-top: 12px;
/* The next element spills over this element. This ensures the link
* is clickable. */
z-index: 1;
}
</style>
<div id="container">
<managed-footnote hidden="[[filter]]"></managed-footnote>
<div id="content-wrapper">
<div id="no-items" class="empty-list-message"
hidden$="[[!shouldShowEmptyItemsMessage_(
......
......@@ -16,6 +16,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/chrome_extension_browser_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/managed_ui.h"
#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/common/chrome_switches.h"
......@@ -117,7 +118,8 @@ std::string GetLoadTimeClasses(bool in_dev_mode) {
return in_dev_mode ? "in-dev-mode" : std::string();
}
content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
bool in_dev_mode) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
source->SetJsonPath("strings.js");
......@@ -132,6 +134,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"controlledSettingPolicy", IDS_CONTROLLED_SETTING_POLICY},
{"done", IDS_DONE},
{"learnMore", IDS_LEARN_MORE},
{"managedByOrg", IDS_MANAGED_BY_ORG_WITH_HYPERLINK},
{"noSearchResults", IDS_SEARCH_NO_RESULTS},
{"ok", IDS_OK},
{"save", IDS_SAVE},
......@@ -286,6 +289,8 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
AddLocalizedStringsBulk(source, localized_strings,
base::size(localized_strings));
source->AddBoolean("isManaged", chrome::ShouldDisplayManagedUi(profile));
source->AddString("errorLinesNotShownSingular",
l10n_util::GetPluralStringFUTF16(
IDS_MD_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 1));
......@@ -358,7 +363,7 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
prefs::kExtensionsUIDeveloperMode, profile->GetPrefs(),
base::Bind(&ExtensionsUI::OnDevModeChanged, base::Unretained(this)));
source = CreateMdExtensionsSource(*in_dev_mode_);
source = CreateMdExtensionsSource(profile, *in_dev_mode_);
DarkModeHandler::Initialize(web_ui, source);
#if defined(OS_CHROMEOS)
......
......@@ -324,6 +324,10 @@ TEST_F('CrExtensionsItemListTest', 'NoSearchResults', function() {
this.runMochaTest(extension_item_list_tests.TestNames.NoSearchResultsMsg);
});
TEST_F('CrExtensionsItemListTest', 'LoadTimeData', function() {
this.runMochaTest(extension_item_list_tests.TestNames.LoadTimeData);
});
////////////////////////////////////////////////////////////////////////////////
// Extension Load Error Tests
......
......@@ -9,6 +9,7 @@ cr.define('extension_item_list_tests', function() {
Filtering: 'item list filtering',
NoItemsMsg: 'empty item list',
NoSearchResultsMsg: 'empty item list filtering results',
LoadTimeData: 'loadTimeData contains isManaged and managedByOrg',
};
const suiteName = 'ExtensionItemListTest';
......@@ -101,6 +102,12 @@ cr.define('extension_item_list_tests', function() {
testVisible('#no-items', false);
testVisible('#no-search-results', true);
});
test(assert(TestNames.LoadTimeData), function() {
// Check that loadTimeData contains these values.
loadTimeData.getBoolean('isManaged');
loadTimeData.getString('managedByOrg');
});
});
return {
......
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