summaryrefslogtreecommitdiffstats
path: root/components/permissions/aboutPermissions.xml
blob: 2932ea08c97890997896bddd8ec741dff993f7ba (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE bindings [
<!ENTITY % aboutPermissionsDTD SYSTEM "chrome://browser/locale/permissions/aboutPermissions.dtd" >
%aboutPermissionsDTD;
]>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">
  <binding id="site" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
    <content>
      <xul:hbox class="site-container" align="center" flex="1">
        <xul:image xbl:inherits="src=favicon" class="site-favicon"/>
        <xul:label xbl:inherits="value,selected" class="site-domain" crop="end" flex="1"/>
      </xul:hbox>
    </content>
  </binding>

  <binding id="pluginPermission">
    <content>
      <xul:hbox flex="1" align="baseline">
        <xul:label xbl:inherits="value=label" class="plugins-label"/>
        <xul:label xbl:inherits="value=vulnerable" class="plugins-vulnerable"/>
        <xul:label xbl:inherits="value=default" anonid="plugins-default" class="plugins-default"/>
        <xul:spacer flex="1"/>
        <xul:menulist anonid="plugins-menulist"
                      class="pref-menulist"
                      oncommand="AboutPermissions.onPermissionCommand(event, false);">
          <xul:menupopup>
            <xul:menuitem anonid="ask" value="0" label="&permission.alwaysAsk;"/>
            <xul:menuitem anonid="allow" value="1" label="&permission.allow;"/>
            <xul:menuitem anonid="block" value="2" label="&permission.block;"/>
          </xul:menupopup>
        </xul:menulist>
        <xul:button xbl:inherits="value=set-default"
                    anonid="plugins-set-default"
                    class="pref-set-default"
                    label="&permission.default;"
                    oncommand="AboutPermissions.onPermissionCommand(event, true);"/>
      </xul:hbox>
    </content>
    <implementation>
      <constructor><![CDATA[
        let mimeType = this.getAttribute("mimeType");
        let permString = this.getAttribute("permString");
        let menulist = document.getAnonymousElementByAttribute(this, "anonid", "plugins-menulist");
        menulist.setAttribute("id", permString + "-menulist");
        menulist.setAttribute("mimeType", mimeType);
        menulist.setAttribute("type", permString);
        let askitem = document.getAnonymousElementByAttribute(this, "anonid", "ask");
        askitem.setAttribute("id", permString + "-0");
        let allowitem = document.getAnonymousElementByAttribute(this, "anonid", "allow");
        allowitem.setAttribute("id", permString + "-1");
        let blockitem = document.getAnonymousElementByAttribute(this, "anonid", "block");
        blockitem.setAttribute("id", permString + "-2");
        let _default = document.getAnonymousElementByAttribute(this, "anonid", "plugins-default");
        this.setDefaultVisibility(false);
        _default.setAttribute("value", "*");
        let _setDefault = document.getAnonymousElementByAttribute(this, "anonid", "plugins-set-default");
        _setDefault.setAttribute("id", permString + "-set-default");
        _setDefault.setAttribute("class", "pref-set-default");
        _setDefault.setAttribute("type", permString);
      ]]>
      </constructor>
      <method name="setDefaultVisibility">
        <parameter name="visibility" />
        <body><![CDATA[
          let _default = document.getAnonymousElementByAttribute(this, "anonid", "plugins-default");
          if (visibility) {
            _default.style.visibility = "visible";
          } else {
            _default.style.visibility = "hidden";
          }
        ]]>
        </body>
      </method>
      <method name="isClickToPlay">
        <body><![CDATA[
          let pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
              .getService(Components.interfaces.nsIPluginHost);
          let mimeType = this.getAttribute("mimeType");
          return (pluginHost.getStateForType(mimeType)
              == Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY);
        ]]>
        </body>
      </method>
      <method name="isBlocklisted">
        <body><![CDATA[
          let pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
                           .getService(Components.interfaces.nsIPluginHost);
          let blocklistService = Components.classes["@mozilla.org/extensions/blocklist;1"]
                                 .getService(Components.interfaces.nsIBlocklistService);
          let mimeType = this.getAttribute("mimeType");
          let tags = pluginHost.getPluginTags();
          let blocklistState = Components.interfaces.nsIBlocklistService.STATE_NOT_BLOCKED;
          for (let plugin of tags) {
            if (plugin.getMimeTypes()[0] == mimeType) {
              blocklistState = blocklistService.getPluginBlocklistState(plugin);
              break;
            }
          }
          return (blocklistState == Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE ||
                  blocklistState == Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
        ]]>
        </body>
      </method>
    </implementation>
  </binding>
</bindings>