Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: webkit/plugins/npapi/plugin_group.h

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/npapi/plugin_group.h
diff --git a/webkit/plugins/npapi/plugin_group.h b/webkit/plugins/npapi/plugin_group.h
index 308fee79a8185e542bd1121ffa7fee34f5c23747..ac6294bd08974df73c265e2af4e6e0d95b1fde62 100644
--- a/webkit/plugins/npapi/plugin_group.h
+++ b/webkit/plugins/npapi/plugin_group.h
@@ -14,6 +14,7 @@
#include "base/gtest_prod_util.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
+#include "webkit/plugins/npapi/webplugininfo.h"
jam 2011/01/15 00:51:34 nit: why is this needed?
pastarmovj 2011/01/18 18:30:39 I need the Definition of WebPluginInfo in several
class DictionaryValue;
class FilePath;
@@ -25,8 +26,9 @@ namespace webkit {
namespace npapi {
class PluginList;
-struct WebPluginInfo;
-
+namespace plugin_test_internal {
+class PluginListWithoutFileIO;
+}
// Hard-coded version ranges for plugin groups.
struct VersionRangeDefinition {
// Matcher for lowest version matched by this range (inclusive). May be empty
@@ -93,22 +95,31 @@ class PluginGroup {
// the lookup key.
static bool IsPluginNameDisabledByPolicy(const string16& plugin_name);
- // Tests to see if a plugin is on the blacklist using its path as
- // the lookup key.
- static bool IsPluginPathDisabledByPolicy(const FilePath& plugin_path);
-
// Returns true if the given plugin matches this group.
bool Match(const WebPluginInfo& plugin) const;
- // Adds the given plugin to this group. Provide the position of the
- // plugin as given by PluginList so we can display its priority.
- void AddPlugin(const WebPluginInfo& plugin, int position);
+ // Adds the given plugin to this group.
+ // Retuns true if plugin has been added and false if it was already contained
+ // in the group before.
+ bool AddPlugin(const WebPluginInfo& plugin, int priority);
- bool IsEmpty() const;
+ // Removes a plugin from the group by its path.
+ bool RemovePlugin(const FilePath& filename);
+
+ // The two following functions enable/disable a plugin given its filename. The
+ // function returns true if the plugin could be enabled/disabled. Plugins
+ // might not get enabled/disabled if they are controlled by policy or are
+ // already in the wanted state.
+ bool EnablePlugin(const FilePath& filename);
+ bool DisablePlugin(const FilePath& filename);
// Enables/disables this group. This enables/disables all plugins in the
// group.
- void Enable(bool enable);
+ bool EnableGroup(bool enable);
+
+ // Enables/disables this group. This enables/disables all plugins in the
+ // group.
+ void EnforceGroupPolicy();
// Returns whether the plugin group is enabled or not.
bool Enabled() const { return enabled_; }
@@ -121,6 +132,10 @@ class PluginGroup {
// is empty.
string16 GetGroupName() const;
+ const std::vector<WebPluginInfo>& GetPlugins() const;
+
+ bool ContainsPlugin(const FilePath& path) const;
+
// Returns the description of the highest-priority plug-in in the group.
const string16& description() const { return description_; }
@@ -137,6 +152,9 @@ class PluginGroup {
// security problems.
bool IsVulnerable() const;
+ // Check if the group has no plugins or only placeholder plugins.
jam 2011/01/15 00:51:34 I thought we're not adding the concept of placehol
pastarmovj 2011/01/18 18:30:39 I forgot to update the comment there. There are no
jam 2011/01/18 20:26:00 ok, so should I just wait for that before doing an
+ bool IsEmpty() const;
+
// Disables all plugins in this group that are older than the
// minimum version.
void DisableOutdatedPlugins();
@@ -149,6 +167,7 @@ class PluginGroup {
typedef std::map<std::string, PluginGroup*> PluginMap;
friend class PluginList;
+ friend class plugin_test_internal::PluginListWithoutFileIO;
friend class PluginGroupTest;
friend class ::TableModelArrayControllerTest;
friend class ::PluginExceptionsTableModelTest;
@@ -169,6 +188,10 @@ class PluginGroup {
// the created PluginGroup.
static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi);
+ // Creates an empty PluginGroup from a given name. The caller takes
+ // ownership of the created PluginGroup.
+ static PluginGroup* CreateEmptyGroup(const string16& name);
jam 2011/01/15 00:51:34 ditto
pastarmovj 2011/01/18 18:30:39 Removed.
+
// Returns |true| if |version| is contained in [low, high) of |range|.
static bool IsVersionInRange(const Version& version,
const VersionRange& range);
@@ -193,6 +216,17 @@ class PluginGroup {
// enabled one, or if all plugins are disabled, simply the first one.
void UpdateActivePlugin(const WebPluginInfo& plugin);
+ // Refreshes the enabled flag based on the state of its plugins.
+ void RefreshEnabledState();
+
+ // Enables the plugin if not already enabled and if policy allows it to.
+ // Returns true on success.
+ static bool Enable(WebPluginInfo* plugin, int reason);
+
+ // Disables the plugin if not already disabled and if policy allows it to.
+ // Returns true on success.
+ static bool Disable(WebPluginInfo* plugin, int reason);
+
static std::set<string16>* policy_disabled_plugin_patterns_;
std::string identifier_;
@@ -204,7 +238,6 @@ class PluginGroup {
std::vector<VersionRange> version_ranges_;
scoped_ptr<Version> version_;
std::vector<WebPluginInfo> web_plugin_infos_;
- std::vector<int> web_plugin_positions_;
};
} // namespace npapi

Powered by Google App Engine
This is Rietveld 408576698