Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
| 8 | 8 |
| 9 ////////////////////////////////////////////////////////////////////////////// | 9 ////////////////////////////////////////////////////////////////////////////// |
| 10 // ContentSettings class: | 10 // ContentSettings class: |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 event.target.getAttribute('contentType')); | 38 event.target.getAttribute('contentType')); |
| 39 OptionsPage.navigateToPage('contentExceptions'); | 39 OptionsPage.navigateToPage('contentExceptions'); |
| 40 // Add on the proper hash for the content type, and store that in the | 40 // Add on the proper hash for the content type, and store that in the |
| 41 // history so back/forward and tab restore works. | 41 // history so back/forward and tab restore works. |
| 42 var hash = event.target.getAttribute('contentType'); | 42 var hash = event.target.getAttribute('contentType'); |
| 43 window.history.replaceState({pageName: page.name}, page.title, | 43 window.history.replaceState({pageName: page.name}, page.title, |
| 44 '/' + page.name + "#" + hash); | 44 '/' + page.name + "#" + hash); |
| 45 }; | 45 }; |
| 46 } | 46 } |
| 47 | 47 |
| 48 var manageHandlersButton = | |
| 49 this.pageDiv.querySelector('#manage-handlers-button'); | |
| 50 manageHandlersButton.onclick = function(event) { | |
| 51 OptionsPage.navigateToPage('handlers'); | |
| 52 }; | |
| 53 | |
| 48 // Cookies filter page --------------------------------------------------- | 54 // Cookies filter page --------------------------------------------------- |
| 49 $('block-third-party-cookies').onclick = function(event) { | 55 $('block-third-party-cookies').onclick = function(event) { |
| 50 chrome.send('setAllowThirdPartyCookies', | 56 chrome.send('setAllowThirdPartyCookies', |
| 51 [String($('block-third-party-cookies').checked)]); | 57 [String($('block-third-party-cookies').checked)]); |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 $('show-cookies-button').onclick = function(event) { | 60 $('show-cookies-button').onclick = function(event) { |
| 55 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); | 61 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); |
| 56 OptionsPage.navigateToPage('cookies'); | 62 OptionsPage.navigateToPage('cookies'); |
| 57 }; | 63 }; |
| 58 | 64 |
| 59 if (!templateData.enable_click_to_play) | 65 if (!templateData.enable_click_to_play) |
| 60 $('click_to_play').style.display = 'none'; | 66 $('click_to_play').style.display = 'none'; |
| 61 }, | 67 }, |
| 62 }; | 68 }; |
| 63 | 69 |
| 70 ContentSettings.updateHandlersEnabledRadios = function(enabled) { | |
|
Evan Stade
2011/05/20 22:01:28
var selector = '#handlers-section input[type=radio
koz (OOO until 15th September)
2011/05/20 22:19:56
Done.
| |
| 71 var allow = '#handlers-section input[type=radio][value=allow]'; | |
| 72 var block = '#handlers-section input[type=radio][value=block]'; | |
| 73 if (enabled) | |
| 74 document.querySelector(allow).checked = true; | |
| 75 else | |
| 76 document.querySelector(block).checked = true; | |
| 77 }; | |
| 78 | |
| 64 /** | 79 /** |
| 65 * Sets the values for all the content settings radios. | 80 * Sets the values for all the content settings radios. |
| 66 * @param {Object} dict A mapping from radio groups to the checked value for | 81 * @param {Object} dict A mapping from radio groups to the checked value for |
| 67 * that group. | 82 * that group. |
| 68 */ | 83 */ |
| 69 ContentSettings.setContentFilterSettingsValue = function(dict) { | 84 ContentSettings.setContentFilterSettingsValue = function(dict) { |
| 70 for (var group in dict) { | 85 for (var group in dict) { |
| 71 document.querySelector('input[type=radio][name=' + group + '][value=' + | 86 document.querySelector('input[type=radio][name=' + group + '][value=' + |
| 72 dict[group]['value'] + ']').checked = true; | 87 dict[group]['value'] + ']').checked = true; |
| 73 var radios = document.querySelectorAll('input[type=radio][name=' + | 88 var radios = document.querySelectorAll('input[type=radio][name=' + |
| 74 group + ']'); | 89 group + ']'); |
| 75 for (var i = 0, len = radios.length; i < len; i++) { | 90 for (var i = 0, len = radios.length; i < len; i++) { |
| 76 radios[i].disabled = dict[group]['managed']; | 91 radios[i].disabled = dict[group]['managed']; |
| 77 radios[i].managed = dict[group]['managed']; | 92 radios[i].managed = dict[group]['managed']; |
| 78 } | 93 } |
| 79 } | 94 } |
| 80 OptionsPage.updateManagedBannerVisibility(); | 95 OptionsPage.updateManagedBannerVisibility(); |
| 81 }; | 96 }; |
| 82 | 97 |
| 83 /** | 98 /** |
| 84 * Initializes an exceptions list. | 99 * Initializes an exceptions list. |
| 85 * @param {string} type The content type that we are setting exceptions for. | 100 * @param {string} type The content type that we are setting exceptions for. |
| 86 * @param {Array} list An array of pairs, where the first element of each pair | 101 * @param {Array} list An array of pairs, where the first element of each pair |
| 87 * is the filter string, and the second is the setting (allow/block). | 102 * is the filter string, and the second is the setting (allow/block). |
| 88 */ | 103 */ |
| 89 ContentSettings.setExceptions = function(type, list) { | 104 ContentSettings.setExceptions = function(type, list) { |
| 90 var exceptionsList = | 105 var exceptionsList = |
| 91 document.querySelector('div[contentType=' + type + ']' + | 106 document.querySelector('div[contentType=' + type + ']' + |
| 92 ' list[mode=normal]'); | 107 ' list[mode=normal]'); |
| 108 exceptionsList.setExceptions(list); | |
| 109 }; | |
| 93 | 110 |
| 94 exceptionsList.setExceptions(list); | 111 ContentSettings.setHandlers = function(list) { |
| 112 $('handlers-list').setHandlers(list); | |
| 95 }; | 113 }; |
| 96 | 114 |
| 97 ContentSettings.setOTRExceptions = function(type, list) { | 115 ContentSettings.setOTRExceptions = function(type, list) { |
| 98 var exceptionsList = | 116 var exceptionsList = |
| 99 document.querySelector('div[contentType=' + type + ']' + | 117 document.querySelector('div[contentType=' + type + ']' + |
| 100 ' list[mode=otr]'); | 118 ' list[mode=otr]'); |
| 101 | 119 |
| 102 exceptionsList.parentNode.classList.remove('hidden'); | 120 exceptionsList.parentNode.classList.remove('hidden'); |
| 103 exceptionsList.setExceptions(list); | 121 exceptionsList.setExceptions(list); |
| 104 }; | 122 }; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 127 'list[mode=' + mode + ']'); | 145 'list[mode=' + mode + ']'); |
| 128 exceptionsList.patternValidityCheckComplete(pattern, valid); | 146 exceptionsList.patternValidityCheckComplete(pattern, valid); |
| 129 }; | 147 }; |
| 130 | 148 |
| 131 // Export | 149 // Export |
| 132 return { | 150 return { |
| 133 ContentSettings: ContentSettings | 151 ContentSettings: ContentSettings |
| 134 }; | 152 }; |
| 135 | 153 |
| 136 }); | 154 }); |
| OLD | NEW |