| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/plugin_group.h" | 5 #include "webkit/plugins/npapi/plugin_group.h" |
| 6 | 6 |
| 7 #include "base/linked_ptr.h" | 7 #include "base/linked_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "webkit/glue/plugins/plugin_list.h" | 13 #include "webkit/plugins/npapi/plugin_list.h" |
| 14 #include "webkit/glue/plugins/webplugininfo.h" | 14 #include "webkit/plugins/npapi/webplugininfo.h" |
| 15 |
| 16 namespace webkit { |
| 17 namespace npapi { |
| 15 | 18 |
| 16 const char* PluginGroup::kAdobeReaderGroupName = "Adobe Reader"; | 19 const char* PluginGroup::kAdobeReaderGroupName = "Adobe Reader"; |
| 17 | 20 |
| 18 /*static*/ | 21 /*static*/ |
| 19 std::set<string16>* PluginGroup::policy_disabled_plugin_patterns_; | 22 std::set<string16>* PluginGroup::policy_disabled_plugin_patterns_; |
| 20 | 23 |
| 21 /*static*/ | 24 /*static*/ |
| 22 void PluginGroup::SetPolicyDisabledPluginPatterns( | 25 void PluginGroup::SetPolicyDisabledPluginPatterns( |
| 23 const std::set<string16>& set) { | 26 const std::set<string16>& set) { |
| 24 if (!policy_disabled_plugin_patterns_) | 27 if (!policy_disabled_plugin_patterns_) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 return true; | 42 return true; |
| 40 ++pattern; | 43 ++pattern; |
| 41 } | 44 } |
| 42 | 45 |
| 43 return false; | 46 return false; |
| 44 } | 47 } |
| 45 | 48 |
| 46 /*static*/ | 49 /*static*/ |
| 47 bool PluginGroup::IsPluginPathDisabledByPolicy(const FilePath& plugin_path) { | 50 bool PluginGroup::IsPluginPathDisabledByPolicy(const FilePath& plugin_path) { |
| 48 std::vector<WebPluginInfo> plugins; | 51 std::vector<WebPluginInfo> plugins; |
| 49 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 52 PluginList::Singleton()->GetPlugins(false, &plugins); |
| 50 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); | 53 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); |
| 51 it != plugins.end(); | 54 it != plugins.end(); |
| 52 ++it) { | 55 ++it) { |
| 53 if (FilePath::CompareEqualIgnoreCase(it->path.value(), | 56 if (FilePath::CompareEqualIgnoreCase(it->path.value(), |
| 54 plugin_path.value()) && IsPluginNameDisabledByPolicy(it->name)) { | 57 plugin_path.value()) && IsPluginNameDisabledByPolicy(it->name)) { |
| 55 return true; | 58 return true; |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 return false; | 61 return false; |
| 59 } | 62 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 enabled_ = false; | 377 enabled_ = false; |
| 375 | 378 |
| 376 for (std::vector<WebPluginInfo>::iterator it = | 379 for (std::vector<WebPluginInfo>::iterator it = |
| 377 web_plugin_infos_.begin(); | 380 web_plugin_infos_.begin(); |
| 378 it != web_plugin_infos_.end(); ++it) { | 381 it != web_plugin_infos_.end(); ++it) { |
| 379 scoped_ptr<Version> version(CreateVersionFromString(it->version)); | 382 scoped_ptr<Version> version(CreateVersionFromString(it->version)); |
| 380 if (version.get()) { | 383 if (version.get()) { |
| 381 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 384 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
| 382 if (IsPluginOutdated(*version, version_ranges_[i])) { | 385 if (IsPluginOutdated(*version, version_ranges_[i])) { |
| 383 it->enabled = false; | 386 it->enabled = false; |
| 384 NPAPI::PluginList::Singleton()->DisablePlugin(it->path); | 387 PluginList::Singleton()->DisablePlugin(it->path); |
| 385 } | 388 } |
| 386 } | 389 } |
| 387 } | 390 } |
| 388 UpdateActivePlugin(*it); | 391 UpdateActivePlugin(*it); |
| 389 } | 392 } |
| 390 } | 393 } |
| 391 | 394 |
| 392 void PluginGroup::Enable(bool enable) { | 395 void PluginGroup::Enable(bool enable) { |
| 393 bool enabled_plugin_exists = false; | 396 bool enabled_plugin_exists = false; |
| 394 for (std::vector<WebPluginInfo>::iterator it = | 397 for (std::vector<WebPluginInfo>::iterator it = |
| 395 web_plugin_infos_.begin(); | 398 web_plugin_infos_.begin(); |
| 396 it != web_plugin_infos_.end(); ++it) { | 399 it != web_plugin_infos_.end(); ++it) { |
| 397 if (enable && !IsPluginNameDisabledByPolicy(it->name)) { | 400 if (enable && !IsPluginNameDisabledByPolicy(it->name)) { |
| 398 NPAPI::PluginList::Singleton()->EnablePlugin(it->path); | 401 PluginList::Singleton()->EnablePlugin(it->path); |
| 399 it->enabled = true; | 402 it->enabled = true; |
| 400 enabled_plugin_exists = true; | 403 enabled_plugin_exists = true; |
| 401 } else { | 404 } else { |
| 402 it->enabled = false; | 405 it->enabled = false; |
| 403 NPAPI::PluginList::Singleton()->DisablePlugin(it->path); | 406 PluginList::Singleton()->DisablePlugin(it->path); |
| 404 } | 407 } |
| 405 } | 408 } |
| 406 enabled_ = enabled_plugin_exists; | 409 enabled_ = enabled_plugin_exists; |
| 407 } | 410 } |
| 411 |
| 412 } // namespace npapi |
| 413 } // namespace webkit |
| OLD | NEW |