From 45c8a93e444a9668214c552a6b3ff86524deba7b Mon Sep 17 00:00:00 2001 From: Jocelyn Liu Date: Fri, 29 Jun 2018 16:43:24 -0700 Subject: [PATCH] add brave_page_visibility.js --- .../settings/brave_page_visibility.js | 32 +++++++++++++++++++ .../resources/settings/settings_resources.grd | 3 ++ ...ources-settings-page_visibility.html.patch | 9 ++++++ 3 files changed, 44 insertions(+) create mode 100644 browser/resources/settings/brave_page_visibility.js create mode 100644 patches/chrome-browser-resources-settings-page_visibility.html.patch diff --git a/browser/resources/settings/brave_page_visibility.js b/browser/resources/settings/brave_page_visibility.js new file mode 100644 index 000000000000..ccbfab8a9165 --- /dev/null +++ b/browser/resources/settings/brave_page_visibility.js @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +cr.define('settings', function() { + // use value defined in page_visibility.js in guest mode + if (loadTimeData.getBoolean('isGuest')) return; + + // We need to specify values for every attribute in pageVisibility instead of + // only overriding specific attributes here because chromium does not + // explicitly define pageVisibility in page_visibility.js since polymer only + // notifies after a property is set. + // Use proxy objects here so we only need to write out the attributes we + // would like to hide. + + const appearanceHandler = { + get: function(obj, prop) { + return prop === 'setTheme' ? false : true; + } + }; + + const handler = { + get: function(obj, prop) { + if (prop === 'appearance') return new Proxy({}, appearanceHandler); + return prop === 'a11y' ? false : true; + } + }; + + let proxy = new Proxy({}, handler); + + return { pageVisibility: proxy }; +}); diff --git a/browser/resources/settings/settings_resources.grd b/browser/resources/settings/settings_resources.grd index 2ee3649d9615..3d8bc025ccd3 100644 --- a/browser/resources/settings/settings_resources.grd +++ b/browser/resources/settings/settings_resources.grd @@ -918,6 +918,9 @@ + + + ++