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

Unified Diff: chrome/browser/resources/settings/site_settings/site_settings_category.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/site_settings_category.js
diff --git a/chrome/browser/resources/settings/site_settings/site_settings_category.js b/chrome/browser/resources/settings/site_settings/site_settings_category.js
index 7d1a33ff425f29d59118561c613c5fd1164204a3..c1debf754fca9e3a9cafe44fefb374a97750039e 100644
--- a/chrome/browser/resources/settings/site_settings/site_settings_category.js
+++ b/chrome/browser/resources/settings/site_settings/site_settings_category.js
@@ -2,6 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Define a global boolean for notifications (only enabled in the test class).
+cr.define('settings_test', function() {
+ var changeCategoryOptions = settings_test.changeCategoryOptions || {
tommycli 2016/02/18 22:15:18 Why is this called changeCategoryOptions instead o
Finnur 2016/02/19 10:18:13 I was struggling to find something that fit the sp
+ /**
+ * True if property changes should fire events for testing purposes.
+ * @type {boolean}
+ */
+ notifyPropertyChangesForTest: false,
+ };
+ return {changeCategoryOptions: changeCategoryOptions};
+});
+
/**
* @fileoverview
* 'site-settings-category' is the polymer element for showing a certain
@@ -43,7 +55,10 @@ Polymer({
* example, the Location category can be set to Block/Ask so false, in that
* case, represents Block and true represents Ask.
*/
- categoryEnabled: Boolean,
+ categoryEnabled: {
+ type: Boolean,
+ notify: settings_test.changeCategoryOptions.notifyPropertyChangesForTest,
+ },
/**
* The origin that was selected by the user in the dropdown list.
@@ -77,32 +92,36 @@ Polymer({
* @private
*/
onToggleChange_: function(event) {
+ var prefsProxy = settings.SiteSettingsPrefsProxy.getInstance();
switch (this.category) {
case settings.ContentSettingsTypes.COOKIES:
case settings.ContentSettingsTypes.JAVASCRIPT:
case settings.ContentSettingsTypes.POPUPS:
// "Allowed" vs "Blocked".
- this.setPrefValue(this.computeCategoryPrefName(this.category),
- this.categoryEnabled ?
- settings.PermissionValues.ALLOW :
- settings.PermissionValues.BLOCK);
+ prefsProxy.setDefaultValueForContentType(
+ this.category,
+ this.categoryEnabled ?
+ settings.PermissionValues.ALLOW :
+ settings.PermissionValues.BLOCK);
break;
case settings.ContentSettingsTypes.NOTIFICATIONS:
case settings.ContentSettingsTypes.GEOLOCATION:
case settings.ContentSettingsTypes.CAMERA:
case settings.ContentSettingsTypes.MIC:
// "Ask" vs "Blocked".
- this.setPrefValue(this.computeCategoryPrefName(this.category),
- this.categoryEnabled ?
- settings.PermissionValues.ASK :
- settings.PermissionValues.BLOCK);
+ prefsProxy.setDefaultValueForContentType(
+ this.category,
+ this.categoryEnabled ?
+ settings.PermissionValues.ASK :
+ settings.PermissionValues.BLOCK);
break;
case settings.ContentSettingsTypes.FULLSCREEN:
// "Allowed" vs. "Ask first".
- this.setPrefValue(this.computeCategoryPrefName(this.category),
- this.categoryEnabled ?
- settings.PermissionValues.ALLOW :
- settings.PermissionValues.ASK);
+ prefsProxy.setDefaultValueForContentType(
+ this.category,
+ this.categoryEnabled ?
+ settings.PermissionValues.ALLOW :
+ settings.PermissionValues.ASK);
break;
default:
assertNotReached();
@@ -114,6 +133,9 @@ Polymer({
* @private
*/
onCategoryChanged_: function() {
- this.categoryEnabled = this.isCategoryAllowed(this.category);
+ settings.SiteSettingsPrefsProxy.getInstance().getDefaultValueForContentType(
+ this.category).then(function(enabled) {
+ this.categoryEnabled = enabled;
+ }.bind(this));
},
});

Powered by Google App Engine
This is Rietveld 408576698