Browse Source

this fixes #489

pull/2/head
gorhill 9 years ago
parent
commit
65924d1be8
  1. 17
      platform/chromium/vapi-background.js
  2. 16
      platform/firefox/vapi-background.js
  3. 24
      src/js/cookies.js

17
platform/chromium/vapi-background.js

@ -840,13 +840,24 @@ vAPI.cookies = {};
/******************************************************************************/
vAPI.cookies.start = function() {
var reallyRemoved = {
'evicted': true,
'expired': true,
'explicit': true
};
var onChanged = function(changeInfo) {
var handler = changeInfo.removed ? this.onRemoved : this.onChanged;
if ( typeof handler !== 'function' ) {
if ( changeInfo.removed ) {
if ( reallyRemoved[changeInfo.cause] && typeof this.onRemoved === 'function' ) {
this.onRemoved(changeInfo.cookie);
}
return;
}
handler(changeInfo.cookie);
if ( typeof this.onChanged === 'function' ) {
this.onChanged(changeInfo.cookie);
}
};
chrome.cookies.onChanged.addListener(onChanged.bind(this));
};

16
platform/firefox/vapi-background.js

@ -3294,7 +3294,21 @@ vAPI.cookies.observe = function(subject, topic, reason) {
//if ( topic !== 'cookie-changed' && topic !== 'private-cookie-changed' ) {
// return;
//}
if ( reason === 'deleted' || subject instanceof Ci.nsICookie2 === false ) {
//
if ( reason === 'cleared' && typeof this.onAllRemoved === 'function' ) {
this.onAllRemoved();
return;
}
if ( subject === null ) {
return;
}
if ( subject instanceof Ci.nsICookie2 === false ) {
subject = subject.QueryInterface(Ci.nsICookie2);
}
if ( reason === 'deleted' ) {
if ( typeof this.onRemoved === 'function' ) {
this.onRemoved(new this.CookieEntry(subject));
}
return;
}
if ( typeof this.onChanged === 'function' ) {

24
src/js/cookies.js

@ -119,7 +119,6 @@ var removeCookieFromDict = function(cookieKey) {
if ( cookieEntryJunkyard.length < 25 ) {
cookieEntryJunkyard.push(cookieEntry.unset());
}
// console.log('cookies.js/removeCookieFromDict()> removed cookie key "%s"', cookieKey);
return true;
};
@ -530,6 +529,29 @@ vAPI.cookies.onChanged = function(cookie) {
/******************************************************************************/
// Listen to any change in cookieland, we will update page stats accordingly.
vAPI.cookies.onRemoved = function(cookie) {
var cookieKey = cookieKeyFromCookie(cookie);
if ( removeCookieFromDict(cookieKey) ) {
µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey));
}
};
/******************************************************************************/
// Listen to any change in cookieland, we will update page stats accordingly.
vAPI.cookies.onAllRemoved = function() {
for ( var cookieKey in cookieDict ) {
if ( cookieDict.hasOwnProperty(cookieKey) && removeCookieFromDict(cookieKey) ) {
µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey));
}
}
};
/******************************************************************************/
vAPI.cookies.getAll(addCookiesToDict);
vAPI.cookies.start();

Loading…
Cancel
Save