зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1483440 - Part 1 - Remove purge-domain-data, add purge-sessionStorage notification. r=baku
The browser:purge-domain-data notification had two different intentions, - to clear session store information and - to clear all localStorage and sessionStorage Firing the notification accomplished both at the same time, which from a user perspective is of course totally not understandable. This commit removes purge-domain-data in favor of the two distinct purge-localStorage and purge-sessionStorage events. This gives callers more granular choice on what they want to clear. Differential Revision: https://phabricator.services.mozilla.com/D16460 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5008c56fe4
Коммит
ee15b3664f
|
@ -395,6 +395,11 @@ nsresult LocalStorageManager::Observe(const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, "browser:purge-sessionStorage")) {
|
||||
// This is only meant for SessionStorageManager.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Clear from caches everything that has been stored
|
||||
// while in session-only mode
|
||||
if (!strcmp(aTopic, "session-only-cleared")) {
|
||||
|
@ -402,13 +407,6 @@ nsresult LocalStorageManager::Observe(const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Clear everything (including so and pb data) from caches and database
|
||||
// for the gived domain and subdomains.
|
||||
if (!strcmp(aTopic, "domain-data-cleared")) {
|
||||
ClearCaches(LocalStorageCache::kUnloadComplete, pattern, aOriginScope);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Clear all private-browsing caches
|
||||
if (!strcmp(aTopic, "private-browsing-data-cleared")) {
|
||||
ClearCaches(LocalStorageCache::kUnloadPrivate, pattern, EmptyCString());
|
||||
|
|
|
@ -243,8 +243,8 @@ nsresult SessionStorageManager::Observe(
|
|||
}
|
||||
|
||||
// Clear everything (including so and pb data) from caches and database
|
||||
// for the gived domain and subdomains.
|
||||
if (!strcmp(aTopic, "domain-data-cleared")) {
|
||||
// for the given domain and subdomains.
|
||||
if (!strcmp(aTopic, "browser:purge-sessionStorage")) {
|
||||
ClearStorages(eAll, pattern, aOriginScope);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,10 +59,10 @@ nsresult StorageObserver::Init() {
|
|||
obs->AddObserver(sSelf, kStartupTopic, true);
|
||||
obs->AddObserver(sSelf, "cookie-changed", true);
|
||||
obs->AddObserver(sSelf, "perm-changed", true);
|
||||
obs->AddObserver(sSelf, "browser:purge-domain-data", true);
|
||||
obs->AddObserver(sSelf, "last-pb-context-exited", true);
|
||||
obs->AddObserver(sSelf, "clear-origin-attributes-data", true);
|
||||
obs->AddObserver(sSelf, "extension:purge-localStorage", true);
|
||||
obs->AddObserver(sSelf, "browser:purge-sessionStorage", true);
|
||||
|
||||
// Shutdown
|
||||
obs->AddObserver(sSelf, "profile-after-change", true);
|
||||
|
@ -135,8 +135,8 @@ void StorageObserver::NoteBackgroundThread(nsIEventTarget* aBackgroundThread) {
|
|||
mBackgroundThread = aBackgroundThread;
|
||||
}
|
||||
|
||||
nsresult StorageObserver::ClearMatchingOrigin(const char16_t* aData,
|
||||
nsACString& aOriginScope) {
|
||||
nsresult StorageObserver::GetOriginScope(const char16_t* aData,
|
||||
nsACString& aOriginScope) {
|
||||
nsresult rv;
|
||||
|
||||
NS_ConvertUTF16toUTF8 domain(aData);
|
||||
|
@ -162,17 +162,6 @@ nsresult StorageObserver::ClearMatchingOrigin(const char16_t* aData,
|
|||
return rv;
|
||||
}
|
||||
|
||||
if (!NextGenLocalStorageEnabled()) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
StorageDBChild* storageChild = StorageDBChild::GetOrCreate();
|
||||
if (NS_WARN_IF(!storageChild)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
storageChild->SendClearMatchingOrigin(originScope);
|
||||
}
|
||||
}
|
||||
|
||||
aOriginScope = originScope;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -309,11 +298,21 @@ StorageObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
if (aData) {
|
||||
nsCString originScope;
|
||||
rv = ClearMatchingOrigin(aData, originScope);
|
||||
|
||||
rv = GetOriginScope(aData, originScope);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
StorageDBChild* storageChild = StorageDBChild::GetOrCreate();
|
||||
if (NS_WARN_IF(!storageChild)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
storageChild->SendClearMatchingOrigin(originScope);
|
||||
}
|
||||
|
||||
Notify(topic, EmptyString(), originScope);
|
||||
} else {
|
||||
StorageDBChild* storageChild = StorageDBChild::GetOrCreate();
|
||||
|
@ -333,16 +332,18 @@ StorageObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Clear everything (including so and pb data) from caches and database
|
||||
// for the given domain and subdomains.
|
||||
if (!strcmp(aTopic, "browser:purge-domain-data")) {
|
||||
nsCString originScope;
|
||||
rv = ClearMatchingOrigin(aData, originScope);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (!strcmp(aTopic, "browser:purge-sessionStorage")) {
|
||||
if (aData) {
|
||||
nsCString originScope;
|
||||
rv = GetOriginScope(aData, originScope);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
Notify("domain-data-cleared", EmptyString(), originScope);
|
||||
Notify(aTopic, EmptyString(), originScope);
|
||||
} else {
|
||||
Notify(aTopic, EmptyString(), EmptyCString());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class StorageObserver : public nsIObserver, public nsSupportsWeakReference {
|
|||
private:
|
||||
virtual ~StorageObserver() {}
|
||||
|
||||
nsresult ClearMatchingOrigin(const char16_t* aData, nsACString& aOriginScope);
|
||||
nsresult GetOriginScope(const char16_t* aData, nsACString& aOriginScope);
|
||||
|
||||
static void TestingPrefChanged(const char* aPrefName, void* aClosure);
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ function localStorageClearDomain(domain, callback)
|
|||
return;
|
||||
}
|
||||
|
||||
os().notifyObservers(null, "browser:purge-domain-data", domain);
|
||||
os().notifyObservers(null, "extension:purge-localStorage", domain);
|
||||
SimpleTest.executeSoon(function () {
|
||||
callback();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче