Skip to content

Commit

Permalink
Add brave_page_visibility.js to provide our own pageVisibility setting
Browse files Browse the repository at this point in the history
  • Loading branch information
yrliou committed Jun 26, 2018
1 parent 2e3f208 commit 6b43657
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
1 change: 1 addition & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<includes>
<include name="IDR_BRAVE_TAG_SERVICES_POLYFILL" file="resources/js/tag_services_polyfill.js" type="BINDATA" />
<include name="IDR_BRAVE_TAG_MANAGER_POLYFILL" file="resources/js/tag_manager_polyfill.js" type="BINDATA" />
<include name="IDR_SETTINGS_BRAVE_PAGE_VISIBILITY_JS" file="resources/js/brave_page_visibility.js" type="BINDATA" />
</includes>
</release>
</grit>
32 changes: 32 additions & 0 deletions app/resources/js/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 };
});
2 changes: 2 additions & 0 deletions chromium_src/chrome/grit/settings_resources.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "brave/grit/brave_generated_resources.h"
#include "gen/chrome/grit/settings_resources.h"
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>
36 changes: 0 additions & 36 deletions patches/chrome-browser-resources-settings-page_visibility.js.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chrome/browser/ui/webui/settings/md_settings_ui.cc
index f8e4ae44148aa01579097d4ef373025b66dde788..dde5c9c64bdeb0091e7b7780e295b5d402d62249 100644
index f8e4ae44148aa01579097d4ef373025b66dde788..1443b742c463e76462c1547452228975cd931946 100644
--- a/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -122,6 +122,7 @@ void MdSettingsUI::RegisterProfilePrefs(
Expand All @@ -10,3 +10,11 @@ index f8e4ae44148aa01579097d4ef373025b66dde788..dde5c9c64bdeb0091e7b7780e295b5d4
}

MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
@@ -341,6 +342,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddResourcePath(kSettingsResources[i].name,
kSettingsResources[i].value);
}
+ html_source->AddResourcePath("brave_page_visibility.js", IDR_SETTINGS_BRAVE_PAGE_VISIBILITY_JS);
html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML);
#endif

0 comments on commit 6b43657

Please sign in to comment.