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 __JumpListBuilder_h__
7 #define __JumpListBuilder_h__
8 
9 #include <windows.h>
10 
11 #undef NTDDI_VERSION
12 #define NTDDI_VERSION NTDDI_WIN7
13 // Needed for various com interfaces
14 #include <shobjidl.h>
15 #undef LogSeverity  // SetupAPI.h #defines this as DWORD
16 
17 #include "nsString.h"
18 #include "nsIMutableArray.h"
19 
20 #include "nsIJumpListBuilder.h"
21 #include "nsIJumpListItem.h"
22 #include "JumpListItem.h"
23 #include "nsIObserver.h"
24 #include "mozilla/Attributes.h"
25 #include "mozilla/ReentrantMonitor.h"
26 
27 namespace mozilla {
28 namespace widget {
29 
30 namespace detail {
31 class DoneCommitListBuildCallback;
32 }  // namespace detail
33 
34 class JumpListBuilder : public nsIJumpListBuilder, public nsIObserver {
35   virtual ~JumpListBuilder();
36 
37  public:
38   NS_DECL_ISUPPORTS
39   NS_DECL_NSIJUMPLISTBUILDER
40   NS_DECL_NSIOBSERVER
41 
42   JumpListBuilder();
43 
44  protected:
45   static Atomic<bool> sBuildingList;
46 
47  private:
48   RefPtr<ICustomDestinationList> mJumpListMgr;
49   uint32_t mMaxItems;
50   bool mHasCommit;
51   nsCOMPtr<nsIThread> mIOThread;
52   ReentrantMonitor mMonitor;
53 
54   bool IsSeparator(nsCOMPtr<nsIJumpListItem> &item);
55   nsresult TransferIObjectArrayToIMutableArray(IObjectArray *objArray,
56                                                nsIMutableArray *removedItems);
57   nsresult RemoveIconCacheForItems(nsIMutableArray *removedItems);
58   nsresult RemoveIconCacheForAllItems();
59   void DoCommitListBuild(RefPtr<detail::DoneCommitListBuildCallback> aCallback);
60 
61   friend class WinTaskbar;
62 };
63 
64 }  // namespace widget
65 }  // namespace mozilla
66 
67 #endif /* __JumpListBuilder_h__ */
68