summaryrefslogtreecommitdiffstats
path: root/chrome/common/plugin_group.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 07:37:42 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 07:37:42 +0000
commit84bee7eacce94576b79e295595394181a015ac8a (patch)
tree9a39f6f092b4691032dc9ce9a6c17684a03b11b7 /chrome/common/plugin_group.cc
parentd81288a066ccb0b938fa883a67dad1fa232dd550 (diff)
downloadchromium_src-84bee7eacce94576b79e295595394181a015ac8a.zip
chromium_src-84bee7eacce94576b79e295595394181a015ac8a.tar.gz
chromium_src-84bee7eacce94576b79e295595394181a015ac8a.tar.bz2
Disable outdated plug-ins on a per-plugin basis.
Change the automatic disabling of outdated plugins (with --disable-outdated-plugins) so that a single plugin is disabled if it is out of date instead of the whole group. This makes it possible to fall back on a newer version of a plugin that would otherwise have lower priority. BUG=47731,51728 TEST=Install an old version and a new version of a plugin, run with --disable-outdated-plugins. The old version should be disabled, and the effective version of the plugin group should be the new one. Review URL: http://codereview.chromium.org/3117009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/plugin_group.cc')
-rw-r--r--chrome/common/plugin_group.cc57
1 files changed, 41 insertions, 16 deletions
diff --git a/chrome/common/plugin_group.cc b/chrome/common/plugin_group.cc
index 2865ac1..5673fc5 100644
--- a/chrome/common/plugin_group.cc
+++ b/chrome/common/plugin_group.cc
@@ -223,28 +223,19 @@ bool PluginGroup::Match(const WebPluginInfo& plugin) const {
version_range_high_->CompareTo(*plugin_version) > 0);
}
-void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) {
- description_ = plugin.desc;
-
- // Update |version_|. Remove spaces and ')' from the version string,
+Version* PluginGroup::CreateVersionFromString(const string16& version_string) {
+ // Remove spaces and ')' from the version string,
// Replace any instances of 'r', ',' or '(' with a dot.
- std::wstring version = UTF16ToWide(plugin.version);
+ std::wstring version = UTF16ToWide(version_string);
RemoveChars(version, L") ", &version);
std::replace(version.begin(), version.end(), 'r', '.');
std::replace(version.begin(), version.end(), ',', '.');
std::replace(version.begin(), version.end(), '(', '.');
- if (Version* new_version = Version::GetVersionFromString(version))
- version_.reset(new_version);
- else
- version_.reset(Version::GetVersionFromString("0"));
+ return Version::GetVersionFromString(version);
}
-void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) {
- web_plugin_infos_.push_back(plugin);
- // The position of this plugin relative to the global list of plugins.
- web_plugin_positions_.push_back(position);
-
+void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) {
// A group is enabled if any of the files are enabled.
if (plugin.enabled) {
if (!enabled_) {
@@ -260,6 +251,21 @@ void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) {
}
}
+void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) {
+ description_ = plugin.desc;
+ if (Version* new_version = CreateVersionFromString(plugin.version))
+ version_.reset(new_version);
+ else
+ version_.reset(Version::GetVersionFromString("0"));
+}
+
+void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) {
+ web_plugin_infos_.push_back(plugin);
+ // The position of this plugin relative to the global list of plugins.
+ web_plugin_positions_.push_back(position);
+ UpdateActivePlugin(plugin);
+}
+
DictionaryValue* PluginGroup::GetSummary() const {
DictionaryValue* result = new DictionaryValue();
result->SetString("name", group_name_);
@@ -338,14 +344,33 @@ bool PluginGroup::IsVulnerable() const {
return version_->CompareTo(*min_version_) < 0;
}
+void PluginGroup::DisableOutdatedPlugins() {
+ if (!min_version_.get())
+ return;
+
+ description_ = string16();
+ enabled_ = false;
+
+ for (std::vector<WebPluginInfo>::iterator it =
+ web_plugin_infos_.begin();
+ it != web_plugin_infos_.end(); ++it) {
+ scoped_ptr<Version> version(CreateVersionFromString(it->version));
+ if (version.get() && version->CompareTo(*min_version_) < 0) {
+ it->enabled = false;
+ NPAPI::PluginList::Singleton()->DisablePlugin(it->path);
+ }
+ UpdateActivePlugin(*it);
+ }
+}
+
void PluginGroup::Enable(bool enable) {
for (std::vector<WebPluginInfo>::const_iterator it =
web_plugin_infos_.begin();
it != web_plugin_infos_.end(); ++it) {
if (enable && !IsPluginNameDisabledByPolicy(it->name)) {
- NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(it->path));
+ NPAPI::PluginList::Singleton()->EnablePlugin(it->path);
} else {
- NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(it->path));
+ NPAPI::PluginList::Singleton()->DisablePlugin(it->path);
}
}
}