tor-browser

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

SimpleURIUnknownSchemes.h (2009B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=4 sw=2 sts=2 et cin: */
      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 SimpleURIUnknownSchemes_h__
      8 #define SimpleURIUnknownSchemes_h__
      9 
     10 #include "nsString.h"
     11 #include "mozilla/RWLock.h"
     12 #include "nsTArray.h"
     13 #include "nsTHashSet.h"
     14 
     15 #define SIMPLE_URI_SCHEMES_PREF "network.url.simple_uri_unknown_schemes"
     16 
     17 namespace mozilla::net {
     18 
     19 class SimpleURIUnknownSchemes {
     20 public:
     21  SimpleURIUnknownSchemes() = default;
     22 
     23  // parse the list in the pref specified by SIMPLE_URI_SCHEMES_PREF
     24  // then merge them with the list obtained from remote settings
     25  // into a list to tell URL constructors of unknown schemes
     26  // to use our simpleURI parser
     27  void ParseAndMergePrefSchemes();
     28 
     29  // pass a remote-settings specified list of unknown schemes that should use
     30  // the simple uri parser
     31  // store a local copy of the list
     32  // and merge the list with the pref-specified list of unknown schemes
     33  void SetAndMergeRemoteSchemes(const nsTArray<nsCString>& remoteSettingsList);
     34 
     35  bool IsSimpleURIUnknownScheme(const nsACString& aScheme);
     36  void GetRemoteSchemes(nsTArray<nsCString>& aArray);
     37 
     38 private:
     39  void ParseAndMergePrefSchemesLocked() MOZ_REQUIRES(mSchemeLock);
     40  void MergeSimpleURISchemes(const nsTArray<nsCString>& prefList,
     41                             const nsTArray<nsCString>& remoteSettingsList)
     42      MOZ_REQUIRES(mSchemeLock);
     43 
     44  mutable RWLock mSchemeLock{"SimpleURIUnknownSchemes"};
     45  nsTHashSet<nsCString> mSimpleURISchemes MOZ_GUARDED_BY(mSchemeLock);
     46 
     47  // process-local copy of the remote settings schemes
     48  // keep them separate from pref-entered schemes so user cannot overwrite
     49  nsTArray<nsCString> mRemoteSettingsURISchemes MOZ_GUARDED_BY(mSchemeLock);
     50 };
     51 
     52 }  // namespace mozilla::net
     53 #endif  // SimpleURIUnknownSchemes_h__