1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/windows/JumpListItem.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef __JumpListItem_h__ 1.10 +#define __JumpListItem_h__ 1.11 + 1.12 +#include <windows.h> 1.13 +#include <shobjidl.h> 1.14 +#undef LogSeverity // SetupAPI.h #defines this as DWORD 1.15 + 1.16 +#include "nsIJumpListItem.h" // defines nsIJumpListItem 1.17 +#include "nsIMIMEInfo.h" // defines nsILocalHandlerApp 1.18 +#include "nsTArray.h" 1.19 +#include "nsIMutableArray.h" 1.20 +#include "nsCOMPtr.h" 1.21 +#include "nsAutoPtr.h" 1.22 +#include "nsIURI.h" 1.23 +#include "nsICryptoHash.h" 1.24 +#include "nsString.h" 1.25 +#include "nsCycleCollectionParticipant.h" 1.26 + 1.27 +class nsIThread; 1.28 + 1.29 +namespace mozilla { 1.30 +namespace widget { 1.31 + 1.32 +class JumpListItem : public nsIJumpListItem 1.33 +{ 1.34 +public: 1.35 + JumpListItem() : 1.36 + mItemType(nsIJumpListItem::JUMPLIST_ITEM_EMPTY) 1.37 + {} 1.38 + 1.39 + JumpListItem(int32_t type) : 1.40 + mItemType(type) 1.41 + {} 1.42 + 1.43 + virtual ~JumpListItem() 1.44 + {} 1.45 + 1.46 + NS_DECL_ISUPPORTS 1.47 + NS_DECL_NSIJUMPLISTITEM 1.48 + 1.49 + static const char kJumpListCacheDir[]; 1.50 + 1.51 +protected: 1.52 + short Type() { return mItemType; } 1.53 + short mItemType; 1.54 + 1.55 +}; 1.56 + 1.57 +class JumpListSeparator : public JumpListItem, public nsIJumpListSeparator 1.58 +{ 1.59 +public: 1.60 + JumpListSeparator() : 1.61 + JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SEPARATOR) 1.62 + {} 1.63 + 1.64 + NS_DECL_ISUPPORTS_INHERITED 1.65 + NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } 1.66 + NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval) { return JumpListItem::Equals(item, _retval); } 1.67 + 1.68 + static nsresult GetSeparator(nsRefPtr<IShellLinkW>& aShellLink); 1.69 +}; 1.70 + 1.71 +class JumpListLink : public JumpListItem, public nsIJumpListLink 1.72 +{ 1.73 +public: 1.74 + JumpListLink() : 1.75 + JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_LINK) 1.76 + {} 1.77 + 1.78 + NS_DECL_ISUPPORTS_INHERITED 1.79 + NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } 1.80 + NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval); 1.81 + NS_DECL_NSIJUMPLISTLINK 1.82 + 1.83 + static nsresult GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem); 1.84 + static nsresult GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink); 1.85 + 1.86 +protected: 1.87 + nsString mUriTitle; 1.88 + nsCOMPtr<nsIURI> mURI; 1.89 + nsCOMPtr<nsICryptoHash> mCryptoHash; 1.90 +}; 1.91 + 1.92 +class JumpListShortcut : public JumpListItem, public nsIJumpListShortcut 1.93 +{ 1.94 +public: 1.95 + JumpListShortcut() : 1.96 + JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SHORTCUT) 1.97 + {} 1.98 + 1.99 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.100 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(JumpListShortcut, JumpListItem) 1.101 + NS_IMETHOD GetType(int16_t *aType) { return JumpListItem::GetType(aType); } 1.102 + NS_IMETHOD Equals(nsIJumpListItem *item, bool *_retval); 1.103 + NS_DECL_NSIJUMPLISTSHORTCUT 1.104 + 1.105 + static nsresult GetShellLink(nsCOMPtr<nsIJumpListItem>& item, 1.106 + nsRefPtr<IShellLinkW>& aShellLink, 1.107 + nsCOMPtr<nsIThread> &aIOThread); 1.108 + static nsresult GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJumpListShortcut>& aShortcut); 1.109 + static nsresult GetOutputIconPath(nsCOMPtr<nsIURI> aFaviconPageURI, 1.110 + nsCOMPtr<nsIFile> &aICOFile); 1.111 + 1.112 +protected: 1.113 + int32_t mIconIndex; 1.114 + nsCOMPtr<nsIURI> mFaviconPageURI; 1.115 + nsCOMPtr<nsILocalHandlerApp> mHandlerApp; 1.116 + 1.117 + bool ExecutableExists(nsCOMPtr<nsILocalHandlerApp>& handlerApp); 1.118 + static nsresult ObtainCachedIconFile(nsCOMPtr<nsIURI> aFaviconPageURI, 1.119 + nsString &aICOFilePath, 1.120 + nsCOMPtr<nsIThread> &aIOThread); 1.121 + static nsresult CacheIconFileFromFaviconURIAsync(nsCOMPtr<nsIURI> aFaviconPageURI, 1.122 + nsCOMPtr<nsIFile> aICOFile, 1.123 + nsCOMPtr<nsIThread> &aIOThread); 1.124 +}; 1.125 + 1.126 +} // namespace widget 1.127 +} // namespace mozilla 1.128 + 1.129 +#endif /* __JumpListItem_h__ */