Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / windows / LegacyJumpListItem.h
blobbcef82d349448045899810fc3d8c008b31d3b7aa
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 __LegacyJumpListItem_h__
7 #define __LegacyJumpListItem_h__
9 #include <windows.h>
10 #include <shobjidl.h>
11 #undef LogSeverity // SetupAPI.h #defines this as DWORD
13 #include "mozilla/RefPtr.h"
14 #include "mozilla/LazyIdleThread.h"
15 #include "nsILegacyJumpListItem.h" // defines nsILegacyJumpListItem
16 #include "nsIMIMEInfo.h" // defines nsILocalHandlerApp
17 #include "nsTArray.h"
18 #include "nsCOMPtr.h"
19 #include "nsIURI.h"
20 #include "nsICryptoHash.h"
21 #include "nsString.h"
22 #include "nsCycleCollectionParticipant.h"
24 class nsIThread;
26 namespace mozilla {
27 namespace widget {
29 class LegacyJumpListItemBase : public nsILegacyJumpListItem {
30 public:
31 LegacyJumpListItemBase()
32 : mItemType(nsILegacyJumpListItem::JUMPLIST_ITEM_EMPTY) {}
34 explicit LegacyJumpListItemBase(int32_t type) : mItemType(type) {}
36 NS_DECL_NSILEGACYJUMPLISTITEM
38 static const char kJumpListCacheDir[];
40 protected:
41 virtual ~LegacyJumpListItemBase() {}
43 short Type() { return mItemType; }
44 short mItemType;
47 class LegacyJumpListItem : public LegacyJumpListItemBase {
48 ~LegacyJumpListItem() {}
50 public:
51 using LegacyJumpListItemBase::LegacyJumpListItemBase;
53 NS_DECL_ISUPPORTS
56 class LegacyJumpListSeparator : public LegacyJumpListItemBase,
57 public nsILegacyJumpListSeparator {
58 ~LegacyJumpListSeparator() {}
60 public:
61 LegacyJumpListSeparator()
62 : LegacyJumpListItemBase(nsILegacyJumpListItem::JUMPLIST_ITEM_SEPARATOR) {
65 NS_DECL_ISUPPORTS
66 NS_FORWARD_NSILEGACYJUMPLISTITEM(LegacyJumpListItemBase::)
68 static nsresult GetSeparator(RefPtr<IShellLinkW>& aShellLink);
71 class LegacyJumpListLink : public LegacyJumpListItemBase,
72 public nsILegacyJumpListLink {
73 ~LegacyJumpListLink() {}
75 public:
76 LegacyJumpListLink()
77 : LegacyJumpListItemBase(nsILegacyJumpListItem::JUMPLIST_ITEM_LINK) {}
79 NS_DECL_ISUPPORTS
80 NS_IMETHOD GetType(int16_t* aType) override {
81 return LegacyJumpListItemBase::GetType(aType);
83 NS_IMETHOD Equals(nsILegacyJumpListItem* item, bool* _retval) override;
84 NS_DECL_NSILEGACYJUMPLISTLINK
86 static nsresult GetShellItem(nsCOMPtr<nsILegacyJumpListItem>& item,
87 RefPtr<IShellItem2>& aShellItem);
88 static nsresult GetJumpListLink(IShellItem* pItem,
89 nsCOMPtr<nsILegacyJumpListLink>& aLink);
91 protected:
92 nsString mUriTitle;
93 nsCOMPtr<nsIURI> mURI;
94 nsCOMPtr<nsICryptoHash> mCryptoHash;
97 class LegacyJumpListShortcut : public LegacyJumpListItemBase,
98 public nsILegacyJumpListShortcut {
99 ~LegacyJumpListShortcut() {}
101 public:
102 LegacyJumpListShortcut()
103 : LegacyJumpListItemBase(nsILegacyJumpListItem::JUMPLIST_ITEM_SHORTCUT) {}
105 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
106 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(LegacyJumpListShortcut,
107 LegacyJumpListItemBase)
108 NS_IMETHOD GetType(int16_t* aType) override {
109 return LegacyJumpListItemBase::GetType(aType);
111 NS_IMETHOD Equals(nsILegacyJumpListItem* item, bool* _retval) override;
112 NS_DECL_NSILEGACYJUMPLISTSHORTCUT
114 static nsresult GetShellLink(nsCOMPtr<nsILegacyJumpListItem>& item,
115 RefPtr<IShellLinkW>& aShellLink,
116 RefPtr<LazyIdleThread>& aIOThread);
117 static nsresult GetJumpListShortcut(
118 IShellLinkW* pLink, nsCOMPtr<nsILegacyJumpListShortcut>& aShortcut);
119 static nsresult GetOutputIconPath(nsCOMPtr<nsIURI> aFaviconPageURI,
120 nsCOMPtr<nsIFile>& aICOFile);
122 protected:
123 int32_t mIconIndex;
124 nsCOMPtr<nsIURI> mFaviconPageURI;
125 nsCOMPtr<nsILocalHandlerApp> mHandlerApp;
127 bool ExecutableExists(nsCOMPtr<nsILocalHandlerApp>& handlerApp);
130 } // namespace widget
131 } // namespace mozilla
133 #endif /* __LegacyJumpListItem_h__ */