| Index: webkit/glue/plugins/plugin_group.cc
|
| diff --git a/webkit/glue/plugins/plugin_group.cc b/webkit/glue/plugins/plugin_group.cc
|
| index 668621d87875cf7bb23cf477b1f44a1acae66b29..197466ff9b7e5cb41530d4ccc85e78fe52508a76 100644
|
| --- a/webkit/glue/plugins/plugin_group.cc
|
| +++ b/webkit/glue/plugins/plugin_group.cc
|
| @@ -112,8 +112,10 @@ void PluginGroup::InitFrom(const PluginGroup& other) {
|
| for (size_t i = 0; i < other.version_ranges_.size(); ++i)
|
| version_ranges_.push_back(other.version_ranges_[i]);
|
| DCHECK_EQ(other.web_plugin_infos_.size(), other.web_plugin_positions_.size());
|
| - for (size_t i = 0; i < other.web_plugin_infos_.size(); ++i)
|
| - AddPlugin(other.web_plugin_infos_[i], other.web_plugin_positions_[i]);
|
| + std::list<WebPluginInfo>::const_iterator it = other.web_plugin_infos_.begin();
|
| + std::vector<int>::const_iterator itprio = other.web_plugin_positions_.begin();
|
| + for (; it != other.web_plugin_infos_.end(); ++it, ++itprio)
|
| + AddPlugin(*it, *itprio);
|
| if (!version_.get())
|
| version_.reset(Version::GetVersionFromString("0"));
|
| }
|
| @@ -235,20 +237,31 @@ void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) {
|
| version_.reset(Version::GetVersionFromString("0"));
|
| }
|
|
|
| -void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) {
|
| +WebPluginInfo* PluginGroup::AddPlugin(
|
| + const WebPluginInfo& plugin, int position) {
|
| // Check if this group already contains this plugin.
|
| - for (size_t i = 0; i < web_plugin_infos_.size(); ++i) {
|
| - if (web_plugin_infos_[i].name == plugin.name &&
|
| - web_plugin_infos_[i].version == plugin.version &&
|
| - FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(),
|
| + for (std::list<WebPluginInfo>::iterator it = web_plugin_infos_.begin();
|
| + it != web_plugin_infos_.end(); ++it) {
|
| + if (it->name == plugin.name &&
|
| + it->version == plugin.version &&
|
| + FilePath::CompareEqualIgnoreCase(it->path.value(),
|
| plugin.path.value())) {
|
| - return;
|
| + return NULL;
|
| }
|
| }
|
| 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);
|
| + return &web_plugin_infos_.back();
|
| +}
|
| +
|
| +std::list<WebPluginInfo>& PluginGroup::GetPlugins() {
|
| + return web_plugin_infos_;
|
| +}
|
| +
|
| +std::vector<int>& PluginGroup::GetPluginPositions() {
|
| + return web_plugin_positions_;
|
| }
|
|
|
| string16 PluginGroup::GetGroupName() const {
|
| @@ -256,7 +269,7 @@ string16 PluginGroup::GetGroupName() const {
|
| return group_name_;
|
| DCHECK_EQ(1u, web_plugin_infos_.size());
|
| FilePath::StringType path =
|
| - web_plugin_infos_[0].path.BaseName().RemoveExtension().value();
|
| + web_plugin_infos_.front().path.BaseName().RemoveExtension().value();
|
| #if defined(OS_POSIX)
|
| return UTF8ToUTF16(path);
|
| #elif defined(OS_WIN)
|
| @@ -283,9 +296,11 @@ DictionaryValue* PluginGroup::GetDataForUI() const {
|
| bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(name);
|
| ListValue* plugin_files = new ListValue();
|
| bool all_plugins_disabled_by_policy = true;
|
| - for (size_t i = 0; i < web_plugin_infos_.size(); ++i) {
|
| - const WebPluginInfo& web_plugin = web_plugin_infos_[i];
|
| - int priority = web_plugin_positions_[i];
|
| + std::vector<int>::const_iterator itprio = web_plugin_positions_.begin();
|
| + for (std::list<WebPluginInfo>::const_iterator it = web_plugin_infos_.begin();
|
| + it != web_plugin_infos_.end(); ++it, ++itprio) {
|
| + const WebPluginInfo& web_plugin = *it;
|
| + int priority = *itprio;
|
| DictionaryValue* plugin_file = new DictionaryValue();
|
| plugin_file->SetString("name", web_plugin.name);
|
| plugin_file->SetString("description", web_plugin.desc);
|
| @@ -369,37 +384,50 @@ bool PluginGroup::IsVulnerable() const {
|
| }
|
|
|
| void PluginGroup::DisableOutdatedPlugins() {
|
| - description_ = string16();
|
| - enabled_ = false;
|
| + bool first_enabled = true;
|
| +
|
| + for (std::list<WebPluginInfo>::iterator it = web_plugin_infos_.begin();
|
| + it != web_plugin_infos_.end(); ++it) {
|
| + scoped_ptr<Version> version(CreateVersionFromString(it->version));
|
| + if (version.get()) {
|
| + bool plugin_is_outdated = false;
|
| + for (size_t i = 0; i < version_ranges_.size(); ++i) {
|
| + if (IsPluginOutdated(*version, version_ranges_[i])) {
|
| + NPAPI::PluginList::Singleton()->DisablePlugin(it->path, false);
|
| + plugin_is_outdated = true;
|
| + break;
|
| + }
|
| + }
|
| + if (!plugin_is_outdated && first_enabled) {
|
| + first_enabled = false;
|
| + UpdateDescriptionAndVersion(*it);
|
| + }
|
| + }
|
| + }
|
| +}
|
|
|
| - for (std::vector<WebPluginInfo>::iterator it =
|
| - web_plugin_infos_.begin();
|
| +void PluginGroup::Enable(bool enable) {
|
| + bool enabled_plugin_exists = false;
|
| + for (std::list<WebPluginInfo>::iterator it = web_plugin_infos_.begin();
|
| it != web_plugin_infos_.end(); ++it) {
|
| - scoped_ptr<Version> version(CreateVersionFromString(it->version));
|
| - if (version.get()) {
|
| - for (size_t i = 0; i < version_ranges_.size(); ++i) {
|
| - if (IsPluginOutdated(*version, version_ranges_[i])) {
|
| - it->enabled = false;
|
| - NPAPI::PluginList::Singleton()->DisablePlugin(it->path);
|
| - }
|
| - }
|
| + bool policy_disabled = IsPluginNameDisabledByPolicy(it->name);
|
| + if (enable && !policy_disabled) {
|
| + NPAPI::PluginList::Singleton()->EnablePlugin(it->path);
|
| + enabled_plugin_exists = true;
|
| + } else {
|
| + NPAPI::PluginList::Singleton()->DisablePlugin(it->path, policy_disabled);
|
| }
|
| - UpdateActivePlugin(*it);
|
| }
|
| + enabled_ = enabled_plugin_exists;
|
| }
|
|
|
| -void PluginGroup::Enable(bool enable) {
|
| +void PluginGroup::RefreshEnabledState() {
|
| bool enabled_plugin_exists = false;
|
| - for (std::vector<WebPluginInfo>::iterator it =
|
| - web_plugin_infos_.begin();
|
| + for (std::list<WebPluginInfo>::iterator it = web_plugin_infos_.begin();
|
| it != web_plugin_infos_.end(); ++it) {
|
| - if (enable && !IsPluginNameDisabledByPolicy(it->name)) {
|
| - NPAPI::PluginList::Singleton()->EnablePlugin(it->path);
|
| - it->enabled = true;
|
| + if (it->enabled) {
|
| enabled_plugin_exists = true;
|
| - } else {
|
| - it->enabled = false;
|
| - NPAPI::PluginList::Singleton()->DisablePlugin(it->path);
|
| + break;
|
| }
|
| }
|
| enabled_ = enabled_plugin_exists;
|
|
|