Skip to content

Commit

Permalink
add brave_page_visibility.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yrliou committed Jul 1, 2018
1 parent c20dbc3 commit 45c8a93
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
32 changes: 32 additions & 0 deletions browser/resources/settings/brave_page_visibility.js
Original file line number Diff line number Diff line change
@@ -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 };
});
3 changes: 3 additions & 0 deletions browser/resources/settings/settings_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,9 @@
<structure name="IDR_SETTINGS_PAGE_VISIBILITY_HTML"
file="page_visibility.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_BRAVE_PAGE_VISIBILITY_JS"
file="brave_page_visibility.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PAGE_VISIBILITY_JS"
file="page_visibility.js"
type="chrome_html"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/chrome/browser/resources/settings/page_visibility.html b/chrome/browser/resources/settings/page_visibility.html
index 8ea50773be028e98aa2d4f90477a05f69f5a476e..6f8314a72295c599bdf97831436562c205509f61 100644
--- a/chrome/browser/resources/settings/page_visibility.html
+++ b/chrome/browser/resources/settings/page_visibility.html
@@ -1,3 +1,4 @@
<link rel="import" href="chrome://resources/html/cr.html">

<script src="page_visibility.js"></script>
+<script src="brave_page_visibility.js"></script>

0 comments on commit 45c8a93

Please sign in to comment.