tor-browser

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

IdentityCredential.h (2544B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_IdentityCredential_h
      8 #define mozilla_dom_IdentityCredential_h
      9 
     10 #include "mozilla/IdentityCredentialStorageService.h"
     11 #include "mozilla/MozPromise.h"
     12 #include "mozilla/dom/CanonicalBrowsingContext.h"
     13 #include "mozilla/dom/Credential.h"
     14 #include "mozilla/dom/PWebIdentity.h"
     15 #include "nsICredentialChosenCallback.h"
     16 
     17 namespace mozilla::dom {
     18 
     19 // This is the primary starting point for FedCM in the platform.
     20 // This class is the implementation of the IdentityCredential object
     21 // that is the value returned from the navigator.credentials.get call
     22 // with an "identity" argument. It also includes static functions that
     23 // perform operations that are used in constructing the credential.
     24 class IdentityCredential final : public Credential {
     25  friend class mozilla::IdentityCredentialStorageService;
     26  friend class WindowGlobalChild;
     27 
     28 protected:
     29  ~IdentityCredential() override;
     30 
     31 public:
     32  explicit IdentityCredential(nsPIDOMWindowInner* aParent,
     33                              const IPCIdentityCredential& aOther);
     34 
     35  virtual JSObject* WrapObject(JSContext* aCx,
     36                               JS::Handle<JSObject*> aGivenProto) override;
     37 
     38  // This builds a value from an IPC-friendly version. This type is returned
     39  // to the caller of navigator.credentials.get, however we get an IPC friendly
     40  // version back from the main process to the content process.
     41  // This is a deep copy of the token, ID, and type.
     42  void CopyValuesFrom(const IPCIdentityCredential& aOther);
     43 
     44  // This is the inverse of CopyValuesFrom. Included for completeness.
     45  IPCIdentityCredential MakeIPCIdentityCredential() const;
     46 
     47  static already_AddRefed<Promise> Disconnect(
     48      const GlobalObject& aGlobal,
     49      const IdentityCredentialDisconnectOptions& aOptions, ErrorResult& aRv);
     50  // Getter and setter for the token member of this class
     51  void GetToken(nsACString& aToken) const;
     52  void SetToken(const nsACString& aToken);
     53  void GetConfigURL(nsACString& aConfigURL) const;
     54  void SetConfigURL(const nsACString& aConfigURL);
     55  bool IsAutoSelected() const;
     56 
     57 private:
     58  nsCString mToken;
     59  nsCString mConfigURL;
     60  bool mIsAutoSelected;
     61 };
     62 }  // namespace mozilla::dom
     63 
     64 #endif  // mozilla_dom_IdentityCredential_h