зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1182347 - Migrate existing code away from .cookieJar. r=sicking,r=allstars.chh
This commit is contained in:
Родитель
8397689ce8
Коммит
23aa464074
|
@ -4851,22 +4851,16 @@ this.DOMApplicationRegistry = {
|
||||||
browserOnly: browserOnly,
|
browserOnly: browserOnly,
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.mozIApplicationClearPrivateDataParams])
|
QueryInterface: XPCOMUtils.generateQI([Ci.mozIApplicationClearPrivateDataParams])
|
||||||
};
|
};
|
||||||
this._clearCookieJarData(appId, browserOnly);
|
this._clearOriginData(appId, browserOnly);
|
||||||
this._notifyCategoryAndObservers(subject, "webapps-clear-data", null, msg);
|
this._notifyCategoryAndObservers(subject, "webapps-clear-data", null, msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
_clearCookieJarData: function(appId, browserOnly) {
|
_clearOriginData: function(appId, browserOnly) {
|
||||||
let browserCookieJar =
|
let attributes = {appId: appId};
|
||||||
ChromeUtils.originAttributesToCookieJar({appId: appId,
|
if (browserOnly) {
|
||||||
inBrowser: true});
|
attributes.inBrowser = true;
|
||||||
this._notifyCategoryAndObservers(null, "clear-cookiejar-data", browserCookieJar);
|
|
||||||
|
|
||||||
if (!browserOnly) {
|
|
||||||
let appCookieJar =
|
|
||||||
ChromeUtils.originAttributesToCookieJar({appId: appId,
|
|
||||||
inBrowser: false});
|
|
||||||
this._notifyCategoryAndObservers(null, "clear-cookiejar-data", appCookieJar);
|
|
||||||
}
|
}
|
||||||
|
this._notifyCategoryAndObservers(null, "clear-origin-data", JSON.stringify(attributes));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,20 +52,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1168300
|
||||||
yield undefined;
|
yield undefined;
|
||||||
let app = request.result;
|
let app = request.result;
|
||||||
|
|
||||||
let _topic = "clear-cookiejar-data";
|
let _topic = "clear-origin-data";
|
||||||
let observer = new Observer(_topic);
|
let observer = new Observer(_topic);
|
||||||
observer.onobserve = function(subject, topic, data, count) {
|
observer.onobserve = function(subject, topic, data, count) {
|
||||||
ok(topic == _topic, "unknown topic " + topic);
|
ok(topic == _topic, "unknown topic " + topic);
|
||||||
|
|
||||||
let cookieJar = data;
|
let props = Object.getOwnPropertyNames(JSON.parse(data));
|
||||||
ok(cookieJar, "params.cookieJar should have value for an app.");
|
is(props.length, 1, "pattern should have one property");
|
||||||
|
is(props[0], 'appId', "pattern property should be appId");
|
||||||
|
|
||||||
// should receive 2 notifications when an app is uninstalled.
|
observer.shutdown();
|
||||||
if (count == 2) {
|
continueTest();
|
||||||
ok(true);
|
|
||||||
observer.shutdown();
|
|
||||||
continueTest();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
request = navigator.mozApps.mgmt.uninstall(app);
|
request = navigator.mozApps.mgmt.uninstall(app);
|
||||||
|
@ -79,7 +76,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1168300
|
||||||
continueTest();
|
continueTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
// we now wait for "clear-cookiejar-data" notifications and onuninstall
|
// we now wait for "clear-origin-data" notifications and onuninstall
|
||||||
// callback.
|
// callback.
|
||||||
yield undefined;
|
yield undefined;
|
||||||
yield undefined;
|
yield undefined;
|
||||||
|
|
|
@ -16,5 +16,5 @@ interface mozIApplicationClearPrivateDataParams : nsISupports
|
||||||
|
|
||||||
%{C++
|
%{C++
|
||||||
#define TOPIC_WEB_APP_CLEAR_DATA "webapps-clear-data"
|
#define TOPIC_WEB_APP_CLEAR_DATA "webapps-clear-data"
|
||||||
#define TOPIC_CLEAR_COOKIEJAR_DATA "clear-cookiejar-data"
|
#define TOPIC_CLEAR_ORIGIN_DATA "clear-origin-data"
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -20,6 +20,7 @@ const RSYNC_STATE_ENABLED = "enabled";
|
||||||
const RSYNC_STATE_DISABLED = "disabled";
|
const RSYNC_STATE_DISABLED = "disabled";
|
||||||
const RSYNC_STATE_WIFIONLY = "wifiOnly";
|
const RSYNC_STATE_WIFIONLY = "wifiOnly";
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/BrowserUtils.jsm");
|
||||||
Cu.import('resource://gre/modules/IndexedDBHelper.jsm');
|
Cu.import('resource://gre/modules/IndexedDBHelper.jsm');
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
@ -81,7 +82,7 @@ this.RequestSyncService = {
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
Services.obs.addObserver(this, 'xpcom-shutdown', false);
|
Services.obs.addObserver(this, 'xpcom-shutdown', false);
|
||||||
Services.obs.addObserver(this, 'clear-cookiejar-data', false);
|
Services.obs.addObserver(this, 'clear-origin-data', false);
|
||||||
Services.obs.addObserver(this, 'wifi-state-changed', false);
|
Services.obs.addObserver(this, 'wifi-state-changed', false);
|
||||||
|
|
||||||
this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
|
this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
|
||||||
|
@ -117,7 +118,7 @@ this.RequestSyncService = {
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
Services.obs.removeObserver(this, 'xpcom-shutdown');
|
Services.obs.removeObserver(this, 'xpcom-shutdown');
|
||||||
Services.obs.removeObserver(this, 'clear-cookiejar-data');
|
Services.obs.removeObserver(this, 'clear-origin-data');
|
||||||
Services.obs.removeObserver(this, 'wifi-state-changed');
|
Services.obs.removeObserver(this, 'wifi-state-changed');
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
|
@ -138,7 +139,7 @@ this.RequestSyncService = {
|
||||||
this.shutdown();
|
this.shutdown();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'clear-cookiejar-data':
|
case 'clear-origin-data':
|
||||||
this.clearData(aData);
|
this.clearData(aData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -160,11 +161,12 @@ this.RequestSyncService = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let partialKey = aData;
|
let pattern = JSON.parse(aData);
|
||||||
let dbKeys = [];
|
let dbKeys = [];
|
||||||
|
|
||||||
for (let key in this._registrations) {
|
for (let key in this._registrations) {
|
||||||
if (key.indexOf(partialKey) != 0) {
|
let prin = BrowserUtils.principalFromOrigin(key);
|
||||||
|
if (!ChromeUtils.originAttributesMatchPattern(prin.originAttributes, pattern)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ this.RequestSyncService = {
|
||||||
|
|
||||||
// This method generates the key for the indexedDB object storage.
|
// This method generates the key for the indexedDB object storage.
|
||||||
principalToKey: function(aPrincipal) {
|
principalToKey: function(aPrincipal) {
|
||||||
return aPrincipal.cookieJar + '|' + aPrincipal.origin;
|
return aPrincipal.origin;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add a task to the _registrations map and create the timer if it's needed.
|
// Add a task to the _registrations map and create the timer if it's needed.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче