tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsILoadContextInfo.idl (2442B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "nsISupports.idl"
      7 
      8 %{ C++
      9 #include "mozilla/BasePrincipal.h"
     10 %}
     11 native OriginAttributesNativePtr(const mozilla::OriginAttributes*);
     12 
     13 interface nsILoadContext;
     14 interface nsIDOMWindow;
     15 
     16 /**
     17 * Helper interface to carry informatin about the load context
     18 * encapsulating origin attributes and IsAnonymous, IsPrivite properties.
     19 * It shall be used where nsILoadContext cannot be used or is not
     20 * available.
     21 */
     22 
     23 [scriptable, builtinclass, uuid(555e2f8a-a1f6-41dd-88ca-ed4ed6b98a22)]
     24 interface nsILoadContextInfo : nsISupports
     25 {
     26  /**
     27   * Whether the context is in a Private Browsing mode
     28   */
     29  readonly attribute boolean isPrivate;
     30 
     31  /**
     32   * Whether the load is initiated as anonymous
     33   */
     34  readonly attribute boolean isAnonymous;
     35 
     36  /**
     37   * OriginAttributes hiding all the security context attributes
     38   */
     39  [implicit_jscontext]
     40  readonly attribute jsval originAttributes;
     41  [noscript, notxpcom, nostdcall, binaryname(OriginAttributesPtr)]
     42  OriginAttributesNativePtr binaryOriginAttributesPtr();
     43 
     44 %{C++
     45  /**
     46   * De-XPCOMed getters
     47   */
     48  bool IsPrivate()
     49  {
     50    bool pb;
     51    GetIsPrivate(&pb);
     52    return pb;
     53  }
     54 
     55  bool IsAnonymous()
     56  {
     57    bool anon;
     58    GetIsAnonymous(&anon);
     59    return anon;
     60  }
     61 
     62  bool Equals(nsILoadContextInfo *aOther)
     63  {
     64    return IsAnonymous() == aOther->IsAnonymous() &&
     65           *OriginAttributesPtr() == *aOther->OriginAttributesPtr();
     66  }
     67 %}
     68 };
     69 
     70 /**
     71 * Since OriginAttributes struct limits the implementation of
     72 * nsILoadContextInfo (that needs to be thread safe) to C++,
     73 * we need a scriptable factory to create instances of that
     74 * interface from JS.
     75 */
     76 [scriptable, uuid(c1c7023d-4318-4f99-8307-b5ccf0558793)]
     77 interface nsILoadContextInfoFactory : nsISupports
     78 {
     79  readonly attribute nsILoadContextInfo default;
     80  readonly attribute nsILoadContextInfo private;
     81  readonly attribute nsILoadContextInfo anonymous;
     82  [implicit_jscontext]
     83  nsILoadContextInfo custom(in boolean aAnonymous, in jsval aOriginAttributes);
     84  nsILoadContextInfo fromLoadContext(in nsILoadContext aLoadContext, in boolean aAnonymous);
     85  nsILoadContextInfo fromWindow(in nsIDOMWindow aWindow, in boolean aAnonymous);
     86 };