OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ | |
6 #define WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/file_path.h" | |
13 | |
14 namespace webkit { | |
15 namespace npapi { | |
16 | |
17 // Describes a mime type entry for a plugin. | |
18 // TODO(viettrungluu): This isn't NPAPI-specific. Move this somewhere else. | |
19 struct WebPluginMimeType { | |
20 WebPluginMimeType(); | |
21 // A constructor for the common case of a single file extension and an ASCII | |
22 // description. | |
23 WebPluginMimeType(const std::string& m, | |
24 const std::string& f, | |
25 const std::string& d); | |
26 ~WebPluginMimeType(); | |
27 | |
28 // The name of the mime type (e.g., "application/x-shockwave-flash"). | |
29 std::string mime_type; | |
30 | |
31 // A list of all the file extensions for this mime type. | |
32 std::vector<std::string> file_extensions; | |
33 | |
34 // Description of the mime type. | |
35 string16 description; | |
36 | |
37 // Extra parameters to include when instantiating the plugin. | |
38 std::vector<string16> additional_param_names; | |
39 std::vector<string16> additional_param_values; | |
40 }; | |
41 | |
42 // Describes an available NPAPI plugin. | |
43 struct WebPluginInfo { | |
44 // Defines the possible enabled state a plugin can have. | |
45 // The enum values actually represent a 3-bit bitfield : | |
46 // |PE|PD|U| - where |PE|PD| is policy state and U is user state. | |
47 // PE == 1 means the plugin is forced to enabled state by policy | |
48 // PD == 1 means the plugin is forced to disabled by policy | |
49 // PE and PD CAN'T be both 1 but can be both 0 which mean no policy is set. | |
50 // U == 1 means the user has disabled the plugin. | |
51 // Because the plugin user state might have been changed before a policy was | |
52 // introduced the user state might contradict the policy state in which case | |
53 // the policy has precedence. | |
54 enum EnabledStates { | |
55 USER_ENABLED = 0, | |
56 USER_DISABLED = 1 << 0, | |
57 POLICY_DISABLED = 1 << 1, | |
58 POLICY_ENABLED = 1 << 2, | |
59 USER_ENABLED_POLICY_UNMANAGED = USER_ENABLED, | |
60 USER_ENABLED_POLICY_DISABLED = USER_ENABLED| POLICY_DISABLED, | |
61 USER_ENABLED_POLICY_ENABLED = USER_ENABLED | POLICY_ENABLED, | |
62 USER_DISABLED_POLICY_UNMANAGED = USER_DISABLED, | |
63 USER_DISABLED_POLICY_DISABLED = USER_DISABLED | POLICY_DISABLED, | |
64 USER_DISABLED_POLICY_ENABLED = USER_DISABLED | POLICY_ENABLED, | |
65 USER_MASK = USER_DISABLED, | |
66 MANAGED_MASK = POLICY_DISABLED | POLICY_ENABLED, | |
67 POLICY_UNMANAGED = -1 | |
68 }; | |
69 | |
70 WebPluginInfo(); | |
71 WebPluginInfo(const WebPluginInfo& rhs); | |
72 ~WebPluginInfo(); | |
73 WebPluginInfo& operator=(const WebPluginInfo& rhs); | |
74 | |
75 // Special constructor only used during unit testing: | |
76 WebPluginInfo(const string16& fake_name, | |
77 const FilePath& fake_path, | |
78 const string16& fake_version, | |
79 const string16& fake_desc); | |
80 | |
81 // The name of the plugin (i.e. Flash). | |
82 string16 name; | |
83 | |
84 // The path to the plugin file (DLL/bundle/library). | |
85 FilePath path; | |
86 | |
87 // The version number of the plugin file (may be OS-specific) | |
88 string16 version; | |
89 | |
90 // A description of the plugin that we get from its version info. | |
91 string16 desc; | |
92 | |
93 // A list of all the mime types that this plugin supports. | |
94 std::vector<WebPluginMimeType> mime_types; | |
95 | |
96 // Enabled state of the plugin. See the EnabledStates enum. | |
97 int enabled; | |
98 }; | |
99 | |
100 // Checks whether a plugin is enabled either by the user or by policy. | |
101 bool IsPluginEnabled(const WebPluginInfo& plugin); | |
102 | |
103 } // namespace npapi | |
104 } // namespace webkit | |
105 | |
106 #endif // WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ | |
OLD | NEW |