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 if (manageHandlersButton) { |
| 51 manageHandlersButton.onclick = function(event) { |
| 52 OptionsPage.navigateToPage('handlers'); |
| 53 }; |
| 54 } |
| 55 |
48 // Cookies filter page --------------------------------------------------- | 56 // Cookies filter page --------------------------------------------------- |
49 $('block-third-party-cookies').onclick = function(event) { | 57 $('block-third-party-cookies').onclick = function(event) { |
50 chrome.send('setAllowThirdPartyCookies', | 58 chrome.send('setAllowThirdPartyCookies', |
51 [String($('block-third-party-cookies').checked)]); | 59 [String($('block-third-party-cookies').checked)]); |
52 }; | 60 }; |
53 | 61 |
54 $('show-cookies-button').onclick = function(event) { | 62 $('show-cookies-button').onclick = function(event) { |
55 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); | 63 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); |
56 OptionsPage.navigateToPage('cookies'); | 64 OptionsPage.navigateToPage('cookies'); |
57 }; | 65 }; |
58 | 66 |
59 if (!templateData.enable_click_to_play) | 67 if (!templateData.enable_click_to_play) |
60 $('click_to_play').style.display = 'none'; | 68 $('click_to_play').style.display = 'none'; |
61 }, | 69 }, |
62 }; | 70 }; |
63 | 71 |
| 72 ContentSettings.updateHandlersEnabledRadios = function(enabled) { |
| 73 var selector = '#handlers-section input[type=radio][value=' + |
| 74 (enabled ? 'allow' : 'block') + ']'; |
| 75 document.querySelector(selector).checked = true; |
| 76 }; |
| 77 |
64 /** | 78 /** |
65 * Sets the values for all the content settings radios. | 79 * Sets the values for all the content settings radios. |
66 * @param {Object} dict A mapping from radio groups to the checked value for | 80 * @param {Object} dict A mapping from radio groups to the checked value for |
67 * that group. | 81 * that group. |
68 */ | 82 */ |
69 ContentSettings.setContentFilterSettingsValue = function(dict) { | 83 ContentSettings.setContentFilterSettingsValue = function(dict) { |
70 for (var group in dict) { | 84 for (var group in dict) { |
71 document.querySelector('input[type=radio][name=' + group + '][value=' + | 85 document.querySelector('input[type=radio][name=' + group + '][value=' + |
72 dict[group]['value'] + ']').checked = true; | 86 dict[group]['value'] + ']').checked = true; |
73 var radios = document.querySelectorAll('input[type=radio][name=' + | 87 var radios = document.querySelectorAll('input[type=radio][name=' + |
74 group + ']'); | 88 group + ']'); |
75 for (var i = 0, len = radios.length; i < len; i++) { | 89 for (var i = 0, len = radios.length; i < len; i++) { |
76 radios[i].disabled = dict[group]['managed']; | 90 radios[i].disabled = dict[group]['managed']; |
77 radios[i].managed = dict[group]['managed']; | 91 radios[i].managed = dict[group]['managed']; |
78 } | 92 } |
79 } | 93 } |
80 OptionsPage.updateManagedBannerVisibility(); | 94 OptionsPage.updateManagedBannerVisibility(); |
81 }; | 95 }; |
82 | 96 |
83 /** | 97 /** |
84 * Initializes an exceptions list. | 98 * Initializes an exceptions list. |
85 * @param {string} type The content type that we are setting exceptions for. | 99 * @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 | 100 * @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). | 101 * is the filter string, and the second is the setting (allow/block). |
88 */ | 102 */ |
89 ContentSettings.setExceptions = function(type, list) { | 103 ContentSettings.setExceptions = function(type, list) { |
90 var exceptionsList = | 104 var exceptionsList = |
91 document.querySelector('div[contentType=' + type + ']' + | 105 document.querySelector('div[contentType=' + type + ']' + |
92 ' list[mode=normal]'); | 106 ' list[mode=normal]'); |
| 107 exceptionsList.setExceptions(list); |
| 108 }; |
93 | 109 |
94 exceptionsList.setExceptions(list); | 110 ContentSettings.setHandlers = function(list) { |
| 111 $('handlers-list').setHandlers(list); |
95 }; | 112 }; |
96 | 113 |
97 ContentSettings.setOTRExceptions = function(type, list) { | 114 ContentSettings.setOTRExceptions = function(type, list) { |
98 var exceptionsList = | 115 var exceptionsList = |
99 document.querySelector('div[contentType=' + type + ']' + | 116 document.querySelector('div[contentType=' + type + ']' + |
100 ' list[mode=otr]'); | 117 ' list[mode=otr]'); |
101 | 118 |
102 exceptionsList.parentNode.hidden = false; | 119 exceptionsList.parentNode.hidden = false; |
103 exceptionsList.setExceptions(list); | 120 exceptionsList.setExceptions(list); |
104 }; | 121 }; |
(...skipping 22 matching lines...) Expand all Loading... |
127 'list[mode=' + mode + ']'); | 144 'list[mode=' + mode + ']'); |
128 exceptionsList.patternValidityCheckComplete(pattern, valid); | 145 exceptionsList.patternValidityCheckComplete(pattern, valid); |
129 }; | 146 }; |
130 | 147 |
131 // Export | 148 // Export |
132 return { | 149 return { |
133 ContentSettings: ContentSettings | 150 ContentSettings: ContentSettings |
134 }; | 151 }; |
135 | 152 |
136 }); | 153 }); |
OLD | NEW |