| 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 = | 6 /** @const */ var ControlledSettingIndicator = |
| 7 options.ControlledSettingIndicator; | 7 options.ControlledSettingIndicator; |
| 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
| 9 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 9 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
| 10 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 10 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Returns whether exceptions list for the type is editable. | 13 * Returns whether exceptions list for the type is editable. |
| 14 * | 14 * |
| 15 * @param {string} contentType The type of the list. | 15 * @param {string} contentType The type of the list. |
| 16 */ | 16 */ |
| 17 function IsEditableType(contentType) { | 17 function IsEditableType(contentType) { |
| 18 // Exceptions of the following lists are not editable for now. | 18 // Exceptions of the following lists are not editable for now. |
| 19 return !(contentType == 'notifications' || | 19 return !(contentType == 'notifications' || |
| 20 contentType == 'location' || | 20 contentType == 'location' || |
| 21 contentType == 'fullscreen' || | 21 contentType == 'fullscreen' || |
| 22 contentType == 'media-stream' || | 22 contentType == 'media-stream-mic' || |
| 23 contentType == 'media-stream-camera' || |
| 23 contentType == 'midi-sysex' || | 24 contentType == 'midi-sysex' || |
| 24 contentType == 'zoomlevels'); | 25 contentType == 'zoomlevels'); |
| 25 } | 26 } |
| 26 | 27 |
| 27 /** | 28 /** |
| 28 * Creates a new exceptions list item. | 29 * Creates a new exceptions list item. |
| 29 * | 30 * |
| 30 * @param {string} contentType The type of the list. | 31 * @param {string} contentType The type of the list. |
| 31 * @param {string} mode The browser mode, 'otr' or 'normal'. | 32 * @param {string} mode The browser mode, 'otr' or 'normal'. |
| 32 * @param {Object} exception A dictionary that contains the data of the | 33 * @param {Object} exception A dictionary that contains the data of the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (this.contentType != 'zoomlevels') { | 120 if (this.contentType != 'zoomlevels') { |
| 120 this.addEditField(select, this.settingLabel); | 121 this.addEditField(select, this.settingLabel); |
| 121 this.contentElement.appendChild(select); | 122 this.contentElement.appendChild(select); |
| 122 } | 123 } |
| 123 select.className = 'exception-setting'; | 124 select.className = 'exception-setting'; |
| 124 select.setAttribute('aria-labelledby', 'exception-behavior-column'); | 125 select.setAttribute('aria-labelledby', 'exception-behavior-column'); |
| 125 | 126 |
| 126 if (this.pattern) | 127 if (this.pattern) |
| 127 select.setAttribute('displaymode', 'edit'); | 128 select.setAttribute('displaymode', 'edit'); |
| 128 | 129 |
| 129 if (this.contentType == 'media-stream') { | |
| 130 this.settingLabel.classList.add('media-audio-setting'); | |
| 131 | |
| 132 var videoSettingLabel = cr.doc.createElement('span'); | |
| 133 videoSettingLabel.textContent = this.videoSettingForDisplay(); | |
| 134 videoSettingLabel.className = 'exception-setting'; | |
| 135 videoSettingLabel.classList.add('media-video-setting'); | |
| 136 videoSettingLabel.setAttribute('displaymode', 'static'); | |
| 137 this.contentElement.appendChild(videoSettingLabel); | |
| 138 } | |
| 139 | |
| 140 if (this.contentType == 'zoomlevels') { | 130 if (this.contentType == 'zoomlevels') { |
| 141 this.deletable = true; | 131 this.deletable = true; |
| 142 | 132 |
| 143 var zoomLabel = cr.doc.createElement('span'); | 133 var zoomLabel = cr.doc.createElement('span'); |
| 144 zoomLabel.textContent = this.dataItem.zoom; | 134 zoomLabel.textContent = this.dataItem.zoom; |
| 145 zoomLabel.className = 'exception-setting'; | 135 zoomLabel.className = 'exception-setting'; |
| 146 zoomLabel.setAttribute('displaymode', 'static'); | 136 zoomLabel.setAttribute('displaymode', 'static'); |
| 147 zoomLabel.setAttribute('aria-labelledby', 'exception-zoom-column'); | 137 zoomLabel.setAttribute('aria-labelledby', 'exception-zoom-column'); |
| 148 this.contentElement.appendChild(zoomLabel); | 138 this.contentElement.appendChild(zoomLabel); |
| 149 this.zoomLabel = zoomLabel; | 139 this.zoomLabel = zoomLabel; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 /** | 247 /** |
| 258 * Gets a human-readable setting string. | 248 * Gets a human-readable setting string. |
| 259 * | 249 * |
| 260 * @return {string} The display string. | 250 * @return {string} The display string. |
| 261 */ | 251 */ |
| 262 settingForDisplay: function() { | 252 settingForDisplay: function() { |
| 263 return this.getDisplayStringForSetting(this.setting); | 253 return this.getDisplayStringForSetting(this.setting); |
| 264 }, | 254 }, |
| 265 | 255 |
| 266 /** | 256 /** |
| 267 * media video specific function. | |
| 268 * Gets a human-readable video setting string. | |
| 269 * | |
| 270 * @return {string} The display string. | |
| 271 */ | |
| 272 videoSettingForDisplay: function() { | |
| 273 return this.getDisplayStringForSetting(this.dataItem.video); | |
| 274 }, | |
| 275 | |
| 276 /** | |
| 277 * Gets a human-readable display string for setting. | 257 * Gets a human-readable display string for setting. |
| 278 * | 258 * |
| 279 * @param {string} setting The setting to be displayed. | 259 * @param {string} setting The setting to be displayed. |
| 280 * @return {string} The display string. | 260 * @return {string} The display string. |
| 281 */ | 261 */ |
| 282 getDisplayStringForSetting: function(setting) { | 262 getDisplayStringForSetting: function(setting) { |
| 283 if (setting == 'allow') | 263 if (setting == 'allow') |
| 284 return loadTimeData.getString('allowException'); | 264 return loadTimeData.getString('allowException'); |
| 285 else if (setting == 'block') | 265 else if (setting == 'block') |
| 286 return loadTimeData.getString('blockException'); | 266 return loadTimeData.getString('blockException'); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 header.textContent = loadTimeData.getString(camelCasedType + 'Header'); | 613 header.textContent = loadTimeData.getString(camelCasedType + 'Header'); |
| 634 | 614 |
| 635 var divs = this.pageDiv.querySelectorAll('div[contentType]'); | 615 var divs = this.pageDiv.querySelectorAll('div[contentType]'); |
| 636 for (var i = 0; i < divs.length; i++) { | 616 for (var i = 0; i < divs.length; i++) { |
| 637 if (divs[i].getAttribute('contentType') == type) | 617 if (divs[i].getAttribute('contentType') == type) |
| 638 divs[i].hidden = false; | 618 divs[i].hidden = false; |
| 639 else | 619 else |
| 640 divs[i].hidden = true; | 620 divs[i].hidden = true; |
| 641 } | 621 } |
| 642 | 622 |
| 643 var mediaHeader = this.pageDiv.querySelector('.media-header'); | |
| 644 mediaHeader.hidden = type != 'media-stream'; | |
| 645 | |
| 646 $('exception-behavior-column').hidden = type == 'zoomlevels'; | 623 $('exception-behavior-column').hidden = type == 'zoomlevels'; |
| 647 $('exception-zoom-column').hidden = type != 'zoomlevels'; | 624 $('exception-zoom-column').hidden = type != 'zoomlevels'; |
| 648 }, | 625 }, |
| 649 | 626 |
| 650 /** | 627 /** |
| 651 * Called after the page has been shown. Show the content type for the | 628 * Called after the page has been shown. Show the content type for the |
| 652 * location's hash. | 629 * location's hash. |
| 653 */ | 630 */ |
| 654 didShowPage: function() { | 631 didShowPage: function() { |
| 655 if (this.hash) | 632 if (this.hash) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 678 } | 655 } |
| 679 }; | 656 }; |
| 680 | 657 |
| 681 return { | 658 return { |
| 682 ExceptionsListItem: ExceptionsListItem, | 659 ExceptionsListItem: ExceptionsListItem, |
| 683 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 660 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
| 684 ExceptionsList: ExceptionsList, | 661 ExceptionsList: ExceptionsList, |
| 685 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 662 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
| 686 }; | 663 }; |
| 687 }); | 664 }); |
| OLD | NEW |