Chromium Code Reviews| Index: chrome/browser/resources/options/website_settings.js |
| diff --git a/chrome/browser/resources/options/website_settings.js b/chrome/browser/resources/options/website_settings.js |
| index 4cda6f18c367e21875a67d8b999b80c2ecc13544..30d6cf2299a243d428293f1a4ffdb84a0cbda305 100644 |
| --- a/chrome/browser/resources/options/website_settings.js |
| +++ b/chrome/browser/resources/options/website_settings.js |
| @@ -18,6 +18,20 @@ cr.define('options', function() { |
| Page.call(this, 'websiteSettings', |
| loadTimeData.getString('websitesOptionsPageTabTitle'), |
| 'website-settings-page'); |
| + |
|
Bernhard Bauer
2014/09/09 08:56:21
Nit: remove one blank line.
Daniel Nishi
2014/09/09 16:11:56
Done.
|
| + |
| + // Lookup table to generate the i18n strings. |
| + this.permissionsLookup = { |
|
Bernhard Bauer
2014/09/09 08:56:21
This can probably be made a constant in a var scop
Daniel Nishi
2014/09/09 16:11:56
Done.
|
| + 'geolocation': 'location_', |
| + 'notifications': 'notifications_', |
| + 'media-stream': 'mediaStream', |
| + 'cookies': 'cookies_', |
| + 'multiple-automatic-downloads': 'multiple-automatic-downloads_', |
| + 'images': 'images_', |
| + 'plugins': 'plugins_', |
| + 'popups': 'popups_', |
| + 'javascript': 'javascript_' |
| + }; |
| } |
| cr.addSingletonGetter(WebsiteSettingsManager); |
| @@ -52,6 +66,10 @@ cr.define('options', function() { |
| WebsiteSettingsManager.getInstance().updatePage_(target.value); |
| }; |
| + $('global-setting').onchange = function(event) { |
| + chrome.send('setDefaultContentSetting', [this.value]); |
| + }; |
| + |
| var searchBox = $('website-settings-search-box'); |
| searchBox.addEventListener('search', |
| this.handleSearchQueryChange_.bind(this)); |
| @@ -174,6 +192,28 @@ cr.define('options', function() { |
| }, |
| /** |
| + * Sets the default content setting dropdown on the page to the current |
| + * default. |
| + * @param {!Object} dict A dictionary with the management and value of the |
| + * default setting for the last selected content setting.. |
| + */ |
| + updateDefault: function(dict) { |
| + // TODO(dhnishi): Remove duplicate default handling in the Content |
| + // Settings page and here. |
| + var managedBy = dict.managedBy; |
| + var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? |
| + managedBy : null; |
| + $('global-setting').disabled = (managedBy != 'default'); |
| + |
| + var options = $('global-setting').options; |
| + for (var i = 0; i < options.length; i++) { |
| + if (options[i].value == dict.value) { |
| + options.selectedIndex = i; |
| + } |
| + } |
| + }, |
| + |
| + /** |
| * Updates the page with the given content setting or resource name's |
| * information. |
| * @param {string} typeName The name of the content setting or resource. |
| @@ -185,6 +225,32 @@ cr.define('options', function() { |
| chrome.send('updateBatteryUsage'); |
| else |
| chrome.send('updateOrigins', [typeName]); |
| + |
| + var permissions = ['allow', 'ask', 'block']; |
| + if (typeName == 'media-stream') { |
| + permissions = ['Allow', 'Ask', 'Block']; |
|
Bernhard Bauer
2014/09/09 08:56:21
I would rather fix this up in ContentSettingsHandl
Daniel Nishi
2014/09/09 16:11:56
I converted over the Content Setting permission st
|
| + } |
| + |
| + var options = $('global-setting').options; |
| + options.length = 0; |
| + var permissionString = |
| + this.permissionsLookup[typeName]; |
| + for (var i = 0; i < permissions.length; i++) { |
| + var valueId = permissionString + permissions[i]; |
| + if (loadTimeData.valueExists(valueId)) { |
| + var loadString = loadTimeData.getString(valueId); |
| + if (loadString != '') |
|
Bernhard Bauer
2014/09/09 08:56:21
Do you actually need this check?
Daniel Nishi
2014/09/09 16:11:56
Nope.
Removed.
|
| + options.add(new Option(loadTimeData.getString(valueId), |
|
Bernhard Bauer
2014/09/09 08:56:21
You can use loadString here.
Also, looking at thi
Daniel Nishi
2014/09/09 16:11:56
Eliminated the use of an intermediate variable all
|
| + permissions[i].toLowerCase())); |
| + } |
| + } |
| + if (options.length == 0) { |
| + $('website-settings-global-controls').hidden = true; |
| + } |
| + else { |
|
Bernhard Bauer
2014/09/09 08:56:21
Nit: Move this to the same line as the closing bra
Daniel Nishi
2014/09/09 16:11:56
Done.
|
| + $('website-settings-global-controls').hidden = false; |
| + chrome.send('updateDefaultSetting'); |
| + } |
| } |
| }; |
| @@ -197,6 +263,10 @@ cr.define('options', function() { |
| WebsiteSettingsEditor.getInstance().populatePage(url); |
| }; |
| + WebsiteSettingsManager.updateDefault = function(dict) { |
| + WebsiteSettingsManager.getInstance().updateDefault(dict); |
| + }; |
| + |
| // Export |
| return { |
| WebsiteSettingsManager: WebsiteSettingsManager |