Fixed some minor errors in cookieStore / cookieSyncCore (still getting used to the getter idiom in javascript -- had too many underscores). Syncing cookies now works in as much as it can upload all cookies to the server without raising any exceptions; now to see if it can download and merge cookies on the other side...

This commit is contained in:
jono@jono-gibbon-laptop 2008-04-01 17:51:10 -07:00
parent b405d397ce
commit 4ad1b9c94f
2 changed files with 20 additions and 12 deletions

View File

@ -781,9 +781,10 @@ CookieStore.prototype = {
// in order to sync with the server.
this._log.info("CookieStore got createCommand: " + command );
if (this._cookieManager == null )
throw "Cookie manager is null in CookieStore._createCommand.";
// this assumes command.data fits the nsICookie2 interface
this.__cookieManager.add( command.data.host,
this._cookieManager.add( command.data.host,
command.data.path,
command.data.name,
command.data.value,
@ -804,6 +805,8 @@ CookieStore.prototype = {
// http://developer.mozilla.org/en/docs/nsICookieManager
// the last argument is "always block cookies from this domain?"
// and the answer is "no".
if (this._cookieManager == null )
throw "Cookie manager is null in CookieStore._removeCommand.";
this._cookieManager.remove( command.data.host,
command.data.name,
command.data.path,
@ -825,7 +828,9 @@ CookieStore.prototype = {
// values are sub-dictionaries containing all cookie fields.
let items = {};
var iter = this.__cookieManager.enumerator;
if (this._cookieManager == null )
throw "Cookie manager is null in CookieStore.wrap.";
var iter = this._cookieManager.enumerator;
while (iter.hasMoreElements()){
var cookie = iter.getNext();
if (cookie instanceof Ci.nsICookie){
@ -859,8 +864,9 @@ CookieStore.prototype = {
// TODO are the semantics of this just wiping out an internal
// buffer, or am I supposed to wipe out all cookies from
// the browser itself for reals?
this.__cookieManager.removeAll()
if (this._cookieManager == null )
throw "Cookie manager is null in CookieStore.wipe";
this._cookieManager.removeAll()
},
resetGUIDs: function CookieStore_resetGUIDs() {

View File

@ -34,7 +34,7 @@
*
* ***** END LICENSE BLOCK ***** */
const EXPORTED_SYMBOLS = ['SyncCore', 'BookmarksSyncCore', 'HistorySyncCore', 'CookiesSyncCore'];
const EXPORTED_SYMBOLS = ['SyncCore', 'BookmarksSyncCore', 'HistorySyncCore', 'CookieSyncCore'];
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -431,10 +431,10 @@ HistorySyncCore.prototype = {
HistorySyncCore.prototype.__proto__ = new SyncCore();
function CookiesSyncCore() {
function CookieSyncCore() {
this._init();
}
CookiesSyncCore.prototype = {
CookieSyncCore.prototype = {
_logName: "CookieSync",
__cookieManager: null,
@ -464,10 +464,12 @@ CookiesSyncCore.prototype = {
// create a generic object to represent the cookie -- just has
// to implement nsICookie2 interface.
cookie = Object();
cookie.host = cookieArray[0]
cookie.path = cookieArray[1]
cookie.host = cookieArray[0];
cookie.path = cookieArray[1];
cookie.name = cookieArray[2];
return this.__cookieManager.findMatchingCookie( cookie, unused );
if (this._cookieManager == null )
throw "Cookie manager is null in CookieSyncCore._itemExists.";
return this._cookieManager.findMatchingCookie( cookie, unused );
},
_commandLike: function CSC_commandLike(a, b) {
@ -480,4 +482,4 @@ CookiesSyncCore.prototype = {
return false;
}
};
CookiesSyncCore.prototype.__proto__ = new SyncCore();
CookieSyncCore.prototype.__proto__ = new SyncCore();