widget/windows/JumpListItem.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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>
    11 #undef LogSeverity // SetupAPI.h #defines this as DWORD
    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"
    24 class nsIThread;
    26 namespace mozilla {
    27 namespace widget {
    29 class JumpListItem : public nsIJumpListItem
    30 {
    31 public:
    32   JumpListItem() :
    33    mItemType(nsIJumpListItem::JUMPLIST_ITEM_EMPTY)
    34   {}
    36   JumpListItem(int32_t type) :
    37    mItemType(type)
    38   {}
    40   virtual ~JumpListItem() 
    41   {}
    43   NS_DECL_ISUPPORTS
    44   NS_DECL_NSIJUMPLISTITEM
    46   static const char kJumpListCacheDir[];
    48 protected:
    49   short Type() { return mItemType; }
    50   short mItemType;
    52 };
    54 class JumpListSeparator : public JumpListItem, public nsIJumpListSeparator
    55 {
    56 public:
    57   JumpListSeparator() :
    58    JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SEPARATOR)
    59   {}
    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); }
    65   static nsresult GetSeparator(nsRefPtr<IShellLinkW>& aShellLink);
    66 };
    68 class JumpListLink : public JumpListItem, public nsIJumpListLink
    69 {
    70 public:
    71   JumpListLink() :
    72    JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_LINK)
    73   {}
    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
    80   static nsresult GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem);
    81   static nsresult GetJumpListLink(IShellItem *pItem, nsCOMPtr<nsIJumpListLink>& aLink);
    83 protected:
    84   nsString mUriTitle;
    85   nsCOMPtr<nsIURI> mURI;
    86   nsCOMPtr<nsICryptoHash> mCryptoHash;
    87 };
    89 class JumpListShortcut : public JumpListItem, public nsIJumpListShortcut
    90 {
    91 public:
    92   JumpListShortcut() :
    93    JumpListItem(nsIJumpListItem::JUMPLIST_ITEM_SHORTCUT)
    94   {}
    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
   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);
   109 protected:
   110   int32_t mIconIndex;
   111   nsCOMPtr<nsIURI> mFaviconPageURI;
   112   nsCOMPtr<nsILocalHandlerApp> mHandlerApp;
   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 };
   123 } // namespace widget
   124 } // namespace mozilla
   126 #endif /* __JumpListItem_h__ */

mercurial