SecurityOriginManager.js 1.5 KB

12345678
  1. export default class SecurityOriginManager extends SDK.SDKModel{constructor(target){super(target);this._mainSecurityOrigin='';this._unreachableMainSecurityOrigin='';this._securityOrigins=new Set();}
  2. updateSecurityOrigins(securityOrigins){const oldOrigins=this._securityOrigins;this._securityOrigins=securityOrigins;for(const origin of oldOrigins){if(!this._securityOrigins.has(origin)){this.dispatchEventToListeners(Events.SecurityOriginRemoved,origin);}}
  3. for(const origin of this._securityOrigins){if(!oldOrigins.has(origin)){this.dispatchEventToListeners(Events.SecurityOriginAdded,origin);}}}
  4. securityOrigins(){return this._securityOrigins.valuesArray();}
  5. mainSecurityOrigin(){return this._mainSecurityOrigin;}
  6. unreachableMainSecurityOrigin(){return this._unreachableMainSecurityOrigin;}
  7. setMainSecurityOrigin(securityOrigin,unreachableSecurityOrigin){this._mainSecurityOrigin=securityOrigin;this._unreachableMainSecurityOrigin=unreachableSecurityOrigin||null;this.dispatchEventToListeners(Events.MainSecurityOriginChanged,{mainSecurityOrigin:this._mainSecurityOrigin,unreachableMainSecurityOrigin:this._unreachableMainSecurityOrigin});}}
  8. export const Events={SecurityOriginAdded:Symbol('SecurityOriginAdded'),SecurityOriginRemoved:Symbol('SecurityOriginRemoved'),MainSecurityOriginChanged:Symbol('MainSecurityOriginChanged')};self.SDK=self.SDK||{};SDK=SDK||{};SDK.SecurityOriginManager=SecurityOriginManager;SDK.SecurityOriginManager.Events=Events;SDK.SDKModel.register(SDK.SecurityOriginManager,SDK.Target.Capability.None,false);