OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
7 | 7 |
8 ////////////////////////////////////////////////////////////////////////////// | 8 ////////////////////////////////////////////////////////////////////////////// |
9 // ContentSettings class: | 9 // ContentSettings class: |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 document.querySelector(selector).checked = true; | 91 document.querySelector(selector).checked = true; |
92 }; | 92 }; |
93 | 93 |
94 /** | 94 /** |
95 * Sets the values for all the content settings radios. | 95 * Sets the values for all the content settings radios. |
96 * @param {Object} dict A mapping from radio groups to the checked value for | 96 * @param {Object} dict A mapping from radio groups to the checked value for |
97 * that group. | 97 * that group. |
98 */ | 98 */ |
99 ContentSettings.setContentFilterSettingsValue = function(dict) { | 99 ContentSettings.setContentFilterSettingsValue = function(dict) { |
100 for (var group in dict) { | 100 for (var group in dict) { |
| 101 var managedBy = dict[group].managedBy; |
| 102 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? |
| 103 managedBy : null; |
101 document.querySelector('input[type=radio][name=' + group + '][value=' + | 104 document.querySelector('input[type=radio][name=' + group + '][value=' + |
102 dict[group].value + ']').checked = true; | 105 dict[group].value + ']').checked = true; |
103 var radios = document.querySelectorAll('input[type=radio][name=' + | 106 var radios = document.querySelectorAll('input[type=radio][name=' + |
104 group + ']'); | 107 group + ']'); |
105 var managedBy = dict[group]['managedBy']; | |
106 for (var i = 0, len = radios.length; i < len; i++) { | 108 for (var i = 0, len = radios.length; i < len; i++) { |
107 radios[i].disabled = (managedBy != 'default'); | 109 radios[i].disabled = (managedBy != 'default'); |
108 radios[i].controlledBy = managedBy; | 110 radios[i].controlledBy = controlledBy; |
109 } | 111 } |
| 112 var indicators = document.querySelectorAll( |
| 113 'span.controlled-setting-indicator[content-setting=' + group + ']'); |
| 114 if (indicators.length == 0) |
| 115 continue; |
| 116 // Create a synthetic pref change event decorated as |
| 117 // CoreOptionsHandler::CreateValueForPref() does. |
| 118 var event = new cr.Event(group); |
| 119 event.value = { |
| 120 value: dict[group].value, |
| 121 controlledBy: controlledBy, |
| 122 }; |
| 123 for (var i = 0; i < indicators.length; i++) |
| 124 indicators[i].handlePrefChange(event); |
110 } | 125 } |
111 OptionsPage.updateManagedBannerVisibility(); | 126 OptionsPage.updateManagedBannerVisibility(); |
112 }; | 127 }; |
113 | 128 |
114 /** | 129 /** |
115 * Initializes an exceptions list. | 130 * Initializes an exceptions list. |
116 * @param {string} type The content type that we are setting exceptions for. | 131 * @param {string} type The content type that we are setting exceptions for. |
117 * @param {Array} list An array of pairs, where the first element of each pair | 132 * @param {Array} list An array of pairs, where the first element of each pair |
118 * is the filter string, and the second is the setting (allow/block). | 133 * is the filter string, and the second is the setting (allow/block). |
119 */ | 134 */ |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 $('pepper-flash-cameramic-section').style.display = ''; | 182 $('pepper-flash-cameramic-section').style.display = ''; |
168 $('pepper-flash-cameramic-exceptions-div').style.display = ''; | 183 $('pepper-flash-cameramic-exceptions-div').style.display = ''; |
169 } | 184 } |
170 | 185 |
171 // Export | 186 // Export |
172 return { | 187 return { |
173 ContentSettings: ContentSettings | 188 ContentSettings: ContentSettings |
174 }; | 189 }; |
175 | 190 |
176 }); | 191 }); |
OLD | NEW |