Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef __JumpListItem_h__ |
michael@0 | 7 | #define __JumpListItem_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include <windows.h> |
michael@0 | 10 | #include <shobjidl.h> |
michael@0 | 11 | #undef LogSeverity // SetupAPI.h #defines this as DWORD |
michael@0 | 12 | |
michael@0 | 13 | #include "nsIJumpListItem.h" // defines nsIJumpListItem |
michael@0 | 14 | #include "nsIMIMEInfo.h" // defines nsILocalHandlerApp |
michael@0 | 15 | #include "nsTArray.h" |
michael@0 | 16 | #include "nsIMutableArray.h" |
michael@0 | 17 | #include "nsCOMPtr.h" |
michael@0 | 18 | #include "nsAutoPtr.h" |
michael@0 | 19 | #include "nsIURI.h" |
michael@0 | 20 | #include "nsICryptoHash.h" |
michael@0 | 21 | #include "nsString.h" |
michael@0 | 22 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 23 | |
michael@0 | 24 | class nsIThread; |
michael@0 | 25 | |
michael@0 | 26 | namespace mozilla { |
michael@0 | 27 | namespace widget { |
michael@0 | 28 | |
michael@0 | 29 | class JumpListItem : public nsIJumpListItem |
michael@0 | 30 | { |
michael@0 | 31 | public: |
michael@0 | 32 | JumpListItem() : |
michael@0 | 33 | mItemType(nsIJumpListItem::JUMPLIST_ITEM_EMPTY) |
michael@0 | 34 | {} |
michael@0 | 35 | |
michael@0 | 36 | JumpListItem(int32_t type) : |
michael@0 | 37 | mItemType(type) |
michael@0 | 38 | {} |
michael@0 | 39 | |
michael@0 | 40 | virtual ~JumpListItem() |
michael@0 | 41 | {} |
michael@0 | 42 | |
michael@0 | 43 | NS_DECL_ISUPPORTS |
michael@0 | 44 | NS_DECL_NSIJUMPLISTITEM |
michael@0 | 45 | |
michael@0 | 46 | static const char kJumpListCacheDir[]; |
michael@0 | 47 | |
michael@0 | 48 | protected: |
michael@0 | 49 | short Type() { return mItemType; } |
michael@0 | 50 | short mItemType; |
michael@0 | 51 | |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | class JumpListSeparator : public JumpListItem, public nsIJumpListSeparator |
michael@0 | 55 | { |
michael@0 | 56 | public: |
michael@0 | 57 | JumpListSeparator() : |
michael@0 | 58 | JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SEPARATOR) |
michael@0 | 59 | {} |
michael@0 | 60 | |
michael@0 | 61 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 62 | NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } |
michael@0 | 63 | NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval) { return JumpListItem::Equals(item, _retval); } |
michael@0 | 64 | |
michael@0 | 65 | static nsresult GetSeparator(nsRefPtr<IShellLinkW>& aShellLink); |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | class JumpListLink : public JumpListItem, public nsIJumpListLink |
michael@0 | 69 | { |
michael@0 | 70 | public: |
michael@0 | 71 | JumpListLink() : |
michael@0 | 72 | JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_LINK) |
michael@0 | 73 | {} |
michael@0 | 74 | |
michael@0 | 75 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 76 | NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } |
michael@0 | 77 | NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval); |
michael@0 | 78 | NS_DECL_NSIJUMPLISTLINK |
michael@0 | 79 | |
michael@0 | 80 | static nsresult GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem); |
michael@0 | 81 | static nsresult GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink); |
michael@0 | 82 | |
michael@0 | 83 | protected: |
michael@0 | 84 | nsString mUriTitle; |
michael@0 | 85 | nsCOMPtr<nsIURI> mURI; |
michael@0 | 86 | nsCOMPtr<nsICryptoHash> mCryptoHash; |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | class JumpListShortcut : public JumpListItem, public nsIJumpListShortcut |
michael@0 | 90 | { |
michael@0 | 91 | public: |
michael@0 | 92 | JumpListShortcut() : |
michael@0 | 93 | JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SHORTCUT) |
michael@0 | 94 | {} |
michael@0 | 95 | |
michael@0 | 96 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 97 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(JumpListShortcut, JumpListItem) |
michael@0 | 98 | NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } |
michael@0 | 99 | NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval); |
michael@0 | 100 | NS_DECL_NSIJUMPLISTSHORTCUT |
michael@0 | 101 | |
michael@0 | 102 | static nsresult GetShellLink(nsCOMPtr<nsIJumpListItem>& item, |
michael@0 | 103 | nsRefPtr<IShellLinkW>& aShellLink, |
michael@0 | 104 | nsCOMPtr<nsIThread> &aIOThread); |
michael@0 | 105 | static nsresult GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJumpListShortcut>& aShortcut); |
michael@0 | 106 | static nsresult GetOutputIconPath(nsCOMPtr<nsIURI> aFaviconPageURI, |
michael@0 | 107 | nsCOMPtr<nsIFile> &aICOFile); |
michael@0 | 108 | |
michael@0 | 109 | protected: |
michael@0 | 110 | int32_t mIconIndex; |
michael@0 | 111 | nsCOMPtr<nsIURI> mFaviconPageURI; |
michael@0 | 112 | nsCOMPtr<nsILocalHandlerApp> mHandlerApp; |
michael@0 | 113 | |
michael@0 | 114 | bool ExecutableExists(nsCOMPtr<nsILocalHandlerApp>& handlerApp); |
michael@0 | 115 | static nsresult ObtainCachedIconFile(nsCOMPtr<nsIURI> aFaviconPageURI, |
michael@0 | 116 | nsString &aICOFilePath, |
michael@0 | 117 | nsCOMPtr<nsIThread> &aIOThread); |
michael@0 | 118 | static nsresult CacheIconFileFromFaviconURIAsync(nsCOMPtr<nsIURI> aFaviconPageURI, |
michael@0 | 119 | nsCOMPtr<nsIFile> aICOFile, |
michael@0 | 120 | nsCOMPtr<nsIThread> &aIOThread); |
michael@0 | 121 | }; |
michael@0 | 122 | |
michael@0 | 123 | } // namespace widget |
michael@0 | 124 | } // namespace mozilla |
michael@0 | 125 | |
michael@0 | 126 | #endif /* __JumpListItem_h__ */ |