widget/windows/JumpListItem.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:d04455f2f7fc
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/. */
5
6 #ifndef __JumpListItem_h__
7 #define __JumpListItem_h__
8
9 #include <windows.h>
10 #include <shobjidl.h>
11 #undef LogSeverity // SetupAPI.h #defines this as DWORD
12
13 #include "nsIJumpListItem.h" // defines nsIJumpListItem
14 #include "nsIMIMEInfo.h" // defines nsILocalHandlerApp
15 #include "nsTArray.h"
16 #include "nsIMutableArray.h"
17 #include "nsCOMPtr.h"
18 #include "nsAutoPtr.h"
19 #include "nsIURI.h"
20 #include "nsICryptoHash.h"
21 #include "nsString.h"
22 #include "nsCycleCollectionParticipant.h"
23
24 class nsIThread;
25
26 namespace mozilla {
27 namespace widget {
28
29 class JumpListItem : public nsIJumpListItem
30 {
31 public:
32 JumpListItem() :
33 mItemType(nsIJumpListItem::JUMPLIST_ITEM_EMPTY)
34 {}
35
36 JumpListItem(int32_t type) :
37 mItemType(type)
38 {}
39
40 virtual ~JumpListItem()
41 {}
42
43 NS_DECL_ISUPPORTS
44 NS_DECL_NSIJUMPLISTITEM
45
46 static const char kJumpListCacheDir[];
47
48 protected:
49 short Type() { return mItemType; }
50 short mItemType;
51
52 };
53
54 class JumpListSeparator : public JumpListItem, public nsIJumpListSeparator
55 {
56 public:
57 JumpListSeparator() :
58 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SEPARATOR)
59 {}
60
61 NS_DECL_ISUPPORTS_INHERITED
62 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
63 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval) { return JumpListItem::Equals(item, _retval); }
64
65 static nsresult GetSeparator(nsRefPtr<IShellLinkW>& aShellLink);
66 };
67
68 class JumpListLink : public JumpListItem, public nsIJumpListLink
69 {
70 public:
71 JumpListLink() :
72 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_LINK)
73 {}
74
75 NS_DECL_ISUPPORTS_INHERITED
76 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
77 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval);
78 NS_DECL_NSIJUMPLISTLINK
79
80 static nsresult GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem);
81 static nsresult GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink);
82
83 protected:
84 nsString mUriTitle;
85 nsCOMPtr<nsIURI> mURI;
86 nsCOMPtr<nsICryptoHash> mCryptoHash;
87 };
88
89 class JumpListShortcut : public JumpListItem, public nsIJumpListShortcut
90 {
91 public:
92 JumpListShortcut() :
93 JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SHORTCUT)
94 {}
95
96 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
97 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(JumpListShortcut, JumpListItem)
98 NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); }
99 NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval);
100 NS_DECL_NSIJUMPLISTSHORTCUT
101
102 static nsresult GetShellLink(nsCOMPtr<nsIJumpListItem>& item,
103 nsRefPtr<IShellLinkW>& aShellLink,
104 nsCOMPtr<nsIThread> &aIOThread);
105 static nsresult GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJumpListShortcut>& aShortcut);
106 static nsresult GetOutputIconPath(nsCOMPtr<nsIURI> aFaviconPageURI,
107 nsCOMPtr<nsIFile> &aICOFile);
108
109 protected:
110 int32_t mIconIndex;
111 nsCOMPtr<nsIURI> mFaviconPageURI;
112 nsCOMPtr<nsILocalHandlerApp> mHandlerApp;
113
114 bool ExecutableExists(nsCOMPtr<nsILocalHandlerApp>& handlerApp);
115 static nsresult ObtainCachedIconFile(nsCOMPtr<nsIURI> aFaviconPageURI,
116 nsString &aICOFilePath,
117 nsCOMPtr<nsIThread> &aIOThread);
118 static nsresult CacheIconFileFromFaviconURIAsync(nsCOMPtr<nsIURI> aFaviconPageURI,
119 nsCOMPtr<nsIFile> aICOFile,
120 nsCOMPtr<nsIThread> &aIOThread);
121 };
122
123 } // namespace widget
124 } // namespace mozilla
125
126 #endif /* __JumpListItem_h__ */

mercurial