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