tor-browser

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

nsIconChannel.h (1901B)


      1 /* -*- Mode: C++; tab-width: 20; 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 mozilla_image_decoders_icon_gtk_nsIconChannel_h
      7 #define mozilla_image_decoders_icon_gtk_nsIconChannel_h
      8 
      9 #include "nsIChannel.h"
     10 #include "nsIURI.h"
     11 #include "nsCOMPtr.h"
     12 
     13 namespace mozilla {
     14 namespace ipc {
     15 class ByteBuf;
     16 }
     17 namespace gfx {
     18 class DataSourceSurface;
     19 }
     20 }  // namespace mozilla
     21 
     22 /// This class is the GTK implementation of nsIconChannel.  It asks
     23 /// GTK for the icon, translates the pixel data in-memory into
     24 /// nsIconDecoder format, and proxies the nsChannel interface to a new
     25 /// channel returning that image.
     26 class nsIconChannel final : public nsIChannel {
     27 public:
     28  NS_DECL_ISUPPORTS
     29  NS_FORWARD_NSIREQUEST(mRealChannel->)
     30  NS_FORWARD_NSICHANNEL(mRealChannel->)
     31 
     32  nsIconChannel() = default;
     33 
     34  static void Shutdown();
     35 
     36  /// Called by nsIconProtocolHandler after it creates this channel.
     37  /// Must be called before calling any other function on this object.
     38  /// If this method fails, no other function must be called on this object.
     39  nsresult Init(nsIURI* aURI, nsILoadInfo* aLoadInfo);
     40 
     41  /// Obtains an icon, in nsIconDecoder format, as a ByteBuf instead
     42  /// of a channel.  For use with IPC.
     43  static nsresult GetIcon(nsIURI* aURI, mozilla::ipc::ByteBuf* aDataOut);
     44  static already_AddRefed<mozilla::gfx::DataSourceSurface> GetSymbolicIcon(
     45      const nsCString& aName, int aIconSize, int aScale, nscolor aFgColor);
     46 
     47 private:
     48  ~nsIconChannel() = default;
     49  /// The input stream channel which will yield the image.
     50  /// Will always be non-null after a successful Init.
     51  nsCOMPtr<nsIChannel> mRealChannel;
     52 };
     53 
     54 #endif  // mozilla_image_decoders_icon_gtk_nsIconChannel_h