Chromium Code Reviews| Index: chrome/browser/resources/settings/site_settings/site_details_permission.js |
| diff --git a/chrome/browser/resources/settings/site_settings/site_details_permission.js b/chrome/browser/resources/settings/site_settings/site_details_permission.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56dfbd74bd2cc52bc78fdf0e43419025d9effd1d |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/site_settings/site_details_permission.js |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview |
| + * 'site-details-permission' handles showing the state of one permission, such |
| + * as Geolocation, for a given origin. |
| + * |
| + * Example: |
| + * |
| + * <site-details-permission prefs="{{prefs}}"> |
| + * </site-details-permission> |
| + * ... other pages ... |
| + * |
| + * @group Chrome Settings Elements |
| + * @element site-details-permission |
| + */ |
| +Polymer({ |
| + is: 'site-details-permission', |
| + |
| + behaviors: [PrefsBehavior, SiteSettingsBehavior], |
| + |
| + properties: { |
| + /** |
| + * Preferences state. |
| + */ |
| + prefs: { |
| + type: Object, |
| + notify: true, |
| + }, |
| + |
| + /** |
| + * The ID of the category this widget is displaying data for. |
| + */ |
| + category: { |
|
michaelpg
2015/11/09 18:26:30
category: Number
Finnur
2015/11/10 16:00:51
Done.
|
| + type: Number, |
| + }, |
| + |
| + /** |
| + * The origin, which this permission affects. |
| + */ |
| + origin: { |
| + type: String, |
| + observer: 'initialize_', |
| + }, |
| + |
| + i18n_: { |
| + readOnly: true, |
| + type: Object, |
| + value: function() { |
| + return { |
| + allowAction: loadTimeData.getString('siteSettingsActionAllow'), |
| + blockAction: loadTimeData.getString('siteSettingsActionBlock'), |
| + }; |
| + }, |
| + }, |
| + }, |
| + |
| + initialize_: function() { |
| + var pref = this.getPref( |
| + this.computeCategoryExceptionsPrefName(this.category)); |
| + var originPref = pref.value[this.origin + ',*']; |
| + if (originPref === undefined) |
| + originPref = pref.value[this.origin + ',' + this.origin]; |
| + if (originPref === undefined) |
| + return; |
| + |
| + if (originPref.setting == settings.DefaultValues.ALLOW) { |
|
Finnur
2015/11/06 11:45:36
One question: Do you know how to take care of this
michaelpg
2015/11/09 18:26:30
Ultimately you'll need to annotate the type of ori
michaelpg
2015/11/09 18:26:30
hmm, kinda wish we had named this something more s
Finnur
2015/11/10 16:00:51
I agree. Renamed.
Finnur
2015/11/10 16:00:51
For some reason I was stuck in the mindset of havi
|
| + this.$.permission.selected = 0; |
| + this.$.details.hidden = false; |
| + } else if (originPref.setting == settings.DefaultValues.BLOCK) { |
| + this.$.permission.selected = 1; |
| + this.$.details.hidden = false; |
| + } |
| + }, |
| + |
| + resetPermission: function() { |
| + var pref = this.getPref( |
| + this.computeCategoryExceptionsPrefName(this.category)); |
| + delete pref.value[this.origin + ',' + this.origin]; |
| + delete pref.value[this.origin + ',*']; |
| + this.setPrefValue( |
| + this.computeCategoryExceptionsPrefName(this.category), pref.value); |
| + this.$.details.hidden = true; |
| + }, |
| +}); |