| 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 Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
| 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 8 |
| 9 // Lookup table to generate the i18n strings. |
| 10 /** @const */ var permissionsLookup = { |
| 11 'location': 'location', |
| 12 'notifications': 'notifications', |
| 13 'media-stream': 'mediaStream', |
| 14 'cookies': 'cookies', |
| 15 'multiple-automatic-downloads': 'multipleAutomaticDownloads', |
| 16 'images': 'images', |
| 17 'plugins': 'plugins', |
| 18 'popups': 'popups', |
| 19 'javascript': 'javascript' |
| 20 }; |
| 21 |
| 9 ////////////////////////////////////////////////////////////////////////////// | 22 ////////////////////////////////////////////////////////////////////////////// |
| 10 // ContentSettings class: | 23 // ContentSettings class: |
| 11 | 24 |
| 12 /** | 25 /** |
| 13 * Encapsulated handling of content settings page. | 26 * Encapsulated handling of content settings page. |
| 14 * @constructor | 27 * @constructor |
| 15 */ | 28 */ |
| 16 function ContentSettings() { | 29 function ContentSettings() { |
| 17 this.activeNavTab = null; | 30 this.activeNavTab = null; |
| 18 Page.call(this, 'content', | 31 Page.call(this, 'content', |
| (...skipping 21 matching lines...) Expand all Loading... |
| 40 var hash = event.currentTarget.getAttribute('contentType'); | 53 var hash = event.currentTarget.getAttribute('contentType'); |
| 41 var url = page.name + '#' + hash; | 54 var url = page.name + '#' + hash; |
| 42 uber.pushState({pageName: page.name}, url); | 55 uber.pushState({pageName: page.name}, url); |
| 43 | 56 |
| 44 // Navigate after the local history has been replaced in order to have | 57 // Navigate after the local history has been replaced in order to have |
| 45 // the correct hash loaded. | 58 // the correct hash loaded. |
| 46 PageManager.showPageByName('contentExceptions', false); | 59 PageManager.showPageByName('contentExceptions', false); |
| 47 }; | 60 }; |
| 48 } | 61 } |
| 49 | 62 |
| 63 var experimentalExceptionsButtons = |
| 64 this.pageDiv.querySelectorAll('.website-settings-permission-button'); |
| 65 for (var i = 0; i < experimentalExceptionsButtons.length; i++) { |
| 66 experimentalExceptionsButtons[i].onclick = function(event) { |
| 67 var page = WebsiteSettingsManager.getInstance(); |
| 68 var hash = event.currentTarget.getAttribute('contentType'); |
| 69 var url = page.name + '#' + hash; |
| 70 uber.pushState({pageName: page.name}, url); |
| 71 |
| 72 // Navigate after the local history has been replaced in order to have |
| 73 // the correct hash loaded. |
| 74 PageManager.showPageByName('websiteSettings', false); |
| 75 }; |
| 76 } |
| 77 |
| 50 var manageHandlersButton = $('manage-handlers-button'); | 78 var manageHandlersButton = $('manage-handlers-button'); |
| 51 if (manageHandlersButton) { | 79 if (manageHandlersButton) { |
| 52 manageHandlersButton.onclick = function(event) { | 80 manageHandlersButton.onclick = function(event) { |
| 53 PageManager.showPageByName('handlers'); | 81 PageManager.showPageByName('handlers'); |
| 54 }; | 82 }; |
| 55 } | 83 } |
| 56 | 84 |
| 57 if (cr.isChromeOS) { | 85 if (cr.isChromeOS) { |
| 58 // Disable some controls for Guest in Chrome OS. | 86 // Disable some controls for Guest in Chrome OS. |
| 59 UIAccountTweaks.applyGuestSessionVisibility(document); | 87 UIAccountTweaks.applyGuestSessionVisibility(document); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 $('content-settings-overlay-confirm').onclick = | 99 $('content-settings-overlay-confirm').onclick = |
| 72 PageManager.closeOverlay.bind(PageManager); | 100 PageManager.closeOverlay.bind(PageManager); |
| 73 | 101 |
| 74 $('media-pepper-flash-default').hidden = true; | 102 $('media-pepper-flash-default').hidden = true; |
| 75 $('media-pepper-flash-exceptions').hidden = true; | 103 $('media-pepper-flash-exceptions').hidden = true; |
| 76 | 104 |
| 77 $('media-select-mic').addEventListener('change', | 105 $('media-select-mic').addEventListener('change', |
| 78 ContentSettings.setDefaultMicrophone_); | 106 ContentSettings.setDefaultMicrophone_); |
| 79 $('media-select-camera').addEventListener('change', | 107 $('media-select-camera').addEventListener('change', |
| 80 ContentSettings.setDefaultCamera_); | 108 ContentSettings.setDefaultCamera_); |
| 109 |
| 110 if (loadTimeData.getBoolean('websiteSettingsManagerEnabled')) { |
| 111 var oldUI = |
| 112 this.pageDiv.querySelectorAll('.replace-with-website-settings'); |
| 113 for (var i = 0; i < oldUI.length; i++) { |
| 114 oldUI[i].hidden = true; |
| 115 } |
| 116 |
| 117 var newUI = |
| 118 this.pageDiv.querySelectorAll('.experimental-website-settings'); |
| 119 for (var i = 0; i < newUI.length; i++) { |
| 120 newUI[i].hidden = false; |
| 121 } |
| 122 } |
| 81 }, | 123 }, |
| 82 }; | 124 }; |
| 83 | 125 |
| 84 ContentSettings.updateHandlersEnabledRadios = function(enabled) { | 126 ContentSettings.updateHandlersEnabledRadios = function(enabled) { |
| 85 var selector = '#content-settings-page input[type=radio][value=' + | 127 var selector = '#content-settings-page input[type=radio][value=' + |
| 86 (enabled ? 'allow' : 'block') + '].handler-radio'; | 128 (enabled ? 'allow' : 'block') + '].handler-radio'; |
| 87 document.querySelector(selector).checked = true; | 129 document.querySelector(selector).checked = true; |
| 88 }; | 130 }; |
| 89 | 131 |
| 90 /** | 132 /** |
| 91 * Sets the values for all the content settings radios. | 133 * Sets the values for all the content settings radios and labels. |
| 92 * @param {Object} dict A mapping from radio groups to the checked value for | 134 * @param {Object} dict A mapping from radio groups to the checked value for |
| 93 * that group. | 135 * that group. |
| 94 */ | 136 */ |
| 95 ContentSettings.setContentFilterSettingsValue = function(dict) { | 137 ContentSettings.setContentFilterSettingsValue = function(dict) { |
| 96 for (var group in dict) { | 138 for (var group in dict) { |
| 139 var settingLabel = $(group + '-default-string'); |
| 140 if (settingLabel) { |
| 141 var value = dict[group].value; |
| 142 var valueId = |
| 143 permissionsLookup[group] + value[0].toUpperCase() + value.slice(1); |
| 144 settingLabel.textContent = loadTimeData.getString(valueId); |
| 145 } |
| 146 |
| 97 var managedBy = dict[group].managedBy; | 147 var managedBy = dict[group].managedBy; |
| 98 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? | 148 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? |
| 99 managedBy : null; | 149 managedBy : null; |
| 100 document.querySelector('input[type=radio][name=' + group + '][value=' + | 150 document.querySelector('input[type=radio][name=' + group + '][value=' + |
| 101 dict[group].value + ']').checked = true; | 151 dict[group].value + ']').checked = true; |
| 102 var radios = document.querySelectorAll('input[type=radio][name=' + | 152 var radios = document.querySelectorAll('input[type=radio][name=' + |
| 103 group + ']'); | 153 group + ']'); |
| 104 for (var i = 0, len = radios.length; i < len; i++) { | 154 for (var i = 0, len = radios.length; i < len; i++) { |
| 105 radios[i].disabled = (managedBy != 'default'); | 155 radios[i].disabled = (managedBy != 'default'); |
| 106 radios[i].controlledBy = controlledBy; | 156 radios[i].controlledBy = controlledBy; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 var deviceSelect = $('media-select-camera'); | 354 var deviceSelect = $('media-select-camera'); |
| 305 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); | 355 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); |
| 306 }; | 356 }; |
| 307 | 357 |
| 308 // Export | 358 // Export |
| 309 return { | 359 return { |
| 310 ContentSettings: ContentSettings | 360 ContentSettings: ContentSettings |
| 311 }; | 361 }; |
| 312 | 362 |
| 313 }); | 363 }); |
| OLD | NEW |