Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: chrome/browser/resources/options/content_settings.js

Issue 5699004: [tabbed options] more work on content settings exceptions lists (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use array.filter Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * Initializes an exceptions list. 87 * Initializes an exceptions list.
88 * @param {string} type The content type that we are setting exceptions for. 88 * @param {string} type The content type that we are setting exceptions for.
89 * @param {Array} list An array of pairs, where the first element of each pair 89 * @param {Array} list An array of pairs, where the first element of each pair
90 * is the filter string, and the second is the setting (allow/block). 90 * is the filter string, and the second is the setting (allow/block).
91 */ 91 */
92 ContentSettings.setExceptions = function(type, list) { 92 ContentSettings.setExceptions = function(type, list) {
93 var exceptionsList = 93 var exceptionsList =
94 document.querySelector('div[contentType=' + type + ']' + 94 document.querySelector('div[contentType=' + type + ']' +
95 ' list[mode=normal]'); 95 ' list[mode=normal]');
96 96
97 exceptionsList.clear(); 97 exceptionsList.reset();
98 for (var i = 0; i < list.length; i++) { 98 for (var i = 0; i < list.length; i++) {
99 exceptionsList.addException(list[i]); 99 exceptionsList.addException(list[i]);
100 } 100 }
101 exceptionsList.redraw(); 101 exceptionsList.redraw();
102 }; 102 };
103 103
104 ContentSettings.setOTRExceptions = function(type, list) { 104 ContentSettings.setOTRExceptions = function(type, list) {
105 var exceptionsList = 105 var exceptionsList =
106 document.querySelector('div[contentType=' + type + ']' + 106 document.querySelector('div[contentType=' + type + ']' +
107 ' div list[mode=normal]'); 107 ' div list[mode=normal]');
108 108
109 exceptionsList.parentNode.classList.remove('hidden'); 109 exceptionsList.parentNode.classList.remove('hidden');
110 110
111 exceptionsList.clear(); 111 exceptionsList.reset();
112 for (var i = 0; i < list.length; i++) { 112 for (var i = 0; i < list.length; i++) {
113 exceptionsList.addException(list[i]); 113 exceptionsList.addException(list[i]);
114 } 114 }
115 exceptionsList.redraw(); 115 exceptionsList.redraw();
116 }; 116 };
117 117
118 /** 118 /**
119 * Called when the last incognito window is closed. 119 * Called when the last incognito window is closed.
120 */ 120 */
121 ContentSettings.OTRProfileDestroyed = function() { 121 ContentSettings.OTRProfileDestroyed = function() {
122 this.hideOTRLists(); 122 this.hideOTRLists();
123 }; 123 };
124 124
125 /** 125 /**
126 * Clears and hides the incognito exceptions lists. 126 * Clears and hides the incognito exceptions lists.
127 */ 127 */
128 ContentSettings.hideOTRLists = function() { 128 ContentSettings.hideOTRLists = function() {
129 var otrLists = document.querySelectorAll('list[mode=otr]'); 129 var otrLists = document.querySelectorAll('list[mode=otr]');
130 130
131 for (var i = 0; i < otrLists.length; i++) { 131 for (var i = 0; i < otrLists.length; i++) {
132 otrLists[i].clear(); 132 otrLists[i].reset();
133 otrLists[i].parentNode.classList.add('hidden'); 133 otrLists[i].parentNode.classList.add('hidden');
134 } 134 }
135 }; 135 };
136 136
137 /** 137 /**
138 * Sets the initial value for the Third Party Cookies checkbox. 138 * Sets the initial value for the Third Party Cookies checkbox.
139 * @param {boolean=} block True if we are blocking third party cookies. 139 * @param {boolean=} block True if we are blocking third party cookies.
140 */ 140 */
141 ContentSettings.setBlockThirdPartyCookies = function(block) { 141 ContentSettings.setBlockThirdPartyCookies = function(block) {
142 $('block-third-party-cookies').checked = block; 142 $('block-third-party-cookies').checked = block;
143 }; 143 };
144 144
145 /** 145 /**
146 * The browser's response to a request to check the validity of a given URL 146 * The browser's response to a request to check the validity of a given URL
147 * pattern. 147 * pattern.
148 * @param {string} type The content type. 148 * @param {string} type The content type.
149 * @param {string} mode The browser mode. 149 * @param {string} mode The browser mode.
150 * @param {string} pattern The pattern. 150 * @param {string} pattern The pattern.
151 * @param {bool} valid Whether said pattern is valid in the context of 151 * @param {bool} valid Whether said pattern is valid in the context of
152 * a content exception setting. 152 * a content exception setting.
153 */ 153 */
154 ContentSettings.patternValidityCheckComplete = 154 ContentSettings.patternValidityCheckComplete =
155 function(type, mode, pattern, valid) { 155 function(type, mode, pattern, valid) {
156 var exceptionsList = 156 var exceptionsList =
157 document.querySelector('div[contentType=' + type + '][mode=' + mode + 157 document.querySelector('div[contentType=' + type + '] ' +
158 '] list'); 158 'list[mode=' + mode + ']');
159 exceptionsList.patternValidityCheckComplete(pattern, valid); 159 exceptionsList.patternValidityCheckComplete(pattern, valid);
160 }; 160 };
161 161
162 // Export 162 // Export
163 return { 163 return {
164 ContentSettings: ContentSettings 164 ContentSettings: ContentSettings
165 }; 165 };
166 166
167 }); 167 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698