OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.ContentSettings', function() { | 5 cr.define('options.ContentSettings', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 // Lookup table to generate the i18n strings. | 10 // Lookup table to generate the i18n strings. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 initializePage: function() { | 59 initializePage: function() { |
60 Page.prototype.initializePage.call(this); | 60 Page.prototype.initializePage.call(this); |
61 | 61 |
62 $('website-settings-overlay-confirm').onclick = | 62 $('website-settings-overlay-confirm').onclick = |
63 PageManager.closeOverlay.bind(PageManager); | 63 PageManager.closeOverlay.bind(PageManager); |
64 | 64 |
65 $('global-setting').onchange = function(event) { | 65 $('global-setting').onchange = function(event) { |
66 chrome.send('setDefaultContentSetting', [this.value]); | 66 chrome.send('setDefaultContentSetting', [this.value]); |
67 }; | 67 }; |
68 | 68 |
| 69 $('global-setting-toggle').onchange = function(event) { |
| 70 var value = event.target.checked; |
| 71 chrome.send('setGlobalEnabled', [value]); |
| 72 }; |
| 73 |
69 var searchBox = $('website-settings-search-box'); | 74 var searchBox = $('website-settings-search-box'); |
70 searchBox.addEventListener('search', | 75 searchBox.addEventListener('search', |
71 this.handleSearchQueryChange_.bind(this)); | 76 this.handleSearchQueryChange_.bind(this)); |
72 | 77 |
73 searchBox.onkeydown = function(e) { | 78 searchBox.onkeydown = function(e) { |
74 if (e.keyIdentifier == 'Enter') | 79 if (e.keyIdentifier == 'Enter') |
75 e.preventDefault(); | 80 e.preventDefault(); |
76 }; | 81 }; |
77 | 82 |
78 this.createOriginsList_(); | 83 this.createOriginsList_(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 142 |
138 /** | 143 /** |
139 * Populate the origin lists with all of the origins with a given permission | 144 * Populate the origin lists with all of the origins with a given permission |
140 * or that are using a given resource, potentially split by if allowed or | 145 * or that are using a given resource, potentially split by if allowed or |
141 * denied. If no blocked dictionary is provided, only the allowed list is | 146 * denied. If no blocked dictionary is provided, only the allowed list is |
142 * shown. | 147 * shown. |
143 * @param {!Object} allowedDict A dictionary of origins to their usage, | 148 * @param {!Object} allowedDict A dictionary of origins to their usage, |
144 which will be used to sort the origins in the main/allowed list. | 149 which will be used to sort the origins in the main/allowed list. |
145 * @param {!Object} blockedDict An optional dictionary of origins to their | 150 * @param {!Object} blockedDict An optional dictionary of origins to their |
146 usage, which will be used to sort the origins in the blocked list. | 151 usage, which will be used to sort the origins in the blocked list. |
| 152 * @param {bool} isGloballyEnabled If the content setting is turned on. |
147 * @private | 153 * @private |
148 */ | 154 */ |
149 populateOrigins: function(allowedDict, blockedDict) { | 155 populateOrigins: function(allowedDict, blockedDict, isGloballyEnabled) { |
150 this.populateOriginsHelper_(this.allowedList_, allowedDict); | 156 this.populateOriginsHelper_(this.allowedList_, allowedDict); |
151 if (blockedDict) { | 157 if (blockedDict) { |
152 this.populateOriginsHelper_(this.blockedList_, blockedDict); | 158 this.populateOriginsHelper_(this.blockedList_, blockedDict); |
153 this.blockedList_.hidden = false; | 159 this.blockedList_.hidden = false; |
154 $('blocked-origin-list-title').hidden = false; | 160 $('blocked-origin-list-title').hidden = false; |
155 this.allowedList_.classList.remove('nonsplit-origin-list'); | 161 this.allowedList_.classList.remove('nonsplit-origin-list'); |
156 } else { | 162 } else { |
157 this.blockedList_.hidden = true; | 163 this.blockedList_.hidden = true; |
158 $('blocked-origin-list-title').hidden = true; | 164 $('blocked-origin-list-title').hidden = true; |
159 $('allowed-origin-list-title').hidden = true; | 165 $('allowed-origin-list-title').hidden = true; |
160 this.allowedList_.classList.add('nonsplit-origin-list'); | 166 this.allowedList_.classList.add('nonsplit-origin-list'); |
161 } | 167 } |
| 168 $('global-setting-toggle').checked = isGloballyEnabled; |
162 }, | 169 }, |
163 | 170 |
164 /** | 171 /** |
165 * Update the table with the origins filtered by the value in the search | 172 * Update the table with the origins filtered by the value in the search |
166 * box. | 173 * box. |
167 * @private | 174 * @private |
168 */ | 175 */ |
169 searchOrigins: function() { | 176 searchOrigins: function() { |
170 var filter = $('website-settings-search-box').value; | 177 var filter = $('website-settings-search-box').value; |
171 chrome.send('updateOriginsSearchResults', [filter]); | 178 chrome.send('updateOriginsSearchResults', [filter]); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } else { | 242 } else { |
236 $('website-settings-global-controls').hidden = false; | 243 $('website-settings-global-controls').hidden = false; |
237 chrome.send('updateDefaultSetting'); | 244 chrome.send('updateDefaultSetting'); |
238 } | 245 } |
239 | 246 |
240 $('website-settings-title').textContent = | 247 $('website-settings-title').textContent = |
241 loadTimeData.getString(permissionString + 'TabLabel'); | 248 loadTimeData.getString(permissionString + 'TabLabel'); |
242 } | 249 } |
243 }; | 250 }; |
244 | 251 |
245 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { | 252 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict, |
| 253 isGloballyEnabled) { |
246 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, | 254 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, |
247 blockedDict); | 255 blockedDict, isGloballyEnabled); |
248 }; | 256 }; |
249 | 257 |
250 WebsiteSettingsManager.updateDefault = function(dict) { | 258 WebsiteSettingsManager.updateDefault = function(dict) { |
251 WebsiteSettingsManager.getInstance().updateDefault(dict); | 259 WebsiteSettingsManager.getInstance().updateDefault(dict); |
252 }; | 260 }; |
253 | 261 |
254 WebsiteSettingsManager.showWebsiteSettings = function(hash) { | 262 WebsiteSettingsManager.showWebsiteSettings = function(hash) { |
255 PageManager.showPageByName('websiteSettings', true, {hash: '#' + hash}); | 263 PageManager.showPageByName('websiteSettings', true, {hash: '#' + hash}); |
256 }; | 264 }; |
257 | 265 |
258 // Export | 266 // Export |
259 return { | 267 return { |
260 WebsiteSettingsManager: WebsiteSettingsManager | 268 WebsiteSettingsManager: WebsiteSettingsManager |
261 }; | 269 }; |
262 }); | 270 }); |
OLD | NEW |