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', function() { | 5 cr.define('options', 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 $('resourceType').onchange = function(event) { | 62 $('resourceType').onchange = function(event) { |
63 var target = event.target; | 63 var target = event.target; |
64 assert(target.tagName == 'SELECT'); | 64 assert(target.tagName == 'SELECT'); |
65 WebsiteSettingsManager.getInstance().updatePage_(target.value); | 65 WebsiteSettingsManager.getInstance().updatePage_(target.value); |
66 }; | 66 }; |
67 | 67 |
68 $('global-setting').onchange = function(event) { | 68 $('global-setting').onchange = function(event) { |
69 chrome.send('setDefaultContentSetting', [this.value]); | 69 chrome.send('setDefaultContentSetting', [this.value]); |
70 }; | 70 }; |
71 | 71 |
| 72 $('global-setting-toggle').onchange = function(event) { |
| 73 var value = event.target.checked; |
| 74 chrome.send('setGlobalEnabled', [value]); |
| 75 }; |
| 76 |
72 var searchBox = $('website-settings-search-box'); | 77 var searchBox = $('website-settings-search-box'); |
73 searchBox.addEventListener('search', | 78 searchBox.addEventListener('search', |
74 this.handleSearchQueryChange_.bind(this)); | 79 this.handleSearchQueryChange_.bind(this)); |
75 | 80 |
76 searchBox.onkeydown = function(e) { | 81 searchBox.onkeydown = function(e) { |
77 if (e.keyIdentifier == 'Enter') | 82 if (e.keyIdentifier == 'Enter') |
78 e.preventDefault(); | 83 e.preventDefault(); |
79 }; | 84 }; |
80 | 85 |
81 this.createOriginsList_(); | 86 this.createOriginsList_(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 145 |
141 /** | 146 /** |
142 * Populate the origin lists with all of the origins with a given permission | 147 * Populate the origin lists with all of the origins with a given permission |
143 * or that are using a given resource, potentially split by if allowed or | 148 * or that are using a given resource, potentially split by if allowed or |
144 * denied. If no blocked dictionary is provided, only the allowed list is | 149 * denied. If no blocked dictionary is provided, only the allowed list is |
145 * shown. | 150 * shown. |
146 * @param {!Object} allowedDict A dictionary of origins to their usage, | 151 * @param {!Object} allowedDict A dictionary of origins to their usage, |
147 which will be used to sort the origins in the main/allowed list. | 152 which will be used to sort the origins in the main/allowed list. |
148 * @param {!Object} blockedDict An optional dictionary of origins to their | 153 * @param {!Object} blockedDict An optional dictionary of origins to their |
149 usage, which will be used to sort the origins in the blocked list. | 154 usage, which will be used to sort the origins in the blocked list. |
| 155 * @param {bool} isGloballyEnabled If the content setting is turned on. |
150 * @private | 156 * @private |
151 */ | 157 */ |
152 populateOrigins: function(allowedDict, blockedDict) { | 158 populateOrigins: function(allowedDict, blockedDict, isGloballyEnabled) { |
153 this.populateOriginsHelper_(this.allowedList_, allowedDict); | 159 this.populateOriginsHelper_(this.allowedList_, allowedDict); |
154 if (blockedDict) { | 160 if (blockedDict) { |
155 this.populateOriginsHelper_(this.blockedList_, blockedDict); | 161 this.populateOriginsHelper_(this.blockedList_, blockedDict); |
156 this.blockedList_.hidden = false; | 162 this.blockedList_.hidden = false; |
157 $('blocked-origin-list-title').hidden = false; | 163 $('blocked-origin-list-title').hidden = false; |
158 this.allowedList_.classList.remove('nonsplit-origin-list'); | 164 this.allowedList_.classList.remove('nonsplit-origin-list'); |
159 } else { | 165 } else { |
160 this.blockedList_.hidden = true; | 166 this.blockedList_.hidden = true; |
161 $('blocked-origin-list-title').hidden = true; | 167 $('blocked-origin-list-title').hidden = true; |
162 this.allowedList_.classList.add('nonsplit-origin-list'); | 168 this.allowedList_.classList.add('nonsplit-origin-list'); |
163 } | 169 } |
| 170 $('global-setting-toggle').checked = isGloballyEnabled; |
164 }, | 171 }, |
165 | 172 |
166 /** | 173 /** |
167 * Update the table with the origins filtered by the value in the search | 174 * Update the table with the origins filtered by the value in the search |
168 * box. | 175 * box. |
169 * @private | 176 * @private |
170 */ | 177 */ |
171 searchOrigins: function() { | 178 searchOrigins: function() { |
172 var filter = $('website-settings-search-box').value; | 179 var filter = $('website-settings-search-box').value; |
173 chrome.send('updateOriginsSearchResults', [filter]); | 180 chrome.send('updateOriginsSearchResults', [filter]); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 241 } |
235 if (options.length == 0) { | 242 if (options.length == 0) { |
236 $('website-settings-global-controls').hidden = true; | 243 $('website-settings-global-controls').hidden = true; |
237 } else { | 244 } else { |
238 $('website-settings-global-controls').hidden = false; | 245 $('website-settings-global-controls').hidden = false; |
239 chrome.send('updateDefaultSetting'); | 246 chrome.send('updateDefaultSetting'); |
240 } | 247 } |
241 } | 248 } |
242 }; | 249 }; |
243 | 250 |
244 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { | 251 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict, |
| 252 isGloballyEnabled) { |
245 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, | 253 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, |
246 blockedDict); | 254 blockedDict, isGloballyEnabled); |
247 }; | 255 }; |
248 | 256 |
249 WebsiteSettingsManager.updateDefault = function(dict) { | 257 WebsiteSettingsManager.updateDefault = function(dict) { |
250 WebsiteSettingsManager.getInstance().updateDefault(dict); | 258 WebsiteSettingsManager.getInstance().updateDefault(dict); |
251 }; | 259 }; |
252 | 260 |
253 // Export | 261 // Export |
254 return { | 262 return { |
255 WebsiteSettingsManager: WebsiteSettingsManager | 263 WebsiteSettingsManager: WebsiteSettingsManager |
256 }; | 264 }; |
257 }); | 265 }); |
OLD | NEW |