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/. */
7 * Retrieves and displays icons on the macOS Touch Bar.
10 #ifndef nsTouchBarInputIcon_h_
11 #define nsTouchBarInputIcon_h_
13 #import <Cocoa/Cocoa.h>
15 #include "mozilla/widget/IconLoader.h"
16 #include "nsTouchBarInput.h"
18 using namespace mozilla::dom
;
22 class imgRequestProxy
;
24 namespace mozilla::dom
{
28 class nsTouchBarInputIcon
: public mozilla::widget::IconLoader::Listener
{
30 explicit nsTouchBarInputIcon(RefPtr
<Document
> aDocument
,
31 TouchBarInput
* aInput
, NSTouchBarItem
* aItem
);
33 NS_INLINE_DECL_REFCOUNTING(nsTouchBarInputIcon
)
36 virtual ~nsTouchBarInputIcon();
39 // SetupIcon succeeds if it was able to set up the icon, or if there should
40 // be no icon, in which case it clears any existing icon but still succeeds.
41 nsresult
SetupIcon(nsCOMPtr
<nsIURI
> aIconURI
);
43 // Implements this method for mozilla::widget::IconLoader::Listener.
44 // Called once the icon load is complete.
45 nsresult
OnComplete(imgIContainer
* aImage
) override
;
47 // Unless we take precautions, we may outlive the object that created us
48 // (mTouchBar, which owns our native menu item (mTouchBarInput)).
49 // Destroy() should be called from mTouchBar's destructor to prevent
50 // this from happening.
53 void ReleaseJSObjects();
56 RefPtr
<Document
> mDocument
;
59 // We accept a mShareScrubber only as a special case since
60 // NSSharingServicePickerTouchBarItem does not expose an NSButton* on which we
61 // can set the `image` property.
62 NSSharingServicePickerTouchBarItem
* mShareScrubber
;
63 // We accept a popover only as a special case.
64 NSPopoverTouchBarItem
* mPopoverItem
;
65 // The icon loader object should never outlive its creating
66 // nsTouchBarInputIcon object.
67 RefPtr
<mozilla::widget::IconLoader
> mIconLoader
;
70 #endif // nsTouchBarInputIcon_h_