home *** CD-ROM | disk | FTP | other *** search
- var scPopup = {
- DEBUG : true,
-
- currentURI : null,
- dirty : false,
- switchingEngines : false,
- prefService : null,
- engineDisableDelay : 2000,
-
- mStrings : null,
- mSiteName : null,
- mTabbox : null,
- mTrustImg : null,
- mTrustDeck : null,
- mPartnerBox : null,
- mTrustRadioGroup : null,
- mTrustRadio : null,
- mStandardRadio : null,
- mCautionRadio : null,
- mCustomRadioBox: null,
- mCustomRadio : null,
- mTrustEngine : null,
- mTrustGecko : null,
- mTrustTrident : null,
- mAdvEngine : null,
- mAdvGecko : null,
- mAdvTrident : null,
- mAllowPopups : null,
- mAllowImages : null,
- mOpenPopupsInTab : null,
- mAllowCookies : null,
- mImagesOrig : null,
- mCookiesOrig : null,
- mEnableJS : null,
- mEnableJava : null,
- mEnableActiveX : null,
- mBtnBar : null,
- mManageButton : null,
-
- init : function() {
- this.debug('init()');
- this.prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- this.mStrings = document.getElementById('sc_strings');
- this.mSiteName = document.getElementById('scp_siteName');
- this.mTitleDeck = document.getElementById('scp_title_deck');
- this.mTabbox = document.getElementById('scp_tabbox');
- this.mTrustImg = document.getElementById('scp_trust_img');
- this.mTrustDeck = document.getElementById('scp_trust_desc_deck');
- this.mPartnerBox = document.getElementById('scp_partner_box');
- this.mTrustRadioGroup = document.getElementById('scp_trust_radios');
- this.mTrustRadio = document.getElementById('scp_radio_trust');
- this.mStandardRadio = document.getElementById('scp_radio_standard');
- this.mCautionRadio = document.getElementById('scp_radio_caution');
- this.mCustomRadio = document.getElementById('scp_radio_custom');
- this.mCustomRadioBox = document.getElementById('scp_radio_custom_box');
- this.mTrustEngine = document.getElementById('scp_trust_displayEngine');
- this.mTrustGecko = document.getElementById('scp_trust_gecko');
- this.mTrustTrident = document.getElementById('scp_trust_trident');
- this.mAdvEngine = document.getElementById('scp_adv_displayEngine');
- this.mAdvGecko = document.getElementById('scp_adv_gecko');
- this.mAdvTrident = document.getElementById('scp_adv_trident');
- this.mAllowPopups = document.getElementById('scp_allowPopups');
- this.mOpenPopupsInTab = document.getElementById('scp_openPopupsInTab');
- this.mAllowImages = document.getElementById('scp_allowImages');
- this.mImagesOrig = document.getElementById('scp_imagesFromOrigOnly');
- this.mAllowCookies = document.getElementById('scp_allowCookies');
- this.mCookiesOrig = document.getElementById('scp_cookiesFromOrigOnly');
- this.mEnableJS = document.getElementById('scp_enableJavaScript');
- this.mEnableJava = document.getElementById('scp_enableJava');
- this.mEnableActiveX = document.getElementById('scp_enableActiveX');
- this.mBtnBar = document.getElementById('scp_btnbar');
- this.mManageButton = document.getElementById('scp_manage_button');
- this.switchingEngines = false;
- },
-
- findSecurityPartners : function() {
- // remove all the partners first
- while(this.mPartnerBox.firstChild) {
- this.mPartnerBox.removeChild(this.mPartnerBox.firstChild);
- }
-
- this.debug('findSecurityPartners(): ' + this.currentURI.spec + '\n');
- var sc = sitecontrols.SCSVC;
-
- switch(sc.getSiteTrustLevel(this.currentURI.spec)) {
- case 0:
- // whitelisted
- var whiteListCode = sc.getSiteTrustLevelDetail(this.currentURI.spec, sc.SC_TRUST_WHITELIST_IDX);
- var whiteListStr = sc.getSiteTrustProviderName(whiteListCode);
- var whiteListArray = whiteListStr.split('|');
- var whiteListURLStr = sc.getSiteTrustProviderURL(whiteListCode);
- var whiteListURLArray = whiteListURLStr.split('|');
- var whiteListIconStr = sc.getSiteTrustProviderIcon(whiteListCode);
- var whiteListIconArray = whiteListIconStr.split('|');
-
- var hboxElem;
- var iconElem;
- var descElem;
- var tmpURL;
- for(var i = 0; i < whiteListArray.length; i++) {
- hboxElem = document.createElement("hbox");
- iconElem = document.createElement("image");
- iconElem.setAttribute("src", whiteListIconArray[i] );
- iconElem.setAttribute("class", "scp_partner_icon");
- descElem = document.createElement("label");
- descElem.setAttribute("value", whiteListArray[i]);
- descElem.setAttribute("class", "scp_partner_text");
- tmpURL = "scPopup.loadTrustPartnersTab('" + whiteListURLArray[i] + "');";
- descElem.setAttribute("onclick", tmpURL);
- hboxElem.appendChild(iconElem);
- hboxElem.appendChild(descElem);
- this.mPartnerBox.appendChild(hboxElem);
- }
- break;
- case 2:
- // phish
- var phishListCode = sc.getSiteTrustLevelDetail(this.currentURI.spec, sc.SC_TRUST_PHISHLIST_IDX);
- var phishListStr = sc.getSiteTrustProviderName(phishListCode);
- var phishListArray = phishListStr.split('|');
- var phishListURLStr = sc.getSiteTrustProviderURL(phishListCode);
- var phishListURLArray = phishListURLStr.split('|');
- var phishListIconStr = sc.getSiteTrustProviderIcon(phishListCode);
- var phishListIconArray = phishListIconStr.split('|');
-
- var hboxElem;
- var iconElem;
- var descElem;
- var tmpURL;
- for(var i = 0; i < phishListArray.length; i++) {
- hboxElem = document.createElement("hbox");
- iconElem = document.createElement("image");
- iconElem.setAttribute("src", phishListIconArray[i]);
- iconElem.setAttribute("class", "scp_partner_icon");
- descElem = document.createElement("label");
- descElem.setAttribute("value", phishListArray[i]);
- descElem.setAttribute("class", "scp_partner_text");
- tmpURL = "scPopup.loadTrustPartnersTab('" + phishListURLArray[i] + "');";
- descElem.setAttribute("onclick", tmpURL);
- hboxElem.appendChild(iconElem);
- hboxElem.appendChild(descElem);
- this.mPartnerBox.appendChild(hboxElem);
- }
- break;
- case 4:
- // spy
- var spyListCode = sc.getSiteTrustLevelDetail(this.currentURI.spec, sc.SC_TRUST_SPYLIST_IDX);
- var spyListStr = sc.getSiteTrustProviderName(spyListCode);
- var spyListArray = spyListStr.split('|');
- var spyListURLStr = sc.getSiteTrustProviderURL(spyListCode);
- var spyListURLArray = spyListURLStr.split('|');
- var spyListIconStr = sc.getSiteTrustProviderIcon(spyListCode);
- var spyListIconArray = spyListIconStr.split('|');
-
- var hboxElem;
- var iconElem;
- var descElem;
- var tmpURL;
- for(var i = 0; i < spyListArray.length; i++) {
- hboxElem = document.createElement("hbox");
- iconElem = document.createElement("image");
- iconElem.setAttribute("src", spyListIconArray[i]);
- iconElem.setAttribute("class", "scp_partner_icon");
- descElem = document.createElement("label");
- descElem.setAttribute("value", spyListArray[i]);
- descElem.setAttribute("class", "scp_partner_text");
- tmpURL = "scPopup.loadTrustPartnersTab('" + spyListURLArray[i] + "');";
- descElem.setAttribute("onclick", tmpURL);
- hboxElem.appendChild(iconElem);
- hboxElem.appendChild(descElem);
- this.mPartnerBox.appendChild(hboxElem);
- }
- break;
- case 6:
- // both phish and spy
- var phishListCode = sc.getSiteTrustLevelDetail(this.currentURI.spec, sc.SC_TRUST_PHISHLIST_IDX);
- var phishListStr = sc.getSiteTrustProviderName(phishListCode);
- var phishListArray = phishListStr.split('|');
- var phishListURLStr = sc.getSiteTrustProviderURL(phishListCode);
- var phishListURLArray = phishListURLStr.split('|');
- var phishListIconStr = sc.getSiteTrustProviderIcon(phishListCode);
- var phishListIconArray = phishListIconStr.split('|');
-
- var spyListCode = sc.getSiteTrustLevelDetail(this.currentURI.spec, sc.SC_TRUST_SPYLIST_IDX);
- var spyListStr = sc.getSiteTrustProviderName(spyListCode);
- var spyListArray = spyListStr.split('|');
- var spyListURLStr = sc.getSiteTrustProviderURL(spyListCode);
- var spyListURLArray = spyListURLStr.split('|');
- var spyListIconStr = sc.getSiteTrustProviderIcon(spyListCode);
- var spyListIconArray = spyListIconStr.split('|');
-
- var combinedArray = phishListArray;
- var combinedURLArray = phishListURLArray;
- var combinedIconArray = phishListIconArray;
- var found;
-
- for(var arrayItem in spyListArray) {
- found = false;
- for(var k = 0; k < phishListArray.length; k++) {
- if(spyListArray[arrayItem] == phishListArray[k]) {
- found = true;
- break;
- }
- }
- if(!found) {
- combinedArray.push(spyListArray[arrayItem]);
- combinedURLArray.push(spyListURLArray[arrayItem]);
- combinedIconArray.push(spyListIconArray[arrayItem]);
- }
- }
-
- /*
- for(var arrayItem in spyListURLArray) {
- found = false;
- for(var k = 0; k < phishListURLArray.length; k++) {
- if(spyListURLArray[arrayItem] == phishListURLArray[k]) {
- found = true;
- break;
- }
- }
- if(!found) {
- combinedURLArray.push(spyListURLArray[arrayItem]);
- }
- }
- */
- var hboxElem;
- var iconElem;
- var descElem;
- var tmpURL;
- for(var i = 0; i < combinedArray.length; i++) {
- hboxElem = document.createElement("hbox");
- iconElem = document.createElement("image");
- iconElem.setAttribute("src", combinedIconArray[i]);
- iconElem.setAttribute("class", "scp_partner_icon");
- descElem = document.createElement("label");
- descElem.setAttribute("value", combinedArray[i]);
- descElem.setAttribute("class", "scp_partner_text");
- tmpURL = "scPopup.loadTrustPartnersTab('" + combinedURLArray[i] + "');";
- descElem.setAttribute("onclick", tmpURL);
- hboxElem.appendChild(iconElem);
- hboxElem.appendChild(descElem);
- this.mPartnerBox.appendChild(hboxElem);
- }
- break;
- case 1:
- default:
- // unknown
- }
- },
-
- loadTrustPartnersTab : function(url)
- {
- dump('*** foobar\n');
- var gBrowser = document.getElementById('content');
- document.getElementById('SiteControlsPopup').hidePopup();
- if (url) {
- var trustTab = gBrowser.addTabAt(url);
- if (!gPrefService.getBoolPref("browser.tabs.loadInBackground"))
- gBrowser.selectedTab = trustTab;
- }
- },
-
- loadCurrentSite : function() {
- this.debug('loadCurrentSite()');
- this.currentURI = gBrowser.currentURI;
- var sc = sitecontrols.SCSVC;
-
- if (sc.isControllableURI(this.currentURI.spec)) {
- this.debug(' { controllable: '+this.currentURI.spec+' }');
- // Controllable URI, so enable controls as appropriate
- this.mTrustImg.removeAttribute('disabled');
- this.mTrustDeck.removeAttribute('disabled');
- this.enableDisableSwitching(true);
- this.mAllowPopups.removeAttribute('disabled');
- this.mOpenPopupsInTab.removeAttribute('disabled');
- this.mAllowImages.removeAttribute('disabled');
- this.mAllowCookies.removeAttribute('disabled');
- this.mCookiesOrig.removeAttribute('disabled');
- this.mImagesOrig.removeAttribute('disabled');
- this.mEnableJS.removeAttribute('disabled');
- this.mEnableJava.removeAttribute('disabled');
- this.mEnableActiveX.removeAttribute('disabled');
-
- // Set control values
- var site = sc.getResourceForURI(this.currentURI.spec);
-
- var trustLevel;
- if (this.currentURI.scheme == 'http' ||
- this.currentURI.scheme == 'https' ||
- this.currentURI.scheme == 'ftp')
- {
- trustLevel = sc.getSiteTrustLevel(this.currentURI.spec);
- } else {
- trustLevel = 1; // local files, etc...
- }
-
- var useBrowserSettingDefault = false;
-
- // if we are forcing a default browser setting AND the site is not controlled
- var securityLevel;
- if(!this.prefService.getBoolPref("trustsettings.partnerratings.auto") && !sitecontrols.SCSVC.isControlledSite(this.currentURI.host)) {
- securityLevel = this.prefService.getCharPref("trustsettings.default");
- useBrowserSettingDefault = true;
- } else {
- securityLevel = sc.readSiteControlResource(site, 'securityLevel');
- }
-
- switch (trustLevel)
- {
- case -1:
- this.mTrustImg.setAttribute('trust', 'disabled');
- this.mTrustDeck.selectedIndex = 3;
- if(!sitecontrols.SCSVC.isControlledSite(this.currentURI.host)) {
- securityLevel = this.prefService.getCharPref("trustsettings.default");
- useBrowserSettingDefault = true;
- }
- break;
- case 0:
- this.mTrustImg.setAttribute('trust', 'verified');
- this.mTrustDeck.selectedIndex = 0;
- break;
- case 1:
- this.mTrustImg.setAttribute('trust', 'notVerified');
- this.mTrustDeck.selectedIndex = 1;
- break;
- case 2:
- default:
- this.mTrustImg.setAttribute('trust', 'warning');
- this.mTrustDeck.selectedIndex = 2;
- break;
- }
-
- switch (securityLevel)
- {
- case 'Low':
- this.mCustomRadioBox.setAttribute('hidden', 'true');
- this.mTrustRadioGroup.selectedItem = this.mTrustRadio;
- break;
- case 'Medium':
- this.mCustomRadioBox.setAttribute('hidden', 'true');
- this.mTrustRadioGroup.selectedItem = this.mStandardRadio;
- break;
- case 'Custom':
- this.mCustomRadioBox.removeAttribute('hidden');
- this.mTrustRadioGroup.selectedItem = this.mCustomRadio;
- break;
- case 'High':
- default:
- this.mCustomRadioBox.setAttribute('hidden', 'true');
- this.mTrustRadioGroup.selectedItem = this.mCautionRadio;
- break;
- }
-
- // If Trust settings is turned off (i.e. trustsettings.partnerratings = false) AND
- // the url is not controlled, we should use the default given by
- // trustsettings.default
- if(useBrowserSettingDefault) {
- switch (securityLevel)
- {
- case 'Low':
- site = sitecontrols.RDF.GetResource(sitecontrols.SC_VERIFIED_DEFAULT);
- break;
- case 'Medium':
- site = sitecontrols.RDF.GetResource(sitecontrols.SC_NOT_VERIFIED_DEFAULT);
- break;
- case 'High':
- default:
- site = sitecontrols.RDF.GetResource(sitecontrols.SC_WARNING_DEFAULT);
- break;
- }
- }
-
- // set title
- if (site.Value == sitecontrols.SC_LOCAL) {
- this.mSiteName.setAttribute('value', sc.readSiteControlResource(site, 'title'));
- } else {
- this.mSiteName.setAttribute('value', this.currentURI.host);
- }
-
- this.mTitleDeck.selectedIndex = 0;
-
- var engine = sc.readSiteControlResource(site, 'displayEngine');
- var jsAndVBScriptDeck = document.getElementById('jsAndVBScriptDeck');
- if (engine == 'Gecko') {
- this.mTrustEngine.selectedIndex = 0;
- this.mAdvEngine.selectedIndex = 0;
- this.mAllowCookies.removeAttribute('disabled');
- this.mCookiesOrig.removeAttribute('disabled');
- jsAndVBScriptDeck.selectedIndex = 0;
- } else {
- this.mTrustEngine.selectedIndex = 1;
- this.mAdvEngine.selectedIndex = 1;
- this.mAllowCookies.setAttribute('disabled', 'true');
- this.mCookiesOrig.setAttribute('disabled', 'true');
- jsAndVBScriptDeck.selectedIndex = 1;
- }
- this.mAllowPopups.checked = eval(sc.readSiteControlResource(site, 'allowPopups'));
- this.mOpenPopupsInTab.checked = eval(sc.readSiteControlResource(site, 'requestedPopupsInTab'));
-
- this.mAllowImages.checked = eval(sc.readSiteControlResource(site, 'allowImages'));
-
- if (this.mTrustEngine.selectedIndex == 1) {
- this.mImagesOrig.checked = false;
- this.mImagesOrig.setAttribute('disabled', 'true');
- } else {
- this.mImagesOrig.checked = eval(sc.readSiteControlResource(site, 'imagesFromOrigOnly'));
- if(!this.mAllowImages.checked)
- this.mImagesOrig.setAttribute('disabled', 'true');
- }
-
- this.mAllowCookies.checked = eval(sc.readSiteControlResource(site, 'allowCookies'));
- this.mCookiesOrig.checked = eval(sc.readSiteControlResource(site, 'cookiesFromOrigOnly'));
- if (!this.mAllowCookies.checked)
- this.mCookiesOrig.setAttribute('disabled','true');
- this.mEnableJS.checked = eval(sc.readSiteControlResource(site, 'enableJavaScript'));
- this.mEnableJava.checked = eval(sc.readSiteControlResource(site, 'enableJava'));
- this.mEnableActiveX.checked = eval(sc.readSiteControlResource(site, 'enableActiveX'));
- if (this.mAdvEngine.value!='Trident') {
- this.mEnableActiveX.setAttribute('checked', 'false');
- this.mEnableActiveX.setAttribute('disabled','true');
- }
- } else {
- this.debug(' { NOT controllable: '+this.currentURI.spec+' }');
- // Not a controllable URI, so disable controls
- //this.mTitleDeck.selectedIndex = 1;
- this.mTrustImg.setAttribute('disabled','true');
- this.mTrustDeck.setAttribute('disabled','true');
- this.enableDisableSwitching(false);
- this.mAllowPopups.setAttribute('disabled','true');
- this.mOpenPopupsInTab.setAttribute('disabled','true');
- this.mAllowImages.setAttribute('disabled','true');
- this.mImagesOrig.setAttribute('disabled','true');
- this.mAllowCookies.setAttribute('disabled','true');
- this.mCookiesOrig.setAttribute('disabled','true');
- this.mEnableJS.setAttribute('disabled','true');
- this.mEnableJava.setAttribute('disabled','true');
- this.mEnableActiveX.setAttribute('disabled','true');
- this.debug(' done disabling fields');
- }
-
- // Uncheck disabled activeX checkbox if Gecko is engine.
- this.removeCheckFromDisabled();
- },
-
- // MERC - JCH: Ensure that disabled activeX checkbox is unchecked if Gecko applies.
- // See BLT bug #120260.
- removeCheckFromDisabled : function() {
-
- var uncheck = (this.mEnableActiveX.disabled && (this.mAdvEngine.value == 'Gecko'));
-
- if (uncheck)
- {
- this.mEnableActiveX.checked = false;
- }
- },
-
-
- enableDisableSwitching : function(enable) {
- this.debug('enableDisableSwitching('+enable+')');
- if (enable && !this.switchingEngines) {
- this.mTrustEngine.removeAttribute('disabled');
- this.mTrustGecko.removeAttribute('disabled');
- this.mTrustTrident.removeAttribute('disabled');
- this.mAdvEngine.removeAttribute('disabled');
- this.mAdvGecko.removeAttribute('disabled');
- this.mAdvTrident.removeAttribute('disabled');
- } else {
- this.mTrustEngine.setAttribute('disabled','true');
- this.mTrustGecko.setAttribute('disabled','true');
- this.mTrustTrident.setAttribute('disabled','true');
- this.mAdvEngine.setAttribute('disabled','true');
- this.mAdvGecko.setAttribute('disabled','true');
- this.mAdvTrident.setAttribute('disabled','true');
- setTimeout("scPopup.mTrustEngine.removeAttribute('disabled');", this.engineDisableDelay);
- setTimeout("scPopup.mTrustGecko.removeAttribute('disabled');", this.engineDisableDelay);
- setTimeout("scPopup.mTrustTrident.removeAttribute('disabled');", this.engineDisableDelay);
- setTimeout("scPopup.mAdvEngine.removeAttribute('disabled');", this.engineDisableDelay);
- setTimeout("scPopup.mAdvGecko.removeAttribute('disabled');", this.engineDisableDelay);
- setTimeout("scPopup.mAdvTrident.removeAttribute('disabled');", this.engineDisableDelay);
- }
- },
-
-
- onPopupShown : function(event) {
- this.debug('onPopupShown()');
- this.init();
- this.mTitleDeck.style.display='-moz-deck';
- this.mTabbox.style.display='-moz-box';
- this.mBtnBar.style.display='-moz-box';
- this.loadCurrentSite();
- this.findSecurityPartners();
- this.dirty = false;
- gBrowser.mCurrentTab.setAttribute("popupvisible", "true");
- },
-
-
- onPopupHidden : function(event) {
- this.mTitleDeck.style.display='none';
- this.mTabbox.style.display='none';
- this.mBtnBar.style.display='none';
- gBrowser.mCurrentTab.setAttribute("popupvisible", "false");
- if (this.dirty)
- BrowserReload();
- },
-
-
- addParent : function(fullURI, event) {
- if (!event.target.id) return;
-
- var tldArray = new Array();
-
- tldArray["AERO"] = "OK";
- tldArray["BIZ"] = "OK";
- tldArray["COM"] = "OK";
- tldArray["COOP"] = "OK";
- tldArray["EDU"] = "OK";
- tldArray["GOV"] = "OK";
- tldArray["INFO"] = "OK";
- tldArray["INT"] = "OK";
- tldArray["MIL"] = "OK";
- tldArray["MUSEUM"] = "OK";
- tldArray["NAME"] = "OK";
- tldArray["NET"] = "OK";
- tldArray["ORG"] = "OK";
- tldArray["PRO"] = "OK";
-
- // Remove any sub domains
- var host = sitecontrols.getStrippedHostFromURL(fullURI);
- if (host && (host != "")) {
- var reg = /.*\.([0-9a-zA-Z\-]+\.[0-9a-zA-Z\-]+)$/;
- if (reg.test(host)) {
- var ar = reg.exec(host);
- host = ar[1];
-
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
- if ((pattern != null) || (host && (host != "") && (host != pattern))) {
- // Just confirm that this is a normal top level domain (ie .com, .org... not .ca, .uk...)
- reg = /[0-9a-zA-Z\-]+\.([0-9a-zA-Z\-]+)$/;
- ar = reg.exec(host);
- var tldPart = ar[1].toUpperCase();
- if (tldArray[tldPart] == "OK") {
-
- var sc = sitecontrols.SCSVC;
- var site = sc.getResourceForURI(host);
- if (site.Value != sitecontrols.SC_LOCAL)
- {
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
- if ((pattern != null) || (host && (host != "") && (host != pattern))) {
- sitecontrols.SCSVC.addControlledSite(host);
- site = sitecontrols.SCSVC.getResourceForURI(host);
- }
- } else {
- return;
- }
-
- switch (event.target.id) {
-
- case 'scp_trust_gecko':
- case 'scp_trust_trident':
- sc.updateSiteControlResource(site, 'displayEngine', this.mTrustEngine.value);
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
- case 'scp_adv_gecko':
- case 'scp_adv_trident':
- sc.updateSiteControlResource(site, 'displayEngine', this.mAdvEngine.value);
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_allowPopups':
- sc.updateSiteControlResource(site, 'allowPopups',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_openPopupsInTab':
- sc.updateSiteControlResource(site, 'requestedPopupsInTab',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_allowImages':
- sc.updateSiteControlResource(site, 'allowImages',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_imagesFromOrigOnly':
- sc.updateSiteControlResource(site, 'imagesFromOrigOnly',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_allowPopupCount':
- sc.updateSiteControlResource(site, 'showBlockedCount',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_allowPopupSound':
- sc.updateSiteControlResource(site, 'playBlockedSound',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_allowCookies':
- sc.updateSiteControlResource(site, 'allowCookies',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_cookiesFromOrigOnly':
- sc.updateSiteControlResource(site, 'cookiesFromOrigOnly',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_enableJavaScript':
- sc.updateSiteControlResource(site, 'enableJavaScript',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_enableJava':
- sc.updateSiteControlResource(site, 'enableJava',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_enableActiveX':
- sc.updateSiteControlResource(site, 'enableActiveX',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- break;
-
- case 'scp_radio_trust':
- sitecontrols.setSecurityLevel(site, 'low');
- break;
-
- case 'scp_radio_standard':
- sitecontrols.setSecurityLevel(site, 'medium');
- break;
-
- case 'scp_radio_caution':
- sitecontrols.setSecurityLevel(site, 'high');
- break;
-
- }
- }
- }
- }
- }
- },
-
- onCommand : function(event) {
- this.debug('onCommand()');
- if (!event.target.id) return;
-
- var sc = sitecontrols.SCSVC;
-
- switch (event.target.id) {
-
- case 'scp_trust_gecko':
- case 'scp_trust_trident':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'displayEngine', this.mTrustEngine.value);
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- this.switchingEngines = true;
- this.enableDisableSwitching(false);
- BrowserReload();
-
- if (event.target.id == 'scp_trust_trident') {
- this.mAllowCookies.setAttribute('disabled', 'true');
- this.mCookiesOrig.setAttribute('disabled', 'true');
- sitecontrols.notifyUser('switch_to_ie');
- } else {
- this.mAllowCookies.removeAttribute('disabled');
- this.mCookiesOrig.removeAttribute('disabled');
- }
- break;
- case 'scp_adv_gecko':
- case 'scp_adv_trident':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'displayEngine', this.mAdvEngine.value);
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- this.switchingEngines = true;
- this.enableDisableSwitching(false);
- BrowserReload();
-
-
- if (event.target.id == 'scp_adv_trident') {
- sitecontrols.notifyUser('switch_to_ie');
- }
-
- break;
-
- case 'scp_allowPopups':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'allowPopups',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- //this.dirty = true;
- BrowserReload();
- break;
-
- case 'scp_openPopupsInTab':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'requestedPopupsInTab',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_allowImages':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'allowImages',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_imagesFromOrigOnly':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'imagesFromOrigOnly',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_allowPopupCount':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'showBlockedCount',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_allowPopupSound':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'playBlockedSound',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_allowCookies':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'allowCookies',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- if (!event.target.checked) sitecontrols.notifyUser('disable_cookies');
- break;
-
- case 'scp_cookiesFromOrigOnly':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'cookiesFromOrigOnly',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_enableJavaScript':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'enableJavaScript',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- if (!event.target.checked) sitecontrols.notifyUser('disable_javascript');
- break;
-
- case 'scp_enableJava':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'enableJava',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- break;
-
- case 'scp_enableActiveX':
- var site = this.ensureExplicitSiteControl();
- sc.updateSiteControlResource(site, 'enableActiveX',
- (event.target.checked) ? 'true' : 'false');
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
- BrowserReload();
- if (event.target.checked) sitecontrols.notifyUser('enable_activex');
- break;
-
- case 'scp_radio_trust':
- var site = this.ensureExplicitSiteControl();
- sitecontrols.setSecurityLevel(site, 'low');
- BrowserReload();
- break;
-
- case 'scp_radio_standard':
- var site = this.ensureExplicitSiteControl();
- sitecontrols.setSecurityLevel(site, 'medium');
- BrowserReload();
- break;
-
- case 'scp_radio_caution':
- var site = this.ensureExplicitSiteControl();
- sitecontrols.setSecurityLevel(site, 'high');
- BrowserReload();
- break;
-
- default:
- return;
- }
-
- this.addParent(this.currentURI.spec, event);
- this.loadCurrentSite();
- },
-
-
- ensureExplicitSiteControl : function() {
- var sc = sitecontrols.SCSVC;
- var site = sc.getResourceForURI(this.currentURI.spec);
- if (site.Value != sitecontrols.SC_LOCAL)
- {
- var host = sitecontrols.getStrippedHostFromURL(this.currentURI.spec);
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
- if ((pattern != null) || (host && (host != "") && (host != pattern))) {
- sitecontrols.SCSVC.addControlledSite(host);
- site = sitecontrols.SCSVC.getResourceForURI(host);
- }
- }
- return site;
- },
-
- manageSiteList : function() {
- this.close(document.getElementById('SiteControlsPopup'));
- openSiteControlPrefs();
- },
-
-
- close : function(elm) {
- while (elm.localName != 'popup')
- elm = elm.parentNode;
- elm.hidePopup();
- },
-
- debug : function(msg) {
- if (this.DEBUG)
- dump('sitecontrolsOverlay.js: '+msg+'\n');
- }
- };
-
-
- function showSiteControlsPopup(x, y) {
- var myTab = gBrowser.selectedTab;
- var siteControlPopup = document.getElementById('SiteControlsPopup');
- document.getElementById('SiteControlsPopup')
- .showPopup(myTab, -1, -1, "popup", "bottomleft", "topleft");
- }