示例#1
0
NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate)
{
  NeckoOriginAttributes attrs;
  attrs.SyncAttributesWithPrivateBrowsing(aPrivate);
  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, false, attrs);
  info.forget(aPrivate);
  return NS_OK;
}
示例#2
0
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;
}
示例#3
0
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;
}
示例#4
0
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);
}
示例#6
0
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);
}