Bug 827050 - Clear cookies and stored data in the browser clears remember my choice permissions for PROMPT_ACTION WebAPIs r=sicking

This commit is contained in:
Andrea Marchesini 2013-01-07 11:31:21 +01:00
parent 14d96b17ec
commit 89ec9d93a7
2 changed files with 38 additions and 0 deletions

View File

@ -338,6 +338,8 @@ nsPermissionManager::Init()
if (NS_SUCCEEDED(rv)) {
mObserverService->AddObserver(this, "profile-before-change", true);
mObserverService->AddObserver(this, "profile-do-change", true);
mObserverService->AddObserver(this, "webapps-clear-data", true);
}
if (IsChildProcess()) {
@ -1126,6 +1128,29 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
// the profile has already changed; init the db from the new location
InitDB(false);
} else if (!nsCRT::strcmp(aTopic, "webapps-clear-data")) {
nsCOMPtr<mozIApplicationClearPrivateDataParams> params =
do_QueryInterface(aSubject);
if (!params) {
NS_ERROR("'webapps-clear-data' notification's subject should be a mozIApplicationClearPrivateDataParams");
return NS_ERROR_UNEXPECTED;
}
uint32_t appId;
nsresult rv = params->GetAppId(&appId);
NS_ENSURE_SUCCESS(rv, rv);
bool browserOnly;
rv = params->GetBrowserOnly(&browserOnly);
NS_ENSURE_SUCCESS(rv, rv);
// If browserOnly if false, it probably means that we are disinstalling
// the app, so we can just ignore this event.
if (!browserOnly) {
return NS_OK;
}
return RemovePermissionsForApp(appId, true);
}
return NS_OK;
@ -1157,6 +1182,12 @@ nsPermissionManager::GetPermissionsForApp(nsPermissionManager::PermissionHashKey
NS_IMETHODIMP
nsPermissionManager::RemovePermissionsForApp(uint32_t aAppId)
{
return RemovePermissionsForApp(aAppId, false);
}
nsresult
nsPermissionManager::RemovePermissionsForApp(uint32_t aAppId, bool aBrowserOnly)
{
ENSURE_NOT_CHILD_PROCESS;
NS_ENSURE_ARG(aAppId != nsIScriptSecurityManager::NO_APP_ID);
@ -1173,6 +1204,11 @@ nsPermissionManager::RemovePermissionsForApp(uint32_t aAppId)
sql.AppendLiteral("DELETE FROM moz_hosts WHERE appId=");
sql.AppendInt(aAppId);
if (aBrowserOnly) {
sql.AppendLiteral(" AND isInBrowserElement=");
sql.AppendInt(true);
}
nsCOMPtr<mozIStorageAsyncStatement> removeStmt;
nsresult rv = mDBConn->CreateAsyncStatement(sql, getter_AddRefs(removeStmt));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -249,6 +249,8 @@ private:
uint32_t aAppId,
bool aIsInBrowserElement);
nsresult RemovePermissionsForApp(uint32_t aAppId, bool aBrowserOnly);
nsresult RemoveExpiredPermissionsForApp(uint32_t aAppId);
/**