Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: chrome/browser/resources/settings/site_settings_page/site_settings_page.js

Issue 1698093007: Convert SiteSettingsCategory to use the HostContentSettingsMap instead of (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'ed Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/site_settings_page/site_settings_page.js
diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.js b/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
index 270f9bcd0ce65986d3729ed0efaf0977cd91c120..670ec2c11191aba89675f13bf3d4ea74371be4e3 100644
--- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
+++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
@@ -51,36 +51,50 @@ Polymer({
ready: function() {
CrSettingsPrefs.initialized.then(function() {
- this.addCategory(-1); // Every category (All Sites).
- this.addCategory(settings.ContentSettingsTypes.COOKIES);
- this.addCategory(settings.ContentSettingsTypes.GEOLOCATION);
- this.addCategory(settings.ContentSettingsTypes.CAMERA);
- this.addCategory(settings.ContentSettingsTypes.MIC);
- this.addCategory(settings.ContentSettingsTypes.JAVASCRIPT);
- this.addCategory(settings.ContentSettingsTypes.POPUPS);
- this.addCategory(settings.ContentSettingsTypes.FULLSCREEN);
- this.addCategory(settings.ContentSettingsTypes.NOTIFICATIONS);
- this.addCategory(settings.ContentSettingsTypes.IMAGES);
+ this.addCategory_(-1); // Every category (All Sites).
tommycli 2016/02/18 22:15:19 Ahh... the -1 sentinel value seems confusing. What
+ this.addCategory_(settings.ContentSettingsTypes.COOKIES);
+ this.addCategory_(settings.ContentSettingsTypes.GEOLOCATION);
+ this.addCategory_(settings.ContentSettingsTypes.CAMERA);
+ this.addCategory_(settings.ContentSettingsTypes.MIC);
+ this.addCategory_(settings.ContentSettingsTypes.JAVASCRIPT);
+ this.addCategory_(settings.ContentSettingsTypes.POPUPS);
+ this.addCategory_(settings.ContentSettingsTypes.FULLSCREEN);
+ this.addCategory_(settings.ContentSettingsTypes.NOTIFICATIONS);
+ this.addCategory_(settings.ContentSettingsTypes.IMAGES);
}.bind(this));
},
/**
* Adds a single category to the page.
* @param {number} category The category to add.
+ * @private
*/
- addCategory: function(category) {
- var icon, title, categoryDescription;
+ addCategory_: function(category) {
if (category === -1) {
- icon = 'list';
- title = loadTimeData.getString('siteSettingsCategoryAllSites');
- categoryDescription = '';
- } else {
- icon = this.computeIconForContentCategory(category);
- title = this.computeTitleForContentCategory(category);
- categoryDescription = this.computeCategoryDesc(
- category, this.isCategoryAllowed(category), false);
+ var description = loadTimeData.getString('siteSettingsCategoryAllSites');
+ this.addCategoryImpl_(category, 'list', description, '');
+ return;
}
+ var icon = this.computeIconForContentCategory(category);
+ var title = this.computeTitleForContentCategory(category);
+ settings.SiteSettingsPrefsProxy.getInstance().getDefaultValueForContentType(
+ category).then(function(enabled) {
+ var description = this.computeCategoryDesc(category, enabled, false);
+ this.addCategoryImpl_(category, icon, title, description);
+ }.bind(this));
+ },
+
+ /**
+ * Constructs the actual HTML elements for the category.
+ * @param {number} category The category to add.
+ * @param {string} icon The icon to show with it.
+ * @param {string} title The title to show for the category.
+ * @param {string} defaultValue The default value (permission) for the
+ * category.
+ * @private
+ */
+ addCategoryImpl_: function(category, icon, title, defaultValue) {
var root = this.$.list;
var paperIcon = document.createElement('paper-icon-item');
paperIcon.addEventListener('tap', this.onTapCategory.bind(this, category));
@@ -95,7 +109,7 @@ Polymer({
var setting = document.createElement('div');
setting.setAttribute('class', 'option-value');
- setting.appendChild(document.createTextNode(categoryDescription));
+ setting.appendChild(document.createTextNode(defaultValue));
paperIcon.appendChild(ironIcon);
paperIcon.appendChild(description);

Powered by Google App Engine
This is Rietveld 408576698