# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is Mozilla.org Code. # # The Initial Developer of the Original Code is # Doron Rosenberg. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All Rights Reserved. # # Contributor(s): # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** var _elementIDs = ["advancedJavaAllow", "enableJavaScript", "enableImagePref", "popupPolicy", "allowWindowMoveResize", "allowWindowFlip", "allowHideStatusBar", "allowWindowStatusChange", "allowImageSrcChange"]; var gImagesPref, gImagesEnabled, gImagesRestricted; var policyButton = null; var manageTree = null; const nsIPermissionManager = Components.interfaces.nsIPermissionManager; function Startup() { policyButton = document.getElementById("popupPolicy"); manageTree = document.getElementById("permissionsTree"); togglePermissionEnabling(); loadPermissions(); javascriptEnabledChange() gImagesPref = document.getElementById("enableImagePref"); gImagesEnabled = document.getElementById("enableImages"); gImagesRestricted = document.getElementById("enableRestricted"); var prefValue = gImagesPref.getAttribute("value"); if (!prefValue) prefValue = "0"; switch (prefValue) { case "1": gImagesRestricted.checked=true; case "0": gImagesEnabled.checked=true; } if (!gImagesEnabled.checked) gImagesRestricted.disabled=true; } function updateImagePref() { if (!gImagesEnabled.checked) { gImagesPref.setAttribute("value", 2) gImagesRestricted.disabled=true; } else { gImagesPref.setAttribute("value", gImagesRestricted.checked?1:0) gImagesRestricted.disabled=false; } } function viewImages() { openDialog("chrome://browser/content/cookieviewer/CookieViewer.xul","_blank", "chrome,resizable=yes,modal", "imageManager" ); } function advancedJavaScript() { openDialog("chrome://browser/content/pref/pref-advancedscripts.xul", "", "chrome,modal"); } function javascriptEnabledChange() { var isEnabled = document.getElementById("enableJavaScript").checked; var advancedButton = document.getElementById("advancedJavascript"); advancedButton.disabled = !isEnabled; } function togglePermissionEnabling() { var enabled = policyButton.checked; var add = document.getElementById("addPermission"); var remove1 = document.getElementById("removePermission"); var remove2 = document.getElementById("removeAllPermissions"); var description = document.getElementById("popupDescription"); add.disabled = !enabled; remove1.disabled = !enabled; remove2.disabled = !enabled; description.disabled = !enabled; manageTree.disabled = !enabled; } /*** =================== PERMISSIONS CODE =================== ***/ var permissionsTreeView = { rowCount : 0, setTree : function(tree){}, getImageSrc : function(row,column) {}, getProgressMode : function(row,column) {}, getCellValue : function(row,column) {}, getCellText : function(row,column){ var rv=""; if (column=="siteCol") { rv = permissions[row].rawHost; } else if (column=="statusCol") { rv = permissions[row].capability; } return rv; }, isSeparator : function(index) {return false;}, isSorted: function() { return false; }, isContainer : function(index) {return false;}, cycleHeader : function(aColId, aElt) {}, getRowProperties : function(row,column,prop){}, getColumnProperties : function(column,columnElement,prop){}, getCellProperties : function(row,prop){} }; var permissionsTree; var permissions = []; var deletedPermissions = []; function Permission(number, host, rawHost, type, capability) { this.number = number; this.host = host; this.rawHost = rawHost; this.type = type; this.capability = capability; } var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService(); permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager); var popupmanager = Components.classes["@mozilla.org/PopupWindowManager;1"].getService(); popupmanager = popupmanager.QueryInterface(Components.interfaces.nsIPopupWindowManager); function DeleteAllFromTree (tree, view, table, deletedTable, removeButton, removeAllButton) { // remove all items from table and place in deleted table for (var i=0; i