| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-site-settings-page' is the settings page containing privacy and | 7 * 'settings-site-settings-page' is the settings page containing privacy and |
| 8 * security site settings. | 8 * security site settings. |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 /** @private */ | 29 /** @private */ |
| 30 enableSiteSettings_: { | 30 enableSiteSettings_: { |
| 31 type: Boolean, | 31 type: Boolean, |
| 32 value: function() { | 32 value: function() { |
| 33 return loadTimeData.getBoolean('enableSiteSettings'); | 33 return loadTimeData.getBoolean('enableSiteSettings'); |
| 34 }, | 34 }, |
| 35 }, | 35 }, |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** @override */ |
| 38 ready: function() { | 39 ready: function() { |
| 39 this.ContentSettingsTypes = settings.ContentSettingsTypes; | 40 this.ContentSettingsTypes = settings.ContentSettingsTypes; |
| 40 this.ALL_SITES = settings.ALL_SITES; | 41 this.ALL_SITES = settings.ALL_SITES; |
| 41 | 42 |
| 42 var keys = Object.keys(settings.ContentSettingsTypes); | 43 var keys = Object.keys(settings.ContentSettingsTypes); |
| 43 for (var i = 0; i < keys.length; ++i) { | 44 for (var i = 0; i < keys.length; ++i) { |
| 44 var key = settings.ContentSettingsTypes[keys[i]]; | 45 var key = settings.ContentSettingsTypes[keys[i]]; |
| 45 // Default labels are not applicable to USB and ZOOM. | 46 // Default labels are not applicable to USB and ZOOM. |
| 46 if (key == settings.ContentSettingsTypes.USB_DEVICES || | 47 if (key == settings.ContentSettingsTypes.USB_DEVICES || |
| 47 key == settings.ContentSettingsTypes.ZOOM_LEVELS) | 48 key == settings.ContentSettingsTypes.ZOOM_LEVELS) |
| 48 continue; | 49 continue; |
| 49 this.updateDefaultValueLabel_(key); | 50 this.updateDefaultValueLabel_(key); |
| 50 } | 51 } |
| 51 | 52 |
| 52 this.addWebUIListener( | 53 this.addWebUIListener( |
| 53 'contentSettingCategoryChanged', | 54 'contentSettingCategoryChanged', |
| 54 this.updateDefaultValueLabel_.bind(this)); | 55 this.updateDefaultValueLabel_.bind(this)); |
| 56 this.addWebUIListener( |
| 57 'setHandlersEnabled', |
| 58 this.updateHandlersEnabled_.bind(this)); |
| 59 this.browserProxy.observeProtocolHandlersEnabledState(); |
| 55 }, | 60 }, |
| 56 | 61 |
| 57 /** | 62 /** |
| 58 * @param {string} category The category to update. | 63 * @param {string} category The category to update. |
| 59 * @private | 64 * @private |
| 60 */ | 65 */ |
| 61 updateDefaultValueLabel_: function(category) { | 66 updateDefaultValueLabel_: function(category) { |
| 62 this.browserProxy.getDefaultValueForContentType( | 67 this.browserProxy.getDefaultValueForContentType( |
| 63 category).then(function(defaultValue) { | 68 category).then(function(defaultValue) { |
| 64 var labelVar = | |
| 65 'default_.' + Polymer.CaseMap.dashToCamelCase(category); | |
| 66 this.set( | 69 this.set( |
| 67 labelVar, | 70 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
| 68 this.computeCategoryDesc( | 71 this.computeCategoryDesc( |
| 69 category, | 72 category, |
| 70 defaultValue.setting, | 73 defaultValue.setting, |
| 71 /*showRecommendation=*/false)); | 74 /*showRecommendation=*/false)); |
| 72 }.bind(this)); | 75 }.bind(this)); |
| 73 }, | 76 }, |
| 74 | 77 |
| 75 /** | 78 /** |
| 79 * The protocol handlers have a separate enabled/disabled notifier. |
| 80 * @param {boolean} enabled |
| 81 * @private |
| 82 */ |
| 83 updateHandlersEnabled_: function(enabled) { |
| 84 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; |
| 85 this.set( |
| 86 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
| 87 this.computeCategoryDesc( |
| 88 category, |
| 89 enabled ? |
| 90 settings.PermissionValues.ALLOW : |
| 91 settings.PermissionValues.BLOCK, |
| 92 /*showRecommendation=*/false)); |
| 93 }, |
| 94 |
| 95 /** |
| 76 * Navigate to the route specified in the event dataset. | 96 * Navigate to the route specified in the event dataset. |
| 77 * @param {!Event} event The tap event. | 97 * @param {!Event} event The tap event. |
| 78 * @private | 98 * @private |
| 79 */ | 99 */ |
| 80 onTapNavigate_: function(event) { | 100 onTapNavigate_: function(event) { |
| 81 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); | 101 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); |
| 82 settings.navigateTo(settings.Route[dataSet.route]); | 102 settings.navigateTo(settings.Route[dataSet.route]); |
| 83 }, | 103 }, |
| 84 }); | 104 }); |
| OLD | NEW |