summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/IDBFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/indexedDB/IDBFactory.cpp')
-rw-r--r--dom/indexedDB/IDBFactory.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp
index be34e1914d..81dce07d7e 100644
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -242,6 +242,12 @@ Result<RefPtr<IDBFactory>, nsresult> IDBFactory::CreateForMainThreadJSInternal(
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
+ nsresult rv = mgr->EnsureLocale();
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ IDB_REPORT_INTERNAL_ERR();
+ return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
+ };
+
return CreateInternal(aGlobal, std::move(aPrincipalInfo),
/* aInnerWindowID */ 0);
}
@@ -283,10 +289,17 @@ nsresult IDBFactory::AllowedForWindowInternal(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
- if (NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate())) {
+ IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
+ if (NS_WARN_IF(!mgr)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
+ nsresult rv = mgr->EnsureLocale();
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ IDB_REPORT_INTERNAL_ERR();
+ return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
+ };
+
StorageAccess access = StorageAllowedForWindow(aWindow);
// the factory callsite records whether the browser is in private browsing.
@@ -341,10 +354,16 @@ bool IDBFactory::AllowedForPrincipal(nsIPrincipal* aPrincipal,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
- if (NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate())) {
+ IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
+ if (NS_WARN_IF(!mgr)) {
return false;
}
+ nsresult rv = mgr->EnsureLocale();
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return false;
+ };
+
if (aPrincipal->IsSystemPrincipal()) {
if (aIsSystemPrincipal) {
*aIsSystemPrincipal = true;
@@ -573,19 +592,20 @@ RefPtr<IDBOpenDBRequest> IDBFactory::OpenInternal(
PersistenceType persistenceType;
- bool isInternal = principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo;
- if (!isInternal &&
+ bool isPersistent =
+ principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo;
+ if (!isPersistent &&
principalInfo.type() == PrincipalInfo::TContentPrincipalInfo) {
nsCString origin =
principalInfo.get_ContentPrincipalInfo().originNoSuffix();
- isInternal = QuotaManager::IsOriginInternal(origin);
+ isPersistent = QuotaManager::IsOriginInternal(origin);
}
const bool isPrivate =
principalInfo.type() == PrincipalInfo::TContentPrincipalInfo &&
principalInfo.get_ContentPrincipalInfo().attrs().mPrivateBrowsingId > 0;
- if (isInternal) {
+ if (isPersistent) {
// Chrome privilege and internal origins always get persistent storage.
persistenceType = PERSISTENCE_TYPE_PERSISTENT;
} else if (isPrivate) {
@@ -641,7 +661,8 @@ RefPtr<IDBOpenDBRequest> IDBFactory::OpenInternal(
mBackgroundActor = static_cast<BackgroundFactoryChild*>(
backgroundActor->SendPBackgroundIDBFactoryConstructor(
- actor, idbThreadLocal->GetLoggingInfo()));
+ actor, idbThreadLocal->GetLoggingInfo(),
+ IndexedDatabaseManager::GetLocale()));
if (NS_WARN_IF(!mBackgroundActor)) {
mBackgroundActorFailed = true;