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

Unified Diff: chrome/browser/resources/settings/site_settings/site_settings_category.js

Issue 1372053002: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
new file mode 100644
index 0000000000000000000000000000000000000000..3e6a8928e939f8b5562a8c79e6a09e8355180427
--- /dev/null
+++ b/chrome/browser/resources/settings/site_settings/site_settings_category.js
@@ -0,0 +1,109 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * 'site-settings-category' is the settings page for showing a certain
+ * category under Site Settings.
+ *
+ * Example:
+ *
+ * <site-settings-category prefs="{{prefs}}">
+ * </site-settings-category>
+ * ... other pages ...
+ *
+ * @group Chrome Settings Elements
+ * @element site-settings-category
+ */
+Polymer({
+ is: 'site-settings-category',
+
+ behaviors: [SiteSettingsBehavior],
+
+ properties: {
+ /**
+ * Preferences state.
+ */
+ prefs: {
+ type: Object,
+ notify: true,
+ },
+
+ /**
+ * Represents the state of the main toggle shown for the category. For
+ * example, the Location category can be set to Block/Ask so false, in that
+ * case, represents Block and true represents Ask.
+ */
+ categoryEnabled: {
+ type: Boolean,
+ },
+
+ /**
+ * The ID of the category this widget is displaying data for.
+ */
+ category: {
+ type: Number,
+ },
+ },
+
+ observers: [
+ 'categoryPrefChanged_(prefs.profile.default_content_setting_values.*)',
+ ],
+
+ ready: function() {
+ this.$.blockList.categorySubtype = settings.DefaultValues.BLOCK;
+ this.$.allowList.categorySubtype = settings.DefaultValues.ALLOW;
+
+ CrSettingsPrefs.initialized.then(function() {
+ this.categoryEnabled = this.isCategoryAllowed(this.category);
+ }.bind(this));
+ },
+
+ /**
+ * A handler for flipping the toggle value.
+ * @private
+ */
+ onToggleChange_: function(event) {
+ assert(CrSettingsPrefs.isInitialized);
+
+ 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.DefaultValues.ALLOW :
+ settings.DefaultValues.BLOCK);
+ break;
+ case settings.ContentSettingsTypes.NOTIFICATION:
+ case settings.ContentSettingsTypes.GEOLOCATION:
+ case settings.ContentSettingsTypes.CAMERA:
+ case settings.ContentSettingsTypes.MIC:
+ // "Ask" vs "Blocked".
+ this.setPrefValue(this.computeCategoryPrefName(this.category),
+ this.categoryEnabled ?
+ settings.DefaultValues.ASK :
+ settings.DefaultValues.BLOCK);
+ break;
+ case settings.ContentSettingsTypes.FULLSCREEN:
+ // "Allowed" vs. "Ask first".
+ this.setPrefValue(this.computeCategoryPrefName(this.category),
+ this.categoryEnabled ?
+ settings.DefaultValues.ALLOW :
+ settings.DefaultValues.ASK);
+ break;
+ default:
+ assertNotReached();
+ }
+ },
+
+ /**
+ * Handles when the global toggle changes.
+ * @private
+ */
+ categoryPrefChanged_: function() {
+ this.categoryEnabled = this.isCategoryAllowed(this.category);
+ },
+});

Powered by Google App Engine
This is Rietveld 408576698