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.contentSettings', function() { | 5 cr.define('options.contentSettings', function() { |
| 6 /** @const */ var ControlledSettingIndicator = |
| 7 options.ControlledSettingIndicator; |
6 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
7 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 9 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 10 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 11 |
10 /** | 12 /** |
11 * Creates a new exceptions list item. | 13 * Creates a new exceptions list item. |
12 * | 14 * |
13 * @param {string} contentType The type of the list. | 15 * @param {string} contentType The type of the list. |
14 * @param {string} mode The browser mode, 'otr' or 'normal'. | 16 * @param {string} mode The browser mode, 'otr' or 'normal'. |
15 * @param {boolean} enableAskOption Whether to show an 'ask every time' | 17 * @param {boolean} enableAskOption Whether to show an 'ask every time' |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 this.updateEditables(); | 127 this.updateEditables(); |
126 | 128 |
127 // Editing notifications, geolocation and media-stream is disabled for | 129 // Editing notifications, geolocation and media-stream is disabled for |
128 // now. | 130 // now. |
129 if (this.contentType == 'notifications' || | 131 if (this.contentType == 'notifications' || |
130 this.contentType == 'location' || | 132 this.contentType == 'location' || |
131 this.contentType == 'media-stream') { | 133 this.contentType == 'media-stream') { |
132 this.editable = false; | 134 this.editable = false; |
133 } | 135 } |
134 | 136 |
135 // If the source of the content setting exception is not the user | 137 // If the source of the content setting exception is not a user |
136 // preference, then the content settings exception is managed and the user | 138 // preference, that source controls the exception and the user cannot edit |
137 // can't edit it. | 139 // or delete it. |
138 if (this.dataItem.source && | 140 var controlledBy = |
139 this.dataItem.source != 'preference') { | 141 this.dataItem.source && this.dataItem.source != 'preference' ? |
140 this.setAttribute('managedby', this.dataItem.source); | 142 this.dataItem.source : null; |
| 143 |
| 144 if (controlledBy) { |
| 145 this.setAttribute('controlled-by', controlledBy); |
141 this.deletable = false; | 146 this.deletable = false; |
142 this.editable = false; | 147 this.editable = false; |
143 } | 148 } |
144 | 149 |
| 150 if (controlledBy == 'policy' || controlledBy == 'extension') { |
| 151 this.querySelector('.row-delete-button').hidden = true; |
| 152 var indicator = ControlledSettingIndicator(); |
| 153 indicator.setAttribute('content-exception', this.contentType); |
| 154 // Create a synthetic pref change event decorated as |
| 155 // CoreOptionsHandler::CreateValueForPref() does. |
| 156 var event = new cr.Event(this.contentType); |
| 157 event.value = { controlledBy: controlledBy }; |
| 158 indicator.handlePrefChange(event); |
| 159 this.appendChild(indicator); |
| 160 } |
| 161 |
145 // If the exception comes from a hosted app, display the name and the | 162 // If the exception comes from a hosted app, display the name and the |
146 // icon of the app. | 163 // icon of the app. |
147 if (this.dataItem.source == 'HostedApp') { | 164 if (controlledBy == 'HostedApp') { |
148 this.title = | 165 this.title = |
149 loadTimeData.getString('set_by') + ' ' + this.dataItem.appName; | 166 loadTimeData.getString('set_by') + ' ' + this.dataItem.appName; |
150 var button = this.querySelector('.row-delete-button'); | 167 var button = this.querySelector('.row-delete-button'); |
151 // Use the host app's favicon (16px, match bigger size). | 168 // Use the host app's favicon (16px, match bigger size). |
152 // See c/b/ui/webui/extensions/extension_icon_source.h | 169 // See c/b/ui/webui/extensions/extension_icon_source.h |
153 // for a description of the chrome://extension-icon URL. | 170 // for a description of the chrome://extension-icon URL. |
154 button.style.backgroundImage = | 171 button.style.backgroundImage = |
155 'url(\'chrome://extension-icon/' + this.dataItem.appId + '/16/1\')'; | 172 'url(\'chrome://extension-icon/' + this.dataItem.appId + '/16/1\')'; |
156 } | 173 } |
157 | 174 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 626 } |
610 }; | 627 }; |
611 | 628 |
612 return { | 629 return { |
613 ExceptionsListItem: ExceptionsListItem, | 630 ExceptionsListItem: ExceptionsListItem, |
614 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 631 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
615 ExceptionsList: ExceptionsList, | 632 ExceptionsList: ExceptionsList, |
616 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 633 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
617 }; | 634 }; |
618 }); | 635 }); |
OLD | NEW |