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

Side by Side Diff: chrome/browser/resources/settings/site_settings_page/site_settings_page.js

Issue 2659833002: [MD settings] Data driven content setting subtext (Closed)
Patch Set: unit tests Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-site-settings-page' is the settings page containing privacy and 7 * 'settings-site-settings-page' is the settings page containing privacy and
8 * security site settings. 8 * security site settings.
9 */ 9 */
10
10 Polymer({ 11 Polymer({
11 is: 'settings-site-settings-page', 12 is: 'settings-site-settings-page',
12 13
13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], 14 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
14 15
15 properties: { 16 properties: {
16 /** 17 /**
17 * An object to bind default value labels to (so they are not in the |this| 18 * An object to bind default values to (so they are not in the |this|
18 * scope). The keys of this object are the values of the 19 * scope). The keys of this object are the values of the
19 * settings.ContentSettingsTypes enum. 20 * settings.ContentSettingsTypes enum.
20 * @private 21 * @private
21 */ 22 */
22 default_: { 23 default_: {
23 type: Object, 24 type: Object,
24 value: function() { 25 value: function() {
25 return {}; 26 return {};
26 }, 27 },
27 }, 28 },
(...skipping 25 matching lines...) Expand all
53 this.addWebUIListener( 54 this.addWebUIListener(
54 'contentSettingCategoryChanged', 55 'contentSettingCategoryChanged',
55 this.updateDefaultValueLabel_.bind(this)); 56 this.updateDefaultValueLabel_.bind(this));
56 this.addWebUIListener( 57 this.addWebUIListener(
57 'setHandlersEnabled', 58 'setHandlersEnabled',
58 this.updateHandlersEnabled_.bind(this)); 59 this.updateHandlersEnabled_.bind(this));
59 this.browserProxy.observeProtocolHandlersEnabledState(); 60 this.browserProxy.observeProtocolHandlersEnabledState();
60 }, 61 },
61 62
62 /** 63 /**
64 * @param {string} setting Value from settings.PermissionValues.
65 * @param {string} enabled Non-block label ('feature X not allowed').
66 * @param {string} disabled Block label (likely just, 'Blocked').
67 * @param {?string} other Tristate value (maybe, 'session only').
68 * @private
69 */
70 defaultSettingLabel_: function(setting, enabled, disabled, other) {
71 if (setting == settings.PermissionValues.BLOCK)
72 return disabled;
73 if (setting == settings.PermissionValues.ALLOW)
74 return enabled;
75 if (other)
76 return other;
77 return enabled;
78 },
79
80 /**
63 * @param {string} category The category to update. 81 * @param {string} category The category to update.
64 * @private 82 * @private
65 */ 83 */
66 updateDefaultValueLabel_: function(category) { 84 updateDefaultValueLabel_: function(category) {
67 this.browserProxy.getDefaultValueForContentType( 85 this.browserProxy.getDefaultValueForContentType(
68 category).then(function(defaultValue) { 86 category).then(function(defaultValue) {
69 this.set( 87 this.set(
70 'default_.' + Polymer.CaseMap.dashToCamelCase(category), 88 'default_.' + Polymer.CaseMap.dashToCamelCase(category),
71 this.computeCategoryDesc( 89 defaultValue.setting);
72 category,
73 defaultValue.setting,
74 /*showRecommendation=*/false));
75 }.bind(this)); 90 }.bind(this));
76 }, 91 },
77 92
78 /** 93 /**
79 * The protocol handlers have a separate enabled/disabled notifier. 94 * The protocol handlers have a separate enabled/disabled notifier.
80 * @param {boolean} enabled 95 * @param {boolean} enabled
81 * @private 96 * @private
82 */ 97 */
83 updateHandlersEnabled_: function(enabled) { 98 updateHandlersEnabled_: function(enabled) {
84 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; 99 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS;
85 this.set( 100 this.set(
86 'default_.' + Polymer.CaseMap.dashToCamelCase(category), 101 'default_.' + Polymer.CaseMap.dashToCamelCase(category),
87 this.computeCategoryDesc( 102 enabled ?
88 category, 103 settings.PermissionValues.ALLOW :
89 enabled ? 104 settings.PermissionValues.BLOCK);
90 settings.PermissionValues.ALLOW :
91 settings.PermissionValues.BLOCK,
92 /*showRecommendation=*/false));
93 }, 105 },
94 106
95 /** 107 /**
96 * Navigate to the route specified in the event dataset. 108 * Navigate to the route specified in the event dataset.
97 * @param {!Event} event The tap event. 109 * @param {!Event} event The tap event.
98 * @private 110 * @private
99 */ 111 */
100 onTapNavigate_: function(event) { 112 onTapNavigate_: function(event) {
101 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); 113 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset);
102 settings.navigateTo(settings.Route[dataSet.route]); 114 settings.navigateTo(settings.Route[dataSet.route]);
103 }, 115 },
104 }); 116 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings_page/site_settings_page.html ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698