
Components.utils.import("resource://avg/Preferences.js");Components.utils.import("resource://avg/avgJsm.js");Components.utils.import("resource://avg/IOJsm.js");Components.utils.import("resource://gre/modules/AddonManager.jsm");var EXPORTED_SYMBOLS=["PasswordBox_avg"];var PasswordBox_avg={addonId:"firefox@passwordbox.com",addonIdAVG:"avg@toolbar",passwordBoxDomObj:null,pwdInstallGUID:"95B7759C-8C7F-4BF1-B163-73684A933233",init:function(domObj){var pwdInstallRegGUID=IORegistryModule_avg.ReadRegistryKey(IORegistryModule_avg.WIN_REG_ROOT.LOCAL_MACHINE,"SOFTWARE\\PasswordBox\\Updater","guid");if(this.pwdInstallGUID!==pwdInstallRegGUID){return}
this.passwordBoxDomObj=domObj;var hiddenState=domObj.getAttribute("hidden");this.setAddonState(hiddenState);AddonManager.addAddonListener(this);Preferences.observe(Domains_avg.PartnerID+".userPreferences.toolbarItems",this.prefObserver);},setAddonState:function(hiddenState){var pwdBoxUserDisabled=Preferences.get(Domains_avg.PartnerID+".userPreferences.pwdBoxUserDisabled",false);if(hiddenState=="false"){if(!pwdBoxUserDisabled){this.enable();}else{this.disable();}}else{PasswordBox_avg._pwdBoxDisableByAVG=true;this.disable();}},prefObserver:function(prefValue){if(typeof prefValue==="undefined"||prefValue===""){return;}
prefValue=JSON.parse(prefValue);var fid=PasswordBox_avg.passwordBoxDomObj.getAttribute("fid");var visible=prefValue[fid]["visible"];var hiddenState="false";if(!visible){hiddenState="true";}
PasswordBox_avg.setAddonState(hiddenState);PasswordBox_avg.passwordBoxDomObj.setAttribute("hidden",hiddenState);},enable:function(){AddonManager.getAddonByID(this.addonId,function(addon){if(!addon.isActive){addon.userDisabled=false;}});},disable:function(){AddonManager.getAddonByID(this.addonId,function(addon){if(addon.isActive){addon.userDisabled=true;}});},_pwdBoxDisableByAVG:false,onDisabling:function(addon){if(addon.id==PasswordBox_avg.addonId){if(!PasswordBox_avg._pwdBoxDisableByAVG){Preferences.set(Domains_avg.PartnerID+".userPreferences.pwdBoxUserDisabled",true);}
LogAddonMsgs_avg.CreateDumpLogString("Add-on disabled: "+PasswordBox_avg.addonId);}else if(addon.id==PasswordBox_avg.addonIdAVG){PasswordBox_avg._pwdBoxDisableByAVG=true;PasswordBox_avg.disable();}},onEnabling:function(addon){if(addon.id==PasswordBox_avg.addonId){Preferences.set(Domains_avg.PartnerID+".userPreferences.pwdBoxUserDisabled",false);}}};