tor-browser

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

nsIconURI.h (3736B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 *
      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_image_decoders_icon_nsIconURI_h
      8 #define mozilla_image_decoders_icon_nsIconURI_h
      9 
     10 #include "nsIIconURI.h"
     11 #include "nsCOMPtr.h"
     12 #include "nsString.h"
     13 #include "nsINestedURI.h"
     14 #include "nsIURIMutator.h"
     15 #include "nsISerializable.h"
     16 
     17 #define NS_THIS_ICONURI_IMPLEMENTATION_CID    \
     18  {/* 0b9bb0c2-fee6-470b-b9b9-9fd9462b5e19 */ \
     19   0x5c3e417f,                                \
     20   0xb686,                                    \
     21   0x4105,                                    \
     22   {0x86, 0xe7, 0xf9, 0x1b, 0xac, 0x97, 0x4d, 0x5c}}
     23 
     24 namespace mozilla {
     25 class Encoding;
     26 }
     27 
     28 class nsMozIconURI final : public nsIMozIconURI,
     29                           public nsINestedURI,
     30                           public nsISerializable {
     31 public:
     32  NS_DECL_THREADSAFE_ISUPPORTS
     33  NS_DECL_NSIURI
     34  NS_DECL_NSIMOZICONURI
     35  NS_DECL_NSINESTEDURI
     36  NS_DECL_NSISERIALIZABLE
     37 
     38 protected:
     39  nsMozIconURI();
     40  virtual ~nsMozIconURI();
     41  nsCOMPtr<nsIURL> mIconURL;  // a URL that we want the icon for
     42  uint32_t mSize;  // the # of pixels in a row that we want for this image.
     43                   // Typically 16, 32, 128, etc.
     44  nsCString mContentType;  // optional field explicitly specifying the content
     45                           // type
     46  nsCString mFileName;  // for if we don't have an actual file path, we're just
     47                        // given a filename with an extension
     48  nsCString mStockIcon;
     49  uint32_t mScale = 1;
     50  mozilla::Maybe<bool> mDark;
     51 
     52 private:
     53  nsresult Clone(nsIURI** aURI);
     54  nsresult SetSpecInternal(const nsACString& input);
     55  nsresult SetScheme(const nsACString& input);
     56  nsresult SetUserPass(const nsACString& input);
     57  nsresult SetUsername(const nsACString& input);
     58  nsresult SetPassword(const nsACString& input);
     59  nsresult SetHostPort(const nsACString& aValue);
     60  nsresult SetHost(const nsACString& input);
     61  nsresult SetPort(int32_t port);
     62  nsresult SetPathQueryRef(const nsACString& input);
     63  nsresult SetRef(const nsACString& input);
     64  nsresult SetFilePath(const nsACString& input);
     65  nsresult SetQuery(const nsACString& input);
     66  nsresult SetQueryWithEncoding(const nsACString& input,
     67                                const mozilla::Encoding* encoding);
     68  nsresult ReadPrivate(nsIObjectInputStream* stream);
     69  bool Deserialize(const mozilla::ipc::URIParams&);
     70 
     71 public:
     72  class Mutator final : public nsIURIMutator,
     73                        public BaseURIMutator<nsMozIconURI>,
     74                        public nsISerializable {
     75    NS_DECL_ISUPPORTS
     76    NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
     77 
     78    NS_IMETHOD
     79    Write(nsIObjectOutputStream* aOutputStream) override {
     80      return NS_ERROR_NOT_IMPLEMENTED;
     81    }
     82 
     83    [[nodiscard]] NS_IMETHOD Read(nsIObjectInputStream* aStream) override {
     84      return InitFromInputStream(aStream);
     85    }
     86 
     87    NS_IMETHOD Deserialize(const mozilla::ipc::URIParams& aParams) override {
     88      return InitFromIPCParams(aParams);
     89    }
     90 
     91    NS_IMETHOD Finalize(nsIURI** aURI) override {
     92      mURI.forget(aURI);
     93      return NS_OK;
     94    }
     95 
     96    NS_IMETHOD SetSpec(const nsACString& aSpec,
     97                       nsIURIMutator** aMutator) override {
     98      if (aMutator) {
     99        nsCOMPtr<nsIURIMutator> mutator = this;
    100        mutator.forget(aMutator);
    101      }
    102      return InitFromSpec(aSpec);
    103    }
    104 
    105    explicit Mutator() {}
    106 
    107   private:
    108    virtual ~Mutator() {}
    109 
    110    friend class nsMozIconURI;
    111  };
    112 
    113  friend BaseURIMutator<nsMozIconURI>;
    114 };
    115 
    116 #endif  // mozilla_image_decoders_icon_nsIconURI_h