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 26 matching lines...) Expand all Loading... | |
42 | 44 |
43 this.isPlaceholder = !this.pattern; | 45 this.isPlaceholder = !this.pattern; |
44 var patternCell = this.createEditableTextCell(this.pattern); | 46 var patternCell = this.createEditableTextCell(this.pattern); |
45 patternCell.className = 'exception-pattern'; | 47 patternCell.className = 'exception-pattern'; |
46 patternCell.classList.add('weakrtl'); | 48 patternCell.classList.add('weakrtl'); |
47 this.contentElement.appendChild(patternCell); | 49 this.contentElement.appendChild(patternCell); |
48 if (this.pattern) | 50 if (this.pattern) |
49 this.patternLabel = patternCell.querySelector('.static-text'); | 51 this.patternLabel = patternCell.querySelector('.static-text'); |
50 var input = patternCell.querySelector('input'); | 52 var input = patternCell.querySelector('input'); |
51 | 53 |
54 // If the source of the content setting exception is not a user | |
55 // preference, that source controls the exception and the user cannot edit | |
56 // or delete it. | |
57 var controlledBy = | |
58 this.dataItem.source && this.dataItem.source != 'preference' ? | |
59 this.dataItem.source : null; | |
Joao da Silva
2012/10/15 08:02:32
How about:
var controlledBy = this.dataItem.sourc
bartfab (slow)
2012/10/15 12:34:07
Move done. The change to the code you suggested wi
Joao da Silva
2012/10/15 12:53:59
|controlledBy| is always tested before begin used
| |
60 | |
52 // TODO(stuartmorgan): Create an createEditableSelectCell abstracting | 61 // TODO(stuartmorgan): Create an createEditableSelectCell abstracting |
53 // this code. | 62 // this code. |
54 // Setting label for display mode. |pattern| will be null for the 'add new | 63 // Setting label for display mode. |pattern| will be null for the 'add new |
55 // exception' row. | 64 // exception' row. |
56 if (this.pattern) { | 65 if (this.pattern) { |
57 var settingLabel = cr.doc.createElement('span'); | 66 var settingLabel = cr.doc.createElement('span'); |
58 settingLabel.textContent = this.settingForDisplay(); | 67 settingLabel.textContent = this.settingForDisplay(); |
59 settingLabel.className = 'exception-setting'; | 68 settingLabel.className = 'exception-setting'; |
60 settingLabel.setAttribute('displaymode', 'static'); | 69 settingLabel.setAttribute('displaymode', 'static'); |
61 this.contentElement.appendChild(settingLabel); | 70 this.contentElement.appendChild(settingLabel); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 this.updateEditables(); | 134 this.updateEditables(); |
126 | 135 |
127 // Editing notifications, geolocation and media-stream is disabled for | 136 // Editing notifications, geolocation and media-stream is disabled for |
128 // now. | 137 // now. |
129 if (this.contentType == 'notifications' || | 138 if (this.contentType == 'notifications' || |
130 this.contentType == 'location' || | 139 this.contentType == 'location' || |
131 this.contentType == 'media-stream') { | 140 this.contentType == 'media-stream') { |
132 this.editable = false; | 141 this.editable = false; |
133 } | 142 } |
134 | 143 |
135 // If the source of the content setting exception is not the user | 144 if (controlledBy) { |
136 // preference, then the content settings exception is managed and the user | 145 this.setAttribute('controlled-by', controlledBy); |
137 // can't edit it. | |
138 if (this.dataItem.source && | |
139 this.dataItem.source != 'preference') { | |
140 this.setAttribute('managedby', this.dataItem.source); | |
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 |