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/. */
6 #ifndef mozilla_widget_IconLoader_h_
7 #define mozilla_widget_IconLoader_h_
9 #include "imgINotificationObserver.h"
10 #include "mozilla/RefPtr.h"
12 #include "nsISupports.h"
16 class imgRequestProxy
;
19 namespace mozilla::widget
{
22 * IconLoader is a utility for loading icons from either the disk or over
23 * the network, and then using them in native OS widgetry like the macOS
24 * global menu bar or the Windows notification area.
27 class IconLoader
: public imgINotificationObserver
{
29 // This is the interface that our listeners need to implement so that they can
30 // be notified when the icon is loaded.
33 virtual nsresult
OnComplete(imgIContainer
* aContainer
) = 0;
37 // aListener will be notified when the load is complete.
38 // The loader does not keep an owning reference to the listener. Call Destroy
39 // before the listener goes away.
40 explicit IconLoader(Listener
* aListener
);
44 NS_DECL_IMGINOTIFICATIONOBSERVER
46 // LoadIcon will start a load request for the icon.
47 // The request may not complete until after LoadIcon returns.
48 // If aIsInternalIcon is true, the document and principal will not be
50 nsresult
LoadIcon(nsIURI
* aIconURI
, nsINode
* aNode
,
51 bool aIsInternalIcon
= false);
56 virtual ~IconLoader();
59 RefPtr
<imgRequestProxy
> mIconRequest
;
61 // The listener, which is notified when loading completes.
62 // Can be null, after a call to Destroy.
63 // This is a non-owning reference and needs to be cleared with a call to
64 // Destroy before the listener goes away.
68 } // namespace mozilla::widget
69 #endif // mozilla_widget_IconLoader_h_