зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1017758
- Use infallible getters for appId/isInBrowserElement/unknownAppId; r=bz
This commit is contained in:
Родитель
2eb9170e70
Коммит
f994d03624
|
@ -6685,11 +6685,7 @@ nsDocShell::DoAppRedirectIfNeeded(nsIURI* aURI,
|
|||
nsIDocShellLoadInfo* aLoadInfo,
|
||||
bool aFirstParty)
|
||||
{
|
||||
uint32_t appId;
|
||||
nsresult rv = GetAppId(&appId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t appId = nsIDocShell::GetAppId();
|
||||
|
||||
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
|
||||
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
|
@ -6697,7 +6693,7 @@ nsDocShell::DoAppRedirectIfNeeded(nsIURI* aURI,
|
|||
do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(appsService, "No AppsService available");
|
||||
nsCOMPtr<nsIURI> redirect;
|
||||
rv = appsService->GetRedirect(appId, aURI, getter_AddRefs(redirect));
|
||||
nsresult rv = appsService->GetRedirect(appId, aURI, getter_AddRefs(redirect));
|
||||
if (NS_SUCCEEDED(rv) && redirect) {
|
||||
rv = LoadURI(redirect, aLoadInfo, nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
aFirstParty);
|
||||
|
@ -13845,9 +13841,7 @@ nsDocShell::GetAppId(uint32_t* aAppId)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetAppManifestURL(nsAString& aAppManifestURL)
|
||||
{
|
||||
uint32_t appId;
|
||||
GetAppId(&appId);
|
||||
|
||||
uint32_t appId = nsIDocShell::GetAppId();
|
||||
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
|
||||
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
nsCOMPtr<nsIAppsService> appsService =
|
||||
|
|
|
@ -2655,15 +2655,8 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
uint32_t appId;
|
||||
nsresult rv = NodePrincipal()->GetAppId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(appId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
|
||||
"Document should never have UNKNOWN_APP_ID");
|
||||
}
|
||||
#endif
|
||||
MOZ_ASSERT(NodePrincipal()->GetAppId() != nsIScriptSecurityManager::UNKNOWN_APP_ID,
|
||||
"Document should never have UNKNOWN_APP_ID");
|
||||
|
||||
MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_UNINITIALIZED,
|
||||
"Bad readyState");
|
||||
|
@ -2864,16 +2857,14 @@ nsDocument::InitCSP(nsIChannel* aChannel)
|
|||
if (appStatus != nsIPrincipal::APP_STATUS_NOT_INSTALLED) {
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
if (appsService) {
|
||||
uint32_t appId = 0;
|
||||
if (NS_SUCCEEDED(principal->GetAppId(&appId))) {
|
||||
appsService->GetManifestCSPByLocalId(appId, appManifestCSP);
|
||||
if (!appManifestCSP.IsEmpty()) {
|
||||
applyAppManifestCSP = true;
|
||||
}
|
||||
appsService->GetDefaultCSPByLocalId(appId, appDefaultCSP);
|
||||
if (!appDefaultCSP.IsEmpty()) {
|
||||
applyAppDefaultCSP = true;
|
||||
}
|
||||
uint32_t appId = principal->GetAppId();
|
||||
appsService->GetManifestCSPByLocalId(appId, appManifestCSP);
|
||||
if (!appManifestCSP.IsEmpty()) {
|
||||
applyAppManifestCSP = true;
|
||||
}
|
||||
appsService->GetDefaultCSPByLocalId(appId, appDefaultCSP);
|
||||
if (!appDefaultCSP.IsEmpty()) {
|
||||
applyAppDefaultCSP = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8438,13 +8438,8 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::SubjectPrincipal();
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
uint32_t appId;
|
||||
if (NS_WARN_IF(NS_FAILED(principal->GetAppId(&appId))))
|
||||
return;
|
||||
|
||||
bool isInBrowser;
|
||||
if (NS_WARN_IF(NS_FAILED(principal->GetIsInBrowserElement(&isInBrowser))))
|
||||
return;
|
||||
uint32_t appId = principal->GetAppId();
|
||||
bool isInBrowser = principal->GetIsInBrowserElement();
|
||||
|
||||
// Create a nsIPrincipal inheriting the app/browser attributes from the
|
||||
// caller.
|
||||
|
|
|
@ -166,19 +166,9 @@ CreateScopeKey(nsIPrincipal* aPrincipal,
|
|||
key.Append(nsPrintfCString(":%d", port));
|
||||
}
|
||||
|
||||
bool unknownAppId;
|
||||
rv = aPrincipal->GetUnknownAppId(&unknownAppId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!unknownAppId) {
|
||||
uint32_t appId;
|
||||
rv = aPrincipal->GetAppId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isInBrowserElement;
|
||||
rv = aPrincipal->GetIsInBrowserElement(&isInBrowserElement);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aPrincipal->GetUnknownAppId()) {
|
||||
uint32_t appId = aPrincipal->GetAppId();
|
||||
bool isInBrowserElement = aPrincipal->GetIsInBrowserElement();
|
||||
if (appId == nsIScriptSecurityManager::NO_APP_ID && !isInBrowserElement) {
|
||||
aKey.Assign(key);
|
||||
return NS_OK;
|
||||
|
@ -221,19 +211,9 @@ CreateQuotaDBKey(nsIPrincipal* aPrincipal,
|
|||
|
||||
CreateReversedDomain(eTLDplusOne, subdomainsDBKey);
|
||||
|
||||
bool unknownAppId;
|
||||
rv = aPrincipal->GetUnknownAppId(&unknownAppId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!unknownAppId) {
|
||||
uint32_t appId;
|
||||
rv = aPrincipal->GetAppId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isInBrowserElement;
|
||||
rv = aPrincipal->GetIsInBrowserElement(&isInBrowserElement);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aPrincipal->GetUnknownAppId()) {
|
||||
uint32_t appId = aPrincipal->GetAppId();
|
||||
bool isInBrowserElement = aPrincipal->GetIsInBrowserElement();
|
||||
if (appId == nsIScriptSecurityManager::NO_APP_ID && !isInBrowserElement) {
|
||||
aKey.Assign(subdomainsDBKey);
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче