Bug 1182347 - Migrate existing code away from .cookieJar. r=sicking,r=allstars.chh

This commit is contained in:
Bobby Holley 2015-07-09 12:14:26 -07:00
Родитель 8397689ce8
Коммит 23aa464074
4 изменённых файлов: 23 добавлений и 30 удалений

Просмотреть файл

@ -4851,22 +4851,16 @@ this.DOMApplicationRegistry = {
browserOnly: browserOnly,
QueryInterface: XPCOMUtils.generateQI([Ci.mozIApplicationClearPrivateDataParams])
};
this._clearCookieJarData(appId, browserOnly);
this._clearOriginData(appId, browserOnly);
this._notifyCategoryAndObservers(subject, "webapps-clear-data", null, msg);
},
_clearCookieJarData: function(appId, browserOnly) {
let browserCookieJar =
ChromeUtils.originAttributesToCookieJar({appId: appId,
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);
_clearOriginData: function(appId, browserOnly) {
let attributes = {appId: appId};
if (browserOnly) {
attributes.inBrowser = true;
}
this._notifyCategoryAndObservers(null, "clear-origin-data", JSON.stringify(attributes));
}
};

Просмотреть файл

@ -52,20 +52,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1168300
yield undefined;
let app = request.result;
let _topic = "clear-cookiejar-data";
let _topic = "clear-origin-data";
let observer = new Observer(_topic);
observer.onobserve = function(subject, topic, data, count) {
ok(topic == _topic, "unknown topic " + topic);
let cookieJar = data;
ok(cookieJar, "params.cookieJar should have value for an app.");
let props = Object.getOwnPropertyNames(JSON.parse(data));
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.
if (count == 2) {
ok(true);
observer.shutdown();
continueTest();
}
observer.shutdown();
continueTest();
};
request = navigator.mozApps.mgmt.uninstall(app);
@ -79,7 +76,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1168300
continueTest();
};
// we now wait for "clear-cookiejar-data" notifications and onuninstall
// we now wait for "clear-origin-data" notifications and onuninstall
// callback.
yield undefined;
yield undefined;

Просмотреть файл

@ -16,5 +16,5 @@ interface mozIApplicationClearPrivateDataParams : nsISupports
%{C++
#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_WIFIONLY = "wifiOnly";
Cu.import("resource://gre/modules/BrowserUtils.jsm");
Cu.import('resource://gre/modules/IndexedDBHelper.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -81,7 +82,7 @@ this.RequestSyncService = {
}).bind(this));
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);
this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
@ -117,7 +118,7 @@ this.RequestSyncService = {
}).bind(this));
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');
this.close();
@ -138,7 +139,7 @@ this.RequestSyncService = {
this.shutdown();
break;
case 'clear-cookiejar-data':
case 'clear-origin-data':
this.clearData(aData);
break;
@ -160,11 +161,12 @@ this.RequestSyncService = {
return;
}
let partialKey = aData;
let pattern = JSON.parse(aData);
let dbKeys = [];
for (let key in this._registrations) {
if (key.indexOf(partialKey) != 0) {
for (let key in this._registrations) {
let prin = BrowserUtils.principalFromOrigin(key);
if (!ChromeUtils.originAttributesMatchPattern(prin.originAttributes, pattern)) {
continue;
}
@ -199,7 +201,7 @@ this.RequestSyncService = {
// This method generates the key for the indexedDB object storage.
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.