tor-browser

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

Windows11LimitedAccessFeatures.h (2170B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      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 #ifndef SHELL_WINDOWS11LIMITEDACCESSFEATURES_H__
      7 #define SHELL_WINDOWS11LIMITEDACCESSFEATURES_H__
      8 
      9 #include "nsISupportsImpl.h"
     10 #include "nsString.h"
     11 #include "mozilla/Result.h"
     12 #include "mozilla/ResultVariant.h"
     13 #include <winerror.h>
     14 #include <windows.h>  // for HRESULT
     15 #include "mozilla/DefineEnum.h"
     16 #include <winerror.h>
     17 
     18 MOZ_DEFINE_ENUM_CLASS(Win11LimitedAccessFeatureType, (Taskbar));
     19 
     20 /**
     21 * Class to manage unlocking limited access features on Windows 11.
     22 * Unless stubbing for testing purposes, create objects of this
     23 * class with CreateWin11LimitedAccessFeaturesInterface.
     24 *
     25 * Windows 11 requires certain features to be unlocked in order to work
     26 * (for instance, the Win11 Taskbar pinning APIs). Call Unlock()
     27 * to unlock them. Generally, results will be cached in atomic variables
     28 * and future calls to Unlock will be as long as it takes
     29 * to fetch an atomic variable.
     30 */
     31 class Win11LimitedAccessFeaturesInterface {
     32 public:
     33  /**
     34   * Unlocks the limited access features, if possible.
     35   *
     36   * Returns an error code on error, true on successful unlock,
     37   * false on unlock failed (but with no error).
     38   */
     39  virtual mozilla::Result<bool, HRESULT> Unlock(
     40      Win11LimitedAccessFeatureType feature) = 0;
     41 
     42  /**
     43   * Reference counting and cycle collection.
     44   */
     45  NS_INLINE_DECL_REFCOUNTING(Win11LimitedAccessFeaturesInterface)
     46 
     47 protected:
     48  virtual ~Win11LimitedAccessFeaturesInterface() {}
     49 };
     50 
     51 struct LimitedAccessFeatureInfo {
     52  const nsCString debugName;
     53  const nsString feature;
     54  const nsString token;
     55  const nsString attestation;
     56 };
     57 
     58 RefPtr<Win11LimitedAccessFeaturesInterface>
     59 CreateWin11LimitedAccessFeaturesInterface();
     60 
     61 mozilla::Result<LimitedAccessFeatureInfo, nsresult>
     62 GenerateLimitedAccessFeatureInfo(const nsCString& debugName,
     63                                 const nsString& lafId);
     64 
     65 #endif  // SHELL_WINDOWS11LIMITEDACCESSFEATURES_H__