Line data Source code
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 AddonManagerStartup_h
7 : #define AddonManagerStartup_h
8 :
9 : #include "amIAddonManagerStartup.h"
10 : #include "mozilla/Result.h"
11 : #include "nsCOMArray.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsIFile.h"
14 : #include "nsISupports.h"
15 :
16 : #include "jsapi.h"
17 :
18 : namespace mozilla {
19 :
20 : class Addon;
21 :
22 : class AddonManagerStartup final : public amIAddonManagerStartup
23 : {
24 : public:
25 : NS_DECL_ISUPPORTS
26 : NS_DECL_AMIADDONMANAGERSTARTUP
27 :
28 : AddonManagerStartup();
29 :
30 : static AddonManagerStartup& GetSingleton();
31 :
32 1 : static already_AddRefed<AddonManagerStartup> GetInstance()
33 : {
34 2 : RefPtr<AddonManagerStartup> inst = &GetSingleton();
35 2 : return inst.forget();
36 : }
37 :
38 16 : const nsCOMArray<nsIFile>& ExtensionPaths()
39 : {
40 16 : return mExtensionPaths;
41 : }
42 :
43 : const nsCOMArray<nsIFile>& ThemePaths()
44 : {
45 : return mExtensionPaths;
46 : }
47 :
48 : private:
49 : Result<Ok, nsresult> AddInstallLocation(Addon& addon);
50 :
51 : nsIFile* ProfileDir();
52 :
53 : nsCOMPtr<nsIFile> mProfileDir;
54 :
55 : nsCOMArray<nsIFile> mExtensionPaths;
56 : nsCOMArray<nsIFile> mThemePaths;
57 :
58 : bool mInitialized;
59 :
60 : protected:
61 0 : virtual ~AddonManagerStartup() = default;
62 : };
63 :
64 : } // namespace mozilla
65 :
66 : #define NS_ADDONMANAGERSTARTUP_CONTRACTID \
67 : "@mozilla.org/addons/addon-manager-startup;1"
68 :
69 : // {17a59a6b-92b8-42e5-bce0-ab434c7a7135
70 : #define NS_ADDON_MANAGER_STARTUP_CID \
71 : { 0x17a59a6b, 0x92b8, 0x42e5, \
72 : { 0xbc, 0xe0, 0xab, 0x43, 0x4c, 0x7a, 0x71, 0x35 } }
73 :
74 : #endif // AddonManagerStartup_h
|