 Chromium Code Reviews
 Chromium Code Reviews Issue 5699005:
  Policy: Re-enabled plugin still disabled  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 5699005:
  Policy: Re-enabled plugin still disabled  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: webkit/glue/plugins/webplugininfo.cc | 
| diff --git a/webkit/glue/plugins/webplugininfo.cc b/webkit/glue/plugins/webplugininfo.cc | 
| index 7d2b4e447e6c32c3ce733f3d14e71f13c585e271..c6ed4edaa0440e221de0660964bfb4c4010ca2ed 100644 | 
| --- a/webkit/glue/plugins/webplugininfo.cc | 
| +++ b/webkit/glue/plugins/webplugininfo.cc | 
| @@ -4,11 +4,21 @@ | 
| #include "webkit/glue/plugins/webplugininfo.h" | 
| +#include "base/logging.h" | 
| +#include "net/base/mime_util.h" | 
| + | 
| +const int WebPluginInfo::USER = 1; | 
| +const int WebPluginInfo::MANAGED = 2; | 
| + | 
| WebPluginMimeType::WebPluginMimeType() {} | 
| WebPluginMimeType::~WebPluginMimeType() {} | 
| -WebPluginInfo::WebPluginInfo() : enabled(false) {} | 
| +WebPluginInfo::WebPluginInfo() | 
| + : enabled(false), | 
| + reason(USER), | 
| + priority(0) { | 
| +} | 
| WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs) | 
| : name(rhs.name), | 
| @@ -16,7 +26,9 @@ WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs) | 
| version(rhs.version), | 
| desc(rhs.desc), | 
| mime_types(rhs.mime_types), | 
| - enabled(rhs.enabled) { | 
| + enabled(rhs.enabled), | 
| + reason(rhs.reason), | 
| + priority(rhs.priority) { | 
| } | 
| WebPluginInfo::~WebPluginInfo() {} | 
| @@ -28,17 +40,83 @@ WebPluginInfo& WebPluginInfo::operator=(const WebPluginInfo& rhs) { | 
| desc = rhs.desc; | 
| mime_types = rhs.mime_types; | 
| enabled = rhs.enabled; | 
| + reason = rhs.reason; | 
| + priority = rhs.priority; | 
| return *this; | 
| } | 
| WebPluginInfo::WebPluginInfo(const string16& fake_name, | 
| + const FilePath& fake_path, | 
| const string16& fake_version, | 
| const string16& fake_desc) | 
| : name(fake_name), | 
| - path(), | 
| + path(fake_path), | 
| version(fake_version), | 
| desc(fake_desc), | 
| mime_types(), | 
| - enabled(true) { | 
| + enabled(true), | 
| + reason(USER), | 
| + priority(0) { | 
| +} | 
| + | 
| +bool WebPluginInfo::Enable(int new_reason) { | 
| + // If already enabled just upgrade the reason. | 
| + if (enabled) { | 
| + reason |= new_reason; | 
| + return true; | 
| + } else { | 
| + // Only changeable if not managed. | 
| + if (IsManaged(reason)) return false; | 
| + enabled = true; | 
| + reason = new_reason; | 
| + } | 
| + return true; | 
| +} | 
| + | 
| +bool WebPluginInfo::Disable(int new_reason) { | 
| + // If already disabled just upgrade the reason. | 
| + if (!enabled) { | 
| + reason |= new_reason; | 
| + return true; | 
| + } else { | 
| + // Only changeable if not managed. | 
| + if (IsManaged(reason)) return false; | 
| 
Bernhard Bauer
2010/12/17 18:50:59
Nit: The coding style says it's okay, but personal
 
pastarmovj
2010/12/20 19:57:37
Done.
 | 
| + enabled = false; | 
| + reason = new_reason; | 
| + } | 
| + return true; | 
| +} | 
| + | 
| +bool WebPluginInfo::SupportsType(const std::string& mime_type, | 
| + bool allow_wildcard) const { | 
| + // Webkit will ask for a plugin to handle empty mime types. | 
| + if (mime_type.empty()) | 
| + return false; | 
| + | 
| + for (size_t i = 0; i < mime_types.size(); ++i) { | 
| + const WebPluginMimeType& mime_info = mime_types[i]; | 
| + if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { | 
| + if (!allow_wildcard && mime_info.mime_type == "*") { | 
| 
Bernhard Bauer
2010/12/17 18:50:59
Nit: Braces unnecessary.
 
pastarmovj
2010/12/20 19:57:37
Done. This is legacy code just moved here but I tu
 | 
| + continue; | 
| + } | 
| + return true; | 
| + } | 
| + } | 
| + return false; | 
| } | 
| +bool WebPluginInfo::SupportsExtension(const std::string& extension, | 
| + std::string* actual_mime_type) const { | 
| + for (size_t i = 0; i < mime_types.size(); ++i) { | 
| + const WebPluginMimeType& mime_type = mime_types[i]; | 
| + for (size_t j = 0; j < mime_type.file_extensions.size(); ++j) { | 
| + if (mime_type.file_extensions[j] == extension) { | 
| + if (actual_mime_type) | 
| + *actual_mime_type = mime_type.mime_type; | 
| + return true; | 
| + } | 
| + } | 
| + } | 
| + | 
| + return false; | 
| +} |