Backed out changeset 8517afe50156 (bug 540456) for reftest failures.
[gecko.git] / widget / windows / JumpListItem.h
blob59f6715297bff18541f8b5cbbf25eaf4e3d34004
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 __JumpListItem_h__
7 #define __JumpListItem_h__
9 #include <windows.h>
10 #include <shobjidl.h>
12 #include "nsIJumpListItem.h" // defines nsIJumpListItem
13 #include "nsIMIMEInfo.h" // defines nsILocalHandlerApp
14 #include "nsTArray.h"
15 #include "nsIMutableArray.h"
16 #include "nsCOMPtr.h"
17 #include "nsAutoPtr.h"
18 #include "nsIURI.h"
19 #include "nsICryptoHash.h"
20 #include "nsString.h"
21 #include "nsCycleCollectionParticipant.h"
23 class nsIThread;
25 namespace mozilla {
26 namespace widget {
28 class JumpListItem : public nsIJumpListItem
30 public:
31 JumpListItem() :
32 mItemType(nsIJumpListItem::JUMPLIST_ITEM_EMPTY)
35 JumpListItem(int32_t type) :
36 mItemType(type)
39 virtual ~JumpListItem()
42 NS_DECL_ISUPPORTS
43 NS_DECL_NSIJUMPLISTITEM
45 static const char kJumpListCacheDir[];
47 protected:
48 short Type() { return mItemType; }
49 short mItemType;
53 class JumpListSeparator : public JumpListItem, public nsIJumpListSeparator
55 public:
56 JumpListSeparator() :
57 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SEPARATOR)
60 NS_DECL_ISUPPORTS_INHERITED
61 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
62 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval) { return JumpListItem::Equals(item, _retval); }
64 static nsresult GetSeparator(nsRefPtr<IShellLinkW>& aShellLink);
67 class JumpListLink : public JumpListItem, public nsIJumpListLink
69 public:
70 JumpListLink() :
71 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_LINK)
74 NS_DECL_ISUPPORTS_INHERITED
75 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
76 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval);
77 NS_DECL_NSIJUMPLISTLINK
79 static nsresult GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem);
80 static nsresult GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink);
82 protected:
83 nsString mUriTitle;
84 nsCOMPtr<nsIURI> mURI;
85 nsCOMPtr<nsICryptoHash> mCryptoHash;
88 class JumpListShortcut : public JumpListItem, public nsIJumpListShortcut
90 public:
91 JumpListShortcut() :
92 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SHORTCUT)
95 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
96 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(JumpListShortcut, JumpListItem)
97 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
98 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval);
99 NS_DECL_NSIJUMPLISTSHORTCUT
101 static nsresult GetShellLink(nsCOMPtr<nsIJumpListItem>& item,
102 nsRefPtr<IShellLinkW>& aShellLink,
103 nsCOMPtr<nsIThread> &aIOThread);
104 static nsresult GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJumpListShortcut>& aShortcut);
105 static nsresult GetOutputIconPath(nsCOMPtr<nsIURI> aFaviconPageURI,
106 nsCOMPtr<nsIFile> &aICOFile);
108 protected:
109 int32_t mIconIndex;
110 nsCOMPtr<nsIURI> mFaviconPageURI;
111 nsCOMPtr<nsILocalHandlerApp> mHandlerApp;
113 bool ExecutableExists(nsCOMPtr<nsILocalHandlerApp>& handlerApp);
114 static nsresult ObtainCachedIconFile(nsCOMPtr<nsIURI> aFaviconPageURI,
115 nsString &aICOFilePath,
116 nsCOMPtr<nsIThread> &aIOThread);
117 static nsresult CacheIconFileFromFaviconURIAsync(nsCOMPtr<nsIURI> aFaviconPageURI,
118 nsCOMPtr<nsIFile> aICOFile,
119 nsCOMPtr<nsIThread> &aIOThread);
122 } // namespace widget
123 } // namespace mozilla
125 #endif /* __JumpListItem_h__ */