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