| Index: webkit/glue/plugins/webplugininfo.cc
|
| diff --git a/webkit/glue/plugins/webplugininfo.cc b/webkit/glue/plugins/webplugininfo.cc
|
| index 7d2b4e447e6c32c3ce733f3d14e71f13c585e271..6c89580ef2cc96c505f49898125648414e66370f 100644
|
| --- a/webkit/glue/plugins/webplugininfo.cc
|
| +++ b/webkit/glue/plugins/webplugininfo.cc
|
| @@ -4,11 +4,18 @@
|
|
|
| #include "webkit/glue/plugins/webplugininfo.h"
|
|
|
| +#include "base/logging.h"
|
| +#include "net/base/mime_util.h"
|
| +
|
| 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 +23,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 +37,84 @@ 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(WebPluginInfo::Reason 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(WebPluginInfo::Reason 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;
|
| + 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 == "*")
|
| + 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;
|
| +}
|
|
|