| 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 return false; | 55 return false; |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 if (!templateData.enable_click_to_play) | 58 if (!templateData.enable_click_to_play) |
| 61 $('click_to_play').style.display = 'none'; | 59 $('click_to_play').style.display = 'none'; |
| 62 }, | 60 }, |
| 63 | 61 |
| 64 /** | 62 /** |
| 65 * Handles a hash value in the URL (such as bar in | 63 * Handles a hash value in the URL (such as bar in |
| 66 * chrome://options/foo#bar). Overrides the default action of showing an | 64 * chrome://options/foo#bar). |
| 67 * overlay by instead navigating to a particular subtab. | |
| 68 * @param {string} hash The hash value. | 65 * @param {string} hash The hash value. |
| 69 */ | 66 */ |
| 70 handleHash: function(hash) { | 67 handleHash: function(hash) { |
| 71 // TODO(estade): show subpage for hash. | 68 ContentSettingsExceptionsArea.getInstance().showList(hash); |
| 69 OptionsPage.showPageByName('contentExceptions'); |
| 72 }, | 70 }, |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 /** | 73 /** |
| 76 * Sets the values for all the content settings radios. | 74 * Sets the values for all the content settings radios. |
| 77 * @param {Object} dict A mapping from radio groups to the checked value for | 75 * @param {Object} dict A mapping from radio groups to the checked value for |
| 78 * that group. | 76 * that group. |
| 79 */ | 77 */ |
| 80 ContentSettings.setContentFilterSettingsValue = function(dict) { | 78 ContentSettings.setContentFilterSettingsValue = function(dict) { |
| 81 for (var group in dict) { | 79 for (var group in dict) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 103 exceptionsList.reset(); | 101 exceptionsList.reset(); |
| 104 for (var i = 0; i < list.length; i++) { | 102 for (var i = 0; i < list.length; i++) { |
| 105 exceptionsList.addException(list[i]); | 103 exceptionsList.addException(list[i]); |
| 106 } | 104 } |
| 107 exceptionsList.redraw(); | 105 exceptionsList.redraw(); |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 ContentSettings.setOTRExceptions = function(type, list) { | 108 ContentSettings.setOTRExceptions = function(type, list) { |
| 111 var exceptionsList = | 109 var exceptionsList = |
| 112 document.querySelector('div[contentType=' + type + ']' + | 110 document.querySelector('div[contentType=' + type + ']' + |
| 113 ' div list[mode=normal]'); | 111 ' list[mode=otr]'); |
| 114 | 112 |
| 115 exceptionsList.parentNode.classList.remove('hidden'); | 113 exceptionsList.parentNode.classList.remove('hidden'); |
| 116 | 114 |
| 117 exceptionsList.reset(); | 115 exceptionsList.reset(); |
| 118 for (var i = 0; i < list.length; i++) { | 116 for (var i = 0; i < list.length; i++) { |
| 119 exceptionsList.addException(list[i]); | 117 exceptionsList.addException(list[i]); |
| 120 } | 118 } |
| 121 exceptionsList.redraw(); | 119 exceptionsList.redraw(); |
| 122 }; | 120 }; |
| 123 | 121 |
| 124 /** | 122 /** |
| 125 * Called when the last incognito window is closed. | |
| 126 */ | |
| 127 ContentSettings.OTRProfileDestroyed = function() { | |
| 128 this.hideOTRLists(); | |
| 129 }; | |
| 130 | |
| 131 /** | |
| 132 * Clears and hides the incognito exceptions lists. | |
| 133 */ | |
| 134 ContentSettings.hideOTRLists = function() { | |
| 135 var otrLists = document.querySelectorAll('list[mode=otr]'); | |
| 136 | |
| 137 for (var i = 0; i < otrLists.length; i++) { | |
| 138 otrLists[i].reset(); | |
| 139 otrLists[i].parentNode.classList.add('hidden'); | |
| 140 } | |
| 141 }; | |
| 142 | |
| 143 /** | |
| 144 * Sets the initial value for the Third Party Cookies checkbox. | 123 * Sets the initial value for the Third Party Cookies checkbox. |
| 145 * @param {boolean=} block True if we are blocking third party cookies. | 124 * @param {boolean=} block True if we are blocking third party cookies. |
| 146 */ | 125 */ |
| 147 ContentSettings.setBlockThirdPartyCookies = function(block) { | 126 ContentSettings.setBlockThirdPartyCookies = function(block) { |
| 148 $('block-third-party-cookies').checked = block; | 127 $('block-third-party-cookies').checked = block; |
| 149 }; | 128 }; |
| 150 | 129 |
| 151 /** | 130 /** |
| 152 * The browser's response to a request to check the validity of a given URL | 131 * The browser's response to a request to check the validity of a given URL |
| 153 * pattern. | 132 * pattern. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 164 'list[mode=' + mode + ']'); | 143 'list[mode=' + mode + ']'); |
| 165 exceptionsList.patternValidityCheckComplete(pattern, valid); | 144 exceptionsList.patternValidityCheckComplete(pattern, valid); |
| 166 }; | 145 }; |
| 167 | 146 |
| 168 // Export | 147 // Export |
| 169 return { | 148 return { |
| 170 ContentSettings: ContentSettings | 149 ContentSettings: ContentSettings |
| 171 }; | 150 }; |
| 172 | 151 |
| 173 }); | 152 }); |
| OLD | NEW |