Commit ebd8d803 authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Commit Bot

FontAccess: Site settings and entries for Font Access

Tested at
https://oyiptong.github.io/opentype.js/font-inspector-bytes.html

With chrome://flags/#font-access enabled.

Fixed: 1112552
Change-Id: If7bba29a96fa305d78cc55879b8dee6e88bae4f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340073
Commit-Queue: Olivier Yiptong <oyiptong@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Reviewed-by: default avatarTheodore Olsauskas-Warren <sauski@google.com>
Cr-Commit-Position: refs/heads/master@{#796116}
parent 054f6ac2
......@@ -2033,6 +2033,12 @@
<message name="IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_BLOCK" desc="The block label for the window placement site settings.">
Block sites from opening and placing windows on your screens
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_ASK" desc="The ask label for the local font access site settings.">
Ask when a site wants to use fonts installed on your device
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_BLOCK" desc="The block label for the local font access site settings.">
Block sites from using fonts installed on your device
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_ALLOWED" desc="A generic Allowed label to show in Site Settings when Allow is NOT the recommended option.">
Allowed
</message>
......
1966ceace30413c1103cc7b4ea1358788b697734
\ No newline at end of file
a6d618be4fd9bd00e1027d9b4148f6d8525bedce
\ No newline at end of file
......@@ -126,6 +126,7 @@ NOTE: Chrome OS icons go in ./chromeos/os_icons.html.
</if>
<g id="window-placement"><path d="M21 1H8c-1.1 0-2 .9-2 2v6H3c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2v-6h3c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm-5 20H3v-8h13v8zm5-8h-3v-2c0-1.1-.9-2-2-2H8V5h13v8z"></path></g>
<g id="zoom-in"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></g>
<g id="font-access"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 18H4V4h16v16zM10.69 6h2.6l4.51 12h-2.5l-1.01-2.87H9.7L8.7 18H6.2l4.49-12zm2.87 7.06l-1.06-3.02-.43-1.44h-.13l-.44 1.44-1.07 3.02h3.13z"></path></g>
</defs>
</svg>
</iron-iconset-svg>
......@@ -666,4 +666,22 @@
</settings-subpage>
</template>
</template>
<template is="dom-if" if="[[enableFontAccessContentSetting_]]">
<template is="dom-if" route-path="/content/fontAccess" no-search>
<settings-subpage page-title="$i18n{fonts}"
search-label="$i18n{siteSettingsAllSitesSearch}"
search-term="{{searchFilter_}}">
<category-default-setting
toggle-off-label="$i18n{siteSettingsFontAccessBlock}"
toggle-on-label="$i18n{siteSettingsFontAccessAsk}"
category="[[ContentSettingsTypes.FONT_ACCESS]]">
</category-default-setting>
<category-setting-exceptions
category="[[ContentSettingsTypes.FONT_ACCESS]]"
block-header="$i18n{siteSettingsBlock}"
search-filter="[[searchFilter_]]">
</category-setting-exceptions>
</settings-subpage>
</template>
</template>
</settings-animated-pages>
......@@ -150,6 +150,14 @@ Polymer({
}
},
/** @private */
enableFontAccessContentSetting_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('enableFontAccessContentSetting');
}
},
/** @private */
enableQuietNotificationPromptsSetting_: {
type: Boolean,
......
......@@ -87,6 +87,9 @@ function addPrivacyChildRoutes(r) {
r.SITE_SETTINGS_FILE_SYSTEM_WRITE =
r.SITE_SETTINGS.createChild('filesystem');
}
if (loadTimeData.getBoolean('enableFontAccessContentSetting')) {
r.SITE_SETTINGS_FONT_ACCESS = r.SITE_SETTINGS.createChild('fontAccess');
}
}
/**
......
......@@ -57,6 +57,7 @@ import {Route} from './router.m.js';
* SITE_SETTINGS_COOKIES: !Route,
* SITE_SETTINGS_DATA_DETAILS: !Route,
* SITE_SETTINGS_FLASH: !Route,
* SITE_SETTINGS_FONT_ACCESS: !Route,
* SITE_SETTINGS_HANDLERS: !Route,
* SITE_SETTINGS_HID_DEVICES: !Route,
* SITE_SETTINGS_IMAGES: !Route,
......
......@@ -163,7 +163,6 @@ Polymer({
case ContentSettingsTypes.PAYMENT_HANDLER:
case ContentSettingsTypes.POPUPS:
case ContentSettingsTypes.PROTOCOL_HANDLERS:
// "Allowed" vs "Blocked".
this.browserProxy.setDefaultValueForContentType(
this.category,
......@@ -172,6 +171,7 @@ Polymer({
case ContentSettingsTypes.AUTOMATIC_DOWNLOADS:
case ContentSettingsTypes.CAMERA:
case ContentSettingsTypes.CLIPBOARD:
case ContentSettingsTypes.FONT_ACCESS:
case ContentSettingsTypes.GEOLOCATION:
case ContentSettingsTypes.MIC:
case ContentSettingsTypes.NOTIFICATIONS:
......
......@@ -11,37 +11,38 @@
* @enum {string}
*/
export const ContentSettingsTypes = {
ADS: 'ads',
AR: 'ar',
AUTOMATIC_DOWNLOADS: 'multiple-automatic-downloads',
BACKGROUND_SYNC: 'background-sync',
BLUETOOTH_DEVICES: 'bluetooth-devices',
BLUETOOTH_SCANNING: 'bluetooth-scanning',
CAMERA: 'media-stream-camera',
CLIPBOARD: 'clipboard',
COOKIES: 'cookies',
FILE_SYSTEM_WRITE: 'file-system-write',
FONT_ACCESS: 'font-access',
GEOLOCATION: 'location',
HID_DEVICES: 'hid-devices',
IMAGES: 'images',
JAVASCRIPT: 'javascript',
SOUND: 'sound',
MIC: 'media-stream-mic', // AKA Microphone.
MIDI_DEVICES: 'midi-sysex',
MIXEDSCRIPT: 'mixed-script',
NOTIFICATIONS: 'notifications',
PAYMENT_HANDLER: 'payment-handler',
PLUGINS: 'plugins', // AKA Flash.
POPUPS: 'popups',
GEOLOCATION: 'location',
NOTIFICATIONS: 'notifications',
MIC: 'media-stream-mic', // AKA Microphone.
CAMERA: 'media-stream-camera',
PROTECTED_CONTENT: 'protected-content',
PROTOCOL_HANDLERS: 'register-protocol-handler',
SENSORS: 'sensors',
SERIAL_PORTS: 'serial-ports',
SOUND: 'sound',
UNSANDBOXED_PLUGINS: 'ppapi-broker',
AUTOMATIC_DOWNLOADS: 'multiple-automatic-downloads',
BACKGROUND_SYNC: 'background-sync',
MIDI_DEVICES: 'midi-sysex',
USB_DEVICES: 'usb-devices',
SERIAL_PORTS: 'serial-ports',
BLUETOOTH_DEVICES: 'bluetooth-devices',
ZOOM_LEVELS: 'zoom-levels',
PROTECTED_CONTENT: 'protected-content',
ADS: 'ads',
CLIPBOARD: 'clipboard',
SENSORS: 'sensors',
PAYMENT_HANDLER: 'payment-handler',
MIXEDSCRIPT: 'mixed-script',
BLUETOOTH_SCANNING: 'bluetooth-scanning',
FILE_SYSTEM_WRITE: 'file-system-write',
HID_DEVICES: 'hid-devices',
AR: 'ar',
VR: 'vr',
WINDOW_PLACEMENT: 'window-placement',
ZOOM_LEVELS: 'zoom-levels',
};
/**
......
......@@ -261,4 +261,11 @@
label="$i18n{siteSettingsWindowPlacement}">
</site-details-permission>
</template>
<template is="dom-if" if="[[enableFontAccessContentSetting_]]">
<site-details-permission
category="[[ContentSettingsTypes.FONT_ACCESS]]"
icon="settings:font-access" id="fontAccess"
label="$i18n{fonts}">
</site-details-permission>
</template>
</div>
......@@ -102,6 +102,14 @@ Polymer({
}
},
/** @private */
enableFontAccessContentSetting_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('enableFontAccessContentSetting');
}
},
/** @private */
enableInsecureContentContentSetting_: {
type: Boolean,
......
......@@ -234,6 +234,8 @@ const SiteSettingsBehaviorImpl = {
addOrRemoveSettingWithFlag(
ContentSettingsTypes.WINDOW_PLACEMENT,
'enableExperimentalWebPlatformFeatures');
addOrRemoveSettingWithFlag(
ContentSettingsTypes.FONT_ACCESS, 'enableFontAccessContentSetting');
return this.contentTypes_.slice(0);
},
......
......@@ -176,6 +176,8 @@ Polymer({
return this.i18n('siteSettingsVr');
case ContentSettingsTypes.WINDOW_PLACEMENT:
return this.i18n('siteSettingsWindowPlacement');
case ContentSettingsTypes.FONT_ACCESS:
return this.i18n('fonts');
default:
return '';
}
......
......@@ -190,6 +190,16 @@ function getCategoryItemMap() {
shouldShow: () =>
loadTimeData.getBoolean('enableFileSystemWriteContentSetting'),
},
{
route: routes.SITE_SETTINGS_FONT_ACCESS,
id: Id.FONT_ACCESS,
label: 'fonts',
icon: 'settings:font-access',
enabledLabel: 'siteSettingsFontAccessAsk',
disabledLabel: 'siteSettingsFontAccessBlock',
shouldShow: () =>
loadTimeData.getBoolean('enableFontAccessContentSetting'),
},
{
route: routes.SITE_SETTINGS_NOTIFICATIONS,
id: Id.NOTIFICATIONS,
......@@ -374,6 +384,7 @@ Polymer({
Id.AR,
Id.VR,
Id.WINDOW_PLACEMENT,
Id.FONT_ACCESS,
]),
contentBasic: buildItemListFromIds([
Id.COOKIES,
......
......@@ -140,6 +140,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"done", IDS_DONE},
{"edit", IDS_SETTINGS_EDIT},
{"extensionsLinkTooltip", IDS_SETTINGS_MENU_EXTENSIONS_LINK_TOOLTIP},
{"fonts", IDS_SETTINGS_FONTS},
{"learnMore", IDS_LEARN_MORE},
{"menu", IDS_MENU},
{"menuButtonLabel", IDS_SETTINGS_MENU_BUTTON_LABEL},
......@@ -324,7 +325,6 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source,
{"pageZoom", IDS_SETTINGS_PAGE_ZOOM_LABEL},
{"fontSize", IDS_SETTINGS_FONT_SIZE_LABEL},
{"customizeFonts", IDS_SETTINGS_CUSTOMIZE_FONTS},
{"fonts", IDS_SETTINGS_FONTS},
{"standardFont", IDS_SETTINGS_STANDARD_FONT_LABEL},
{"serifFont", IDS_SETTINGS_SERIF_FONT_LABEL},
{"sansSerifFont", IDS_SETTINGS_SANS_SERIF_FONT_LABEL},
......@@ -1937,6 +1937,9 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_ASK_RECOMMENDED},
{"siteSettingsWindowPlacementBlock",
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_BLOCK},
{"siteSettingsFontAccessAsk", IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_ASK},
{"siteSettingsFontAccessBlock",
IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_BLOCK},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
......@@ -2004,6 +2007,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(
features::kWebBluetoothNewPermissionsBackend));
html_source->AddBoolean(
"enableFontAccessContentSetting",
base::FeatureList::IsEnabled(::blink::features::kFontAccess));
// The exception placeholder should not be translated. See crbug.com/1095878.
html_source->AddString("addSiteExceptionPlaceholder", "[*.]example.com");
}
......
......@@ -158,6 +158,9 @@ suite('SiteDetails', function() {
createContentSettingTypeToValuePair(
ContentSettingsTypes.WINDOW_PLACEMENT,
[createRawSiteException('https://foo.com:443')]),
createContentSettingTypeToValuePair(
ContentSettingsTypes.FONT_ACCESS,
[createRawSiteException('https://foo.com:443')]),
],
[
createContentSettingTypeToValuePair(
......@@ -226,12 +229,15 @@ suite('SiteDetails', function() {
optionalSiteDetailsContentSettingsTypes[ContentSettingsTypes
.BLUETOOTH_DEVICES] =
'enableWebBluetoothNewPermissionsBackend';
optionalSiteDetailsContentSettingsTypes[ContentSettingsTypes.FONT_ACCESS] =
'enableFontAccessContentSetting';
const controlledSettingsCount = /** @type{string : int } */ ({});
controlledSettingsCount['enableExperimentalWebPlatformFeatures'] = 2;
controlledSettingsCount['enableInsecureContentContentSetting'] = 1;
controlledSettingsCount['enableFileSystemWriteContentSetting'] = 1;
controlledSettingsCount['enableFontAccessContentSetting'] = 1;
controlledSettingsCount['enablePaymentHandlerContentSetting'] = 1;
controlledSettingsCount['enableSafeBrowsingSubresourceFilter'] = 1;
controlledSettingsCount['enableWebBluetoothNewPermissionsBackend'] = 1;
......@@ -363,6 +369,7 @@ suite('SiteDetails', function() {
enableExperimentalWebPlatformFeatures: true,
enableInsecureContentContentSetting: true,
enableFileSystemWriteContentSetting: true,
enableFontAccessContentSetting: true,
enablePaymentHandlerContentSetting: true,
enableSafeBrowsingSubresourceFilter: true,
enableWebBluetoothNewPermissionsBackend: true,
......
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