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) { | |
71 var selector = '#handlers-section input[type=radio][value=' + | |
72 (enabled ? 'allow' : 'block') + ']'; | |
73 document.querySelector(selector).checked = true; | |
tony
2011/05/23 21:42:00
Nit: indent is off
koz (OOO until 15th September)
2011/05/24 08:47:49
Done.
| |
74 }; | |
75 | |
64 /** | 76 /** |
65 * Sets the values for all the content settings radios. | 77 * Sets the values for all the content settings radios. |
66 * @param {Object} dict A mapping from radio groups to the checked value for | 78 * @param {Object} dict A mapping from radio groups to the checked value for |
67 * that group. | 79 * that group. |
68 */ | 80 */ |
69 ContentSettings.setContentFilterSettingsValue = function(dict) { | 81 ContentSettings.setContentFilterSettingsValue = function(dict) { |
70 for (var group in dict) { | 82 for (var group in dict) { |
71 document.querySelector('input[type=radio][name=' + group + '][value=' + | 83 document.querySelector('input[type=radio][name=' + group + '][value=' + |
72 dict[group]['value'] + ']').checked = true; | 84 dict[group]['value'] + ']').checked = true; |
73 var radios = document.querySelectorAll('input[type=radio][name=' + | 85 var radios = document.querySelectorAll('input[type=radio][name=' + |
74 group + ']'); | 86 group + ']'); |
75 for (var i = 0, len = radios.length; i < len; i++) { | 87 for (var i = 0, len = radios.length; i < len; i++) { |
76 radios[i].disabled = dict[group]['managed']; | 88 radios[i].disabled = dict[group]['managed']; |
77 radios[i].managed = dict[group]['managed']; | 89 radios[i].managed = dict[group]['managed']; |
78 } | 90 } |
79 } | 91 } |
80 OptionsPage.updateManagedBannerVisibility(); | 92 OptionsPage.updateManagedBannerVisibility(); |
81 }; | 93 }; |
82 | 94 |
83 /** | 95 /** |
84 * Initializes an exceptions list. | 96 * Initializes an exceptions list. |
85 * @param {string} type The content type that we are setting exceptions for. | 97 * @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 | 98 * @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). | 99 * is the filter string, and the second is the setting (allow/block). |
88 */ | 100 */ |
89 ContentSettings.setExceptions = function(type, list) { | 101 ContentSettings.setExceptions = function(type, list) { |
90 var exceptionsList = | 102 var exceptionsList = |
91 document.querySelector('div[contentType=' + type + ']' + | 103 document.querySelector('div[contentType=' + type + ']' + |
92 ' list[mode=normal]'); | 104 ' list[mode=normal]'); |
105 exceptionsList.setExceptions(list); | |
106 }; | |
93 | 107 |
94 exceptionsList.setExceptions(list); | 108 ContentSettings.setHandlers = function(list) { |
109 $('handlers-list').setHandlers(list); | |
95 }; | 110 }; |
96 | 111 |
97 ContentSettings.setOTRExceptions = function(type, list) { | 112 ContentSettings.setOTRExceptions = function(type, list) { |
98 var exceptionsList = | 113 var exceptionsList = |
99 document.querySelector('div[contentType=' + type + ']' + | 114 document.querySelector('div[contentType=' + type + ']' + |
100 ' list[mode=otr]'); | 115 ' list[mode=otr]'); |
101 | 116 |
102 exceptionsList.parentNode.classList.remove('hidden'); | 117 exceptionsList.parentNode.classList.remove('hidden'); |
103 exceptionsList.setExceptions(list); | 118 exceptionsList.setExceptions(list); |
104 }; | 119 }; |
(...skipping 22 matching lines...) Expand all Loading... | |
127 'list[mode=' + mode + ']'); | 142 'list[mode=' + mode + ']'); |
128 exceptionsList.patternValidityCheckComplete(pattern, valid); | 143 exceptionsList.patternValidityCheckComplete(pattern, valid); |
129 }; | 144 }; |
130 | 145 |
131 // Export | 146 // Export |
132 return { | 147 return { |
133 ContentSettings: ContentSettings | 148 ContentSettings: ContentSettings |
134 }; | 149 }; |
135 | 150 |
136 }); | 151 }); |
OLD | NEW |