tor-browser

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

nsDataHandler.h (1839B)


      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 nsDataHandler_h___
      7 #define nsDataHandler_h___
      8 
      9 #include "mozilla/dom/MimeType.h"
     10 #include "nsIProtocolHandler.h"
     11 #include "nsWeakReference.h"
     12 
     13 class nsDataHandler : public nsIProtocolHandler,
     14                      public nsSupportsWeakReference {
     15  virtual ~nsDataHandler() = default;
     16 
     17 public:
     18  NS_DECL_ISUPPORTS
     19 
     20  // nsIProtocolHandler methods:
     21  NS_DECL_NSIPROTOCOLHANDLER
     22 
     23  // nsDataHandler methods:
     24  nsDataHandler() = default;
     25 
     26  static nsresult CreateNewURI(const nsACString& aSpec, const char* aCharset,
     27                               nsIURI* aBaseURI, nsIURI** result);
     28 
     29  // Define a Create method to be used with a factory:
     30  [[nodiscard]] static nsresult Create(const nsIID& aIID, void** aResult);
     31 
     32  // Parse the full spec of a data: URI and return the individual parts.
     33  //
     34  // @arg aSpec The spec of the data URI.
     35  // @arg aContentType Out param, will hold the parsed content type.
     36  // @arg aContentCharset Optional, will hold the charset if specified.
     37  // @arg aIsBase64 Out param, indicates if the data is base64 encoded.
     38  // @arg aDataBuffer Optional, will reference the substring in |aPath| that
     39  //  contains the data portion of the path. No copy is made.
     40  // @arg aMimeType Optional, will be a CMimeType for the data in |aPath|.
     41  [[nodiscard]] static nsresult ParseURI(
     42      const nsACString& aSpec, nsCString& aContentType,
     43      nsCString* aContentCharset, bool& aIsBase64,
     44      nsDependentCSubstring* aDataBuffer = nullptr,
     45      RefPtr<CMimeType>* aMimeType = nullptr);
     46 };
     47 
     48 #endif /* nsDataHandler_h___ */