| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 11 matching lines...) Expand all Loading... |
| 22 cr.addSingletonGetter(ContentSettings); | 22 cr.addSingletonGetter(ContentSettings); |
| 23 | 23 |
| 24 ContentSettings.prototype = { | 24 ContentSettings.prototype = { |
| 25 __proto__: OptionsPage.prototype, | 25 __proto__: OptionsPage.prototype, |
| 26 | 26 |
| 27 initializePage: function() { | 27 initializePage: function() { |
| 28 OptionsPage.prototype.initializePage.call(this); | 28 OptionsPage.prototype.initializePage.call(this); |
| 29 | 29 |
| 30 chrome.send('getContentFilterSettings'); | 30 chrome.send('getContentFilterSettings'); |
| 31 | 31 |
| 32 var exceptionsLists = this.pageDiv.querySelectorAll('list'); | 32 var exceptionsButtons = |
| 33 for (var i = 0; i < exceptionsLists.length; i++) { | 33 this.pageDiv.querySelectorAll('.exceptionsListButton'); |
| 34 options.contentSettings.ExceptionsList.decorate(exceptionsLists[i]); | 34 for (var i = 0; i < exceptionsButtons.length; i++) { |
| 35 exceptionsButtons[i].onclick = function(event) { |
| 36 ContentSettingsExceptionsArea.getInstance().showList( |
| 37 event.target.getAttribute('contentType')); |
| 38 OptionsPage.showPageByName('contentExceptions'); |
| 39 }; |
| 35 } | 40 } |
| 36 ContentSettings.hideOTRLists(); | |
| 37 | |
| 38 this.addEventListener('visibleChange', function(event) { | |
| 39 for (var i = 0; i < exceptionsLists.length; i++) { | |
| 40 exceptionsLists[i].redraw(); | |
| 41 } | |
| 42 }); | |
| 43 | 41 |
| 44 // Cookies filter page --------------------------------------------------- | 42 // Cookies filter page --------------------------------------------------- |
| 45 $('block-third-party-cookies').onclick = function(event) { | 43 $('block-third-party-cookies').onclick = function(event) { |
| 46 chrome.send('setAllowThirdPartyCookies', | 44 chrome.send('setAllowThirdPartyCookies', |
| 47 [String($('block-third-party-cookies').checked)]); | 45 [String($('block-third-party-cookies').checked)]); |
| 48 }; | 46 }; |
| 49 | 47 |
| 50 $('show-cookies-button').onclick = function(event) { | 48 $('show-cookies-button').onclick = function(event) { |
| 51 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); | 49 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); |
| 52 OptionsPage.showPageByName('cookiesView'); | 50 OptionsPage.showPageByName('cookiesView'); |
| 53 }; | 51 }; |
| 54 | 52 |
| 55 $('plugins-tab').onclick = function(event) { | 53 $('plugins-tab').onclick = function(event) { |
| 56 chrome.send('openPluginsTab'); | 54 chrome.send('openPluginsTab'); |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 if (!templateData.enable_click_to_play) | 57 if (!templateData.enable_click_to_play) |
| 60 $('click_to_play').style.display = 'none'; | 58 $('click_to_play').style.display = 'none'; |
| 61 }, | 59 }, |
| 62 | 60 |
| 63 /** | 61 /** |
| 64 * Handles a hash value in the URL (such as bar in | 62 * Handles a hash value in the URL (such as bar in |
| 65 * chrome://options/foo#bar). Overrides the default action of showing an | 63 * chrome://options/foo#bar). |
| 66 * overlay by instead navigating to a particular subtab. | |
| 67 * @param {string} hash The hash value. | 64 * @param {string} hash The hash value. |
| 68 */ | 65 */ |
| 69 handleHash: function(hash) { | 66 handleHash: function(hash) { |
| 70 // TODO(estade): show subpage for hash. | 67 ContentSettingsExceptionsArea.getInstance().showList(hash); |
| 68 OptionsPage.showPageByName('contentExceptions'); |
| 71 }, | 69 }, |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 /** | 72 /** |
| 75 * Sets the values for all the content settings radios. | 73 * Sets the values for all the content settings radios. |
| 76 * @param {Object} dict A mapping from radio groups to the checked value for | 74 * @param {Object} dict A mapping from radio groups to the checked value for |
| 77 * that group. | 75 * that group. |
| 78 */ | 76 */ |
| 79 ContentSettings.setContentFilterSettingsValue = function(dict) { | 77 ContentSettings.setContentFilterSettingsValue = function(dict) { |
| 80 for (var group in dict) { | 78 for (var group in dict) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 102 exceptionsList.reset(); | 100 exceptionsList.reset(); |
| 103 for (var i = 0; i < list.length; i++) { | 101 for (var i = 0; i < list.length; i++) { |
| 104 exceptionsList.addException(list[i]); | 102 exceptionsList.addException(list[i]); |
| 105 } | 103 } |
| 106 exceptionsList.redraw(); | 104 exceptionsList.redraw(); |
| 107 }; | 105 }; |
| 108 | 106 |
| 109 ContentSettings.setOTRExceptions = function(type, list) { | 107 ContentSettings.setOTRExceptions = function(type, list) { |
| 110 var exceptionsList = | 108 var exceptionsList = |
| 111 document.querySelector('div[contentType=' + type + ']' + | 109 document.querySelector('div[contentType=' + type + ']' + |
| 112 ' div list[mode=normal]'); | 110 ' list[mode=otr]'); |
| 113 | 111 |
| 114 exceptionsList.parentNode.classList.remove('hidden'); | 112 exceptionsList.parentNode.classList.remove('hidden'); |
| 115 | 113 |
| 116 exceptionsList.reset(); | 114 exceptionsList.reset(); |
| 117 for (var i = 0; i < list.length; i++) { | 115 for (var i = 0; i < list.length; i++) { |
| 118 exceptionsList.addException(list[i]); | 116 exceptionsList.addException(list[i]); |
| 119 } | 117 } |
| 120 exceptionsList.redraw(); | 118 exceptionsList.redraw(); |
| 121 }; | 119 }; |
| 122 | 120 |
| 123 /** | 121 /** |
| 124 * Called when the last incognito window is closed. | |
| 125 */ | |
| 126 ContentSettings.OTRProfileDestroyed = function() { | |
| 127 this.hideOTRLists(); | |
| 128 }; | |
| 129 | |
| 130 /** | |
| 131 * Clears and hides the incognito exceptions lists. | |
| 132 */ | |
| 133 ContentSettings.hideOTRLists = function() { | |
| 134 var otrLists = document.querySelectorAll('list[mode=otr]'); | |
| 135 | |
| 136 for (var i = 0; i < otrLists.length; i++) { | |
| 137 otrLists[i].reset(); | |
| 138 otrLists[i].parentNode.classList.add('hidden'); | |
| 139 } | |
| 140 }; | |
| 141 | |
| 142 /** | |
| 143 * Sets the initial value for the Third Party Cookies checkbox. | 122 * Sets the initial value for the Third Party Cookies checkbox. |
| 144 * @param {boolean=} block True if we are blocking third party cookies. | 123 * @param {boolean=} block True if we are blocking third party cookies. |
| 145 */ | 124 */ |
| 146 ContentSettings.setBlockThirdPartyCookies = function(block) { | 125 ContentSettings.setBlockThirdPartyCookies = function(block) { |
| 147 $('block-third-party-cookies').checked = block; | 126 $('block-third-party-cookies').checked = block; |
| 148 }; | 127 }; |
| 149 | 128 |
| 150 /** | 129 /** |
| 151 * The browser's response to a request to check the validity of a given URL | 130 * The browser's response to a request to check the validity of a given URL |
| 152 * pattern. | 131 * pattern. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 163 'list[mode=' + mode + ']'); | 142 'list[mode=' + mode + ']'); |
| 164 exceptionsList.patternValidityCheckComplete(pattern, valid); | 143 exceptionsList.patternValidityCheckComplete(pattern, valid); |
| 165 }; | 144 }; |
| 166 | 145 |
| 167 // Export | 146 // Export |
| 168 return { | 147 return { |
| 169 ContentSettings: ContentSettings | 148 ContentSettings: ContentSettings |
| 170 }; | 149 }; |
| 171 | 150 |
| 172 }); | 151 }); |
| OLD | NEW |