NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate) { NeckoOriginAttributes attrs; attrs.SyncAttributesWithPrivateBrowsing(aPrivate); nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, false, attrs); info.forget(aPrivate); return NS_OK; }
NS_IMETHODIMP LoadInfo::SetScriptableOriginAttributes(JSContext* aCx, JS::Handle<JS::Value> aOriginAttributes) { NeckoOriginAttributes attrs; if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { return NS_ERROR_INVALID_ARG; } mOriginAttributes = attrs; return NS_OK; }
NS_IMETHODIMP LoadContextInfoFactory::Custom(bool aPrivate, bool aAnonymous, JS::HandleValue aOriginAttributes, JSContext *cx, nsILoadContextInfo * *_retval) { NeckoOriginAttributes attrs; bool status = attrs.Init(cx, aOriginAttributes); NS_ENSURE_TRUE(status, NS_ERROR_FAILURE); nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(aPrivate, aAnonymous, attrs); info.forget(_retval); return NS_OK; }
MOZ_WARN_UNUSED_RESULT bool CookieServiceParent::GetOriginAttributesFromParams(const IPC::SerializedLoadContext &aLoadContext, NeckoOriginAttributes& aAttrs, bool& aIsPrivate) { aIsPrivate = false; DocShellOriginAttributes docShellAttrs; const char* error = NeckoParent::GetValidatedAppInfo(aLoadContext, Manager()->Manager(), docShellAttrs); if (error) { NS_WARNING(nsPrintfCString("CookieServiceParent: GetOriginAttributesFromParams: " "FATAL error: %s: KILLING CHILD PROCESS\n", error).get()); return false; } if (aLoadContext.IsPrivateBitValid()) { aIsPrivate = aLoadContext.mUsePrivateBrowsing; } aAttrs.InheritFromDocShellToNecko(docShellAttrs); return true; }
LoadContextInfo * GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous) { if (!aLoadContext) { return new LoadContextInfo(aIsAnonymous, NeckoOriginAttributes(nsILoadContextInfo::NO_APP_ID, false)); } DebugOnly<bool> pb = aLoadContext->UsePrivateBrowsing(); DocShellOriginAttributes doa; aLoadContext->GetOriginAttributes(doa); MOZ_ASSERT(pb == (doa.mPrivateBrowsingId > 0)); NeckoOriginAttributes noa; noa.InheritFromDocShellToNecko(doa); return new LoadContextInfo(aIsAnonymous, noa); }
LoadContextInfo * GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous) { if (!aLoadContext) { return new LoadContextInfo(false, aIsAnonymous, NeckoOriginAttributes(nsILoadContextInfo::NO_APP_ID, false)); } bool pb = aLoadContext->UsePrivateBrowsing(); DocShellOriginAttributes doa; aLoadContext->GetOriginAttributes(doa); doa.SyncAttributesWithPrivateBrowsing(pb); NeckoOriginAttributes noa; noa.InheritFromDocShellToNecko(doa); return new LoadContextInfo(pb, aIsAnonymous, noa); }