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

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: Make win and mac compilers happy. 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..0093e95f74fe317a2be12269b7058dd8e343b9c8 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"
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,29 @@ 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.
+ void AddPlugin(const WebPluginInfo& plugin);
- 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);
+
+ // Checks whether the group should be disabled/enabled by a policy and puts
+ // it in the needed state. Updates all contained plugins too.
+ void EnforceGroupPolicy();
// Returns whether the plugin group is enabled or not.
bool Enabled() const { return enabled_; }
@@ -117,10 +126,21 @@ class PluginGroup {
// string otherwise.
const std::string& identifier() const { return identifier_; }
+ // Returns a unique identifier for this group, if one is defined, or the empty
+ // string otherwise.
+ std::string& identifier() { return identifier_; }
jam 2011/01/20 18:22:34 our style guide disallows non-const references. f
pastarmovj 2011/01/20 22:59:49 Done.
+
// Returns this group's name, or the filename without extension if the name
// is empty.
string16 GetGroupName() const;
+ // Returns all plugins added to the group.
+ std::vector<WebPluginInfo>& web_info_plugins();
jam 2011/01/20 18:22:34 the non const version seems dangereous to have as
pastarmovj 2011/01/20 22:59:49 Done. Sorry for the word swap there :(
+ const std::vector<WebPluginInfo>& web_info_plugins() const;
+
+ // Checks whether a plugin exists in the group with the given path.
+ 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 +157,10 @@ class PluginGroup {
// security problems.
bool IsVulnerable() const;
+ // Check if the group has no plugins. Could happen after a reload if the plug-
+ // in has disappeared from the pc (or in the process of updating).
+ bool IsEmpty() const;
+
// Disables all plugins in this group that are older than the
// minimum version.
void DisableOutdatedPlugins();
@@ -146,9 +170,8 @@ class PluginGroup {
static Version* CreateVersionFromString(const string16& version_string);
private:
- 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;
@@ -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