1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// 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 origin, which this permission affects.
*/
origin: String,
i18n_: {
readOnly: true,
type: Object,
value: function() {
return {
allowAction: loadTimeData.getString('siteSettingsActionAllow'),
blockAction: loadTimeData.getString('siteSettingsActionBlock'),
};
},
},
},
observers: [
'initialize_(' +
'prefs.profile.content_settings.exceptions.*, category, origin)',
],
initialize_: function() {
this.$.details.hidden = true;
if (this.get('prefs.' +
this.computeCategoryExceptionsPrefName(this.category)) === undefined)
return;
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 (/** @type {{setting: number}} */(originPref.setting) ==
settings.PermissionValues.ALLOW) {
this.$.permission.selected = 0;
this.$.details.hidden = false;
} else if (originPref.setting == settings.PermissionValues.BLOCK) {
this.$.permission.selected = 1;
this.$.details.hidden = false;
}
},
/**
* Resets the category permission for this origin.
*/
resetPermission: function() {
this.resetCategoryPermissionForOrigin(this.origin, this.category);
this.$.details.hidden = true;
},
/**
* Handles the category permission changing for this origin.
* @param {!{target: !{selectedItem: !{innerText: string}}}} event
*/
onPermissionMenuIronSelect_: function(event) {
var action = event.target.selectedItem.innerText;
var value = (action == this.i18n_.allowAction) ?
settings.PermissionValues.ALLOW :
settings.PermissionValues.BLOCK;
this.setCategoryPermissionForOrigin(this.origin, value, this.category);
},
});
|