Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / widget / windows / JumpListBuilder.h
blobe228669f11c524ec9e82363b13578d2c8dd4151e
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 __JumpListBuilder_h__
7 #define __JumpListBuilder_h__
9 #include "nsIJumpListBuilder.h"
11 #include "nsIObserver.h"
12 #include "nsProxyRelease.h"
13 #include "mozilla/LazyIdleThread.h"
15 namespace mozilla {
17 namespace dom {
18 struct WindowsJumpListShortcutDescription;
19 } // namespace dom
21 namespace widget {
23 /**
24 * This is an abstract class for a backend to write to the Windows Jump List.
26 * It has a 1-to-1 method mapping with ICustomDestinationList. The abtract
27 * class allows us to implement a "fake" backend for automated testing.
29 class JumpListBackend {
30 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
32 virtual bool IsAvailable() = 0;
34 virtual HRESULT SetAppID(LPCWSTR pszAppID) = 0;
35 virtual HRESULT BeginList(UINT* pcMinSlots, REFIID riid, void** ppv) = 0;
36 virtual HRESULT AddUserTasks(IObjectArray* poa) = 0;
37 virtual HRESULT AppendCategory(LPCWSTR pszCategory, IObjectArray* poa) = 0;
38 virtual HRESULT CommitList() = 0;
39 virtual HRESULT AbortList() = 0;
40 virtual HRESULT DeleteList(LPCWSTR pszAppID) = 0;
41 virtual HRESULT AppendKnownCategory(KNOWNDESTCATEGORY category) = 0;
43 protected:
44 virtual ~JumpListBackend() {}
47 /**
48 * JumpListBuilder is a component that can be used to manage the Windows
49 * Jump List off of the main thread.
51 class JumpListBuilder : public nsIJumpListBuilder, public nsIObserver {
52 virtual ~JumpListBuilder();
54 public:
55 NS_DECL_THREADSAFE_ISUPPORTS
56 NS_DECL_NSIJUMPLISTBUILDER
57 NS_DECL_NSIOBSERVER
59 explicit JumpListBuilder(const nsAString& aAppUserModelId,
60 RefPtr<JumpListBackend> aTestingBackend = nullptr);
62 private:
63 // These all run on the lazy helper thread.
64 void DoSetupBackend();
65 void DoSetupTestingBackend(RefPtr<JumpListBackend> aTestingBackend);
66 void DoShutdownBackend();
67 void DoSetAppID(nsString aAppUserModelID);
68 void DoIsAvailable(const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);
69 void DoCheckForRemovals(
70 const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);
71 void DoPopulateJumpList(
72 const nsTArray<dom::WindowsJumpListShortcutDescription>&&
73 aTaskDescriptions,
74 const nsAString& aCustomTitle,
75 const nsTArray<dom::WindowsJumpListShortcutDescription>&&
76 aCustomDescriptions,
77 const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);
78 void DoClearJumpList(
79 const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);
80 void RemoveIconCacheAndGetJumplistShortcutURIs(IObjectArray* aObjArray,
81 nsTArray<nsString>& aURISpecs);
82 void DeleteIconFromDisk(const nsAString& aPath);
83 nsresult GetShellLinkFromDescription(
84 const dom::WindowsJumpListShortcutDescription& aDesc,
85 RefPtr<IShellLinkW>& aShellLink);
87 // This is written to once during construction on the main thread before the
88 // lazy helper thread is created. After that, the lazy helper thread might
89 // read from it.
90 nsString mAppUserModelId;
92 // This is only accessed by the lazy helper thread.
93 RefPtr<JumpListBackend> mJumpListBackend;
95 // This is only accessed by the main thread.
96 RefPtr<LazyIdleThread> mIOThread;
99 } // namespace widget
100 } // namespace mozilla
102 #endif /* __JumpListBuilder_h__ */