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.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. |
11 /** @const */ var permissionsLookup = { | 11 /** @const */ var permissionsLookup = { |
12 'geolocation': 'location', | 12 'geolocation': 'location', |
13 'notifications': 'notifications', | 13 'notifications': 'notifications', |
14 'media-stream': 'mediaStream', | 14 'media-stream': 'mediaStream', |
15 'cookies': 'cookies', | 15 'cookies': 'cookies', |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 */ | 53 */ |
54 blockedList_: null, | 54 blockedList_: null, |
55 | 55 |
56 /** @override */ | 56 /** @override */ |
57 initializePage: function() { | 57 initializePage: function() { |
58 Page.prototype.initializePage.call(this); | 58 Page.prototype.initializePage.call(this); |
59 | 59 |
60 $('website-settings-overlay-confirm').onclick = | 60 $('website-settings-overlay-confirm').onclick = |
61 PageManager.closeOverlay.bind(PageManager); | 61 PageManager.closeOverlay.bind(PageManager); |
62 | 62 |
63 $('resourceType').onchange = function(event) { | |
64 var target = event.target; | |
65 assert(target.tagName == 'SELECT'); | |
66 WebsiteSettingsManager.getInstance().updatePage_(target.value); | |
67 }; | |
68 | |
69 $('global-setting').onchange = function(event) { | 63 $('global-setting').onchange = function(event) { |
70 chrome.send('setDefaultContentSetting', [this.value]); | 64 chrome.send('setDefaultContentSetting', [this.value]); |
71 }; | 65 }; |
72 | 66 |
73 var searchBox = $('website-settings-search-box'); | 67 var searchBox = $('website-settings-search-box'); |
74 searchBox.addEventListener('search', | 68 searchBox.addEventListener('search', |
75 this.handleSearchQueryChange_.bind(this)); | 69 this.handleSearchQueryChange_.bind(this)); |
76 | 70 |
77 searchBox.onkeydown = function(e) { | 71 searchBox.onkeydown = function(e) { |
78 if (e.keyIdentifier == 'Enter') | 72 if (e.keyIdentifier == 'Enter') |
79 e.preventDefault(); | 73 e.preventDefault(); |
80 }; | 74 }; |
81 | 75 |
82 this.createOriginsList_(); | 76 this.createOriginsList_(); |
83 this.updatePage_('geolocation'); | 77 this.updatePage_('geolocation'); |
84 }, | 78 }, |
85 | 79 |
86 /** | 80 /** |
87 * Called after the page has been shown. Show the content settings or | 81 * Called after the page has been shown. Show the content settings or |
88 * resource auditing for the location's hash. | 82 * resource auditing for the location's hash. |
89 */ | 83 */ |
90 didShowPage: function() { | 84 didShowPage: function() { |
91 var hash = location.hash; | 85 var hash = location.hash; |
92 if (hash) | 86 if (hash) |
93 hash = hash.slice(1); | 87 hash = hash.slice(1); |
94 else | 88 else |
95 hash = 'geolocation'; | 89 hash = 'geolocation'; |
96 this.updatePage_(hash); | 90 this.updatePage_(hash); |
97 | |
98 $('resourceType').value = hash; | |
99 }, | 91 }, |
100 | 92 |
101 /** | 93 /** |
102 * Creates, decorates and initializes the origin list. | 94 * Creates, decorates and initializes the origin list. |
103 * @private | 95 * @private |
104 */ | 96 */ |
105 createOriginsList_: function() { | 97 createOriginsList_: function() { |
106 this.allowedList_ = $('allowed-origin-list'); | 98 this.allowedList_ = $('allowed-origin-list'); |
107 options.OriginList.decorate(this.allowedList_); | 99 options.OriginList.decorate(this.allowedList_); |
108 this.allowedList_.autoExpands = true; | 100 this.allowedList_.autoExpands = true; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 options.add(new Option(loadTimeData.getString(valueId), | 224 options.add(new Option(loadTimeData.getString(valueId), |
233 permissions[i].toLowerCase())); | 225 permissions[i].toLowerCase())); |
234 } | 226 } |
235 } | 227 } |
236 if (options.length == 0) { | 228 if (options.length == 0) { |
237 $('website-settings-global-controls').hidden = true; | 229 $('website-settings-global-controls').hidden = true; |
238 } else { | 230 } else { |
239 $('website-settings-global-controls').hidden = false; | 231 $('website-settings-global-controls').hidden = false; |
240 chrome.send('updateDefaultSetting'); | 232 chrome.send('updateDefaultSetting'); |
241 } | 233 } |
| 234 |
| 235 $('website-settings-title').textContent = |
| 236 loadTimeData.getString(permissionString + 'TabLabel'); |
242 } | 237 } |
243 }; | 238 }; |
244 | 239 |
245 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { | 240 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { |
246 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, | 241 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, |
247 blockedDict); | 242 blockedDict); |
248 }; | 243 }; |
249 | 244 |
250 WebsiteSettingsManager.updateDefault = function(dict) { | 245 WebsiteSettingsManager.updateDefault = function(dict) { |
251 WebsiteSettingsManager.getInstance().updateDefault(dict); | 246 WebsiteSettingsManager.getInstance().updateDefault(dict); |
252 }; | 247 }; |
253 | 248 |
254 // Export | 249 // Export |
255 return { | 250 return { |
256 WebsiteSettingsManager: WebsiteSettingsManager | 251 WebsiteSettingsManager: WebsiteSettingsManager |
257 }; | 252 }; |
258 }); | 253 }); |
OLD | NEW |