|
1 /* -*- Mode: C++; tab-width: 4; 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 nsPluginsDir_h_ |
|
7 #define nsPluginsDir_h_ |
|
8 |
|
9 #include "nsError.h" |
|
10 #include "nsIFile.h" |
|
11 |
|
12 /** |
|
13 * nsPluginsDir is nearly obsolete. Directory Service should be used instead. |
|
14 * It exists for the sake of one static function. |
|
15 */ |
|
16 |
|
17 class nsPluginsDir { |
|
18 public: |
|
19 /** |
|
20 * Determines whether or not the given file is actually a plugin file. |
|
21 */ |
|
22 static bool IsPluginFile(nsIFile* file); |
|
23 }; |
|
24 |
|
25 struct PRLibrary; |
|
26 |
|
27 struct nsPluginInfo { |
|
28 char* fName; // name of the plugin |
|
29 char* fDescription; // etc. |
|
30 uint32_t fVariantCount; |
|
31 char** fMimeTypeArray; |
|
32 char** fMimeDescriptionArray; |
|
33 char** fExtensionArray; |
|
34 char* fFileName; |
|
35 char* fFullPath; |
|
36 char* fVersion; |
|
37 }; |
|
38 |
|
39 /** |
|
40 * Provides cross-platform access to a plugin file. Deals with reading |
|
41 * properties from the plugin file, and loading the plugin's shared |
|
42 * library. Insulates core nsIPluginHost implementations from these |
|
43 * details. |
|
44 */ |
|
45 class nsPluginFile { |
|
46 PRLibrary* pLibrary; |
|
47 nsCOMPtr<nsIFile> mPlugin; |
|
48 public: |
|
49 /** |
|
50 * If spec corresponds to a valid plugin file, constructs a reference |
|
51 * to a plugin file on disk. Plugins are typically located using the |
|
52 * nsPluginsDir class. |
|
53 */ |
|
54 nsPluginFile(nsIFile* spec); |
|
55 virtual ~nsPluginFile(); |
|
56 |
|
57 /** |
|
58 * Loads the plugin into memory using NSPR's shared-library loading |
|
59 * mechanism. Handles platform differences in loading shared libraries. |
|
60 */ |
|
61 nsresult LoadPlugin(PRLibrary **outLibrary); |
|
62 |
|
63 /** |
|
64 * Obtains all of the information currently available for this plugin. |
|
65 * Has a library outparam which will be non-null if a library load was required. |
|
66 */ |
|
67 nsresult GetPluginInfo(nsPluginInfo &outPluginInfo, PRLibrary **outLibrary); |
|
68 |
|
69 /** |
|
70 * Should be called after GetPluginInfo to free all allocated stuff |
|
71 */ |
|
72 nsresult FreePluginInfo(nsPluginInfo &PluginInfo); |
|
73 }; |
|
74 |
|
75 #endif /* nsPluginsDir_h_ */ |