| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 144 |
| 140 /** | 145 /** |
| 141 * Populate the origin lists with all of the origins with a given permission | 146 * Populate the origin lists with all of the origins with a given permission |
| 142 * or that are using a given resource, potentially split by if allowed or | 147 * or that are using a given resource, potentially split by if allowed or |
| 143 * denied. If no blocked dictionary is provided, only the allowed list is | 148 * denied. If no blocked dictionary is provided, only the allowed list is |
| 144 * shown. | 149 * shown. |
| 145 * @param {!Object} allowedDict A dictionary of origins to their usage, | 150 * @param {!Object} allowedDict A dictionary of origins to their usage, |
| 146 which will be used to sort the origins in the main/allowed list. | 151 which will be used to sort the origins in the main/allowed list. |
| 147 * @param {!Object} blockedDict An optional dictionary of origins to their | 152 * @param {!Object} blockedDict An optional dictionary of origins to their |
| 148 usage, which will be used to sort the origins in the blocked list. | 153 usage, which will be used to sort the origins in the blocked list. |
| 154 * @param {bool} isGloballyEnabled If the content setting is turned on. |
| 149 * @private | 155 * @private |
| 150 */ | 156 */ |
| 151 populateOrigins: function(allowedDict, blockedDict) { | 157 populateOrigins: function(allowedDict, blockedDict, isGloballyEnabled) { |
| 152 this.populateOriginsHelper_(this.allowedList_, allowedDict); | 158 this.populateOriginsHelper_(this.allowedList_, allowedDict); |
| 153 if (blockedDict) { | 159 if (blockedDict) { |
| 154 this.populateOriginsHelper_(this.blockedList_, blockedDict); | 160 this.populateOriginsHelper_(this.blockedList_, blockedDict); |
| 155 this.blockedList_.hidden = false; | 161 this.blockedList_.hidden = false; |
| 156 $('blocked-origin-list-title').hidden = false; | 162 $('blocked-origin-list-title').hidden = false; |
| 157 this.allowedList_.classList.remove('nonsplit-origin-list'); | 163 this.allowedList_.classList.remove('nonsplit-origin-list'); |
| 158 } else { | 164 } else { |
| 159 this.blockedList_.hidden = true; | 165 this.blockedList_.hidden = true; |
| 160 $('blocked-origin-list-title').hidden = true; | 166 $('blocked-origin-list-title').hidden = true; |
| 161 this.allowedList_.classList.add('nonsplit-origin-list'); | 167 this.allowedList_.classList.add('nonsplit-origin-list'); |
| 162 } | 168 } |
| 169 $('global-setting-toggle').checked = isGloballyEnabled; |
| 163 }, | 170 }, |
| 164 | 171 |
| 165 /** | 172 /** |
| 166 * Update the table with the origins filtered by the value in the search | 173 * Update the table with the origins filtered by the value in the search |
| 167 * box. | 174 * box. |
| 168 * @private | 175 * @private |
| 169 */ | 176 */ |
| 170 searchOrigins: function() { | 177 searchOrigins: function() { |
| 171 var filter = $('website-settings-search-box').value; | 178 var filter = $('website-settings-search-box').value; |
| 172 chrome.send('updateOriginsSearchResults', [filter]); | 179 chrome.send('updateOriginsSearchResults', [filter]); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 240 } |
| 234 if (options.length == 0) { | 241 if (options.length == 0) { |
| 235 $('website-settings-global-controls').hidden = true; | 242 $('website-settings-global-controls').hidden = true; |
| 236 } else { | 243 } else { |
| 237 $('website-settings-global-controls').hidden = false; | 244 $('website-settings-global-controls').hidden = false; |
| 238 chrome.send('updateDefaultSetting'); | 245 chrome.send('updateDefaultSetting'); |
| 239 } | 246 } |
| 240 } | 247 } |
| 241 }; | 248 }; |
| 242 | 249 |
| 243 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { | 250 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict, |
| 251 isGloballyEnabled) { |
| 244 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, | 252 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, |
| 245 blockedDict); | 253 blockedDict, isGloballyEnabled); |
| 246 }; | 254 }; |
| 247 | 255 |
| 248 WebsiteSettingsManager.updateDefault = function(dict) { | 256 WebsiteSettingsManager.updateDefault = function(dict) { |
| 249 WebsiteSettingsManager.getInstance().updateDefault(dict); | 257 WebsiteSettingsManager.getInstance().updateDefault(dict); |
| 250 }; | 258 }; |
| 251 | 259 |
| 252 // Export | 260 // Export |
| 253 return { | 261 return { |
| 254 WebsiteSettingsManager: WebsiteSettingsManager | 262 WebsiteSettingsManager: WebsiteSettingsManager |
| 255 }; | 263 }; |
| 256 }); | 264 }); |
| OLD | NEW |