| Index: chrome/browser/plugins/plugin_finder.cc
|
| diff --git a/chrome/browser/plugins/plugin_finder.cc b/chrome/browser/plugins/plugin_finder.cc
|
| index 2ac0b99352ce6c745c4b821415d7bf5057de0d6a..560d742e31e29e8cbc9fdd9fa9b8d7b91e3ae9e5 100644
|
| --- a/chrome/browser/plugins/plugin_finder.cc
|
| +++ b/chrome/browser/plugins/plugin_finder.cc
|
| @@ -69,13 +69,16 @@ PluginMetadata* CreatePluginMetadata(
|
| string16 group_name_matcher;
|
| success = plugin_dict->GetString("group_name_matcher", &group_name_matcher);
|
| DCHECK(success);
|
| + std::string language_str;
|
| + plugin_dict->GetString("lang", &language_str);
|
|
|
| PluginMetadata* plugin = new PluginMetadata(identifier,
|
| name,
|
| display_url,
|
| GURL(url),
|
| GURL(help_url),
|
| - group_name_matcher);
|
| + group_name_matcher,
|
| + language_str);
|
| const ListValue* versions = NULL;
|
| if (plugin_dict->GetList("versions", &versions)) {
|
| for (ListValue::const_iterator it = versions->begin();
|
| @@ -99,6 +102,23 @@ PluginMetadata* CreatePluginMetadata(
|
| }
|
| }
|
|
|
| + const ListValue* mime_types = NULL;
|
| + if (plugin_dict->GetList("mime_types", &mime_types)) {
|
| + for (ListValue::const_iterator mime_type_it = mime_types->begin();
|
| + mime_type_it != mime_types->end(); ++mime_type_it) {
|
| + DictionaryValue* mime_types_dict = NULL;
|
| + if (!(*mime_type_it)->GetAsDictionary(&mime_types_dict)) {
|
| + NOTREACHED();
|
| + continue;
|
| + }
|
| + std::string mime_type;
|
| + success = mime_types_dict->GetString("mime_type", &mime_type);
|
| + DCHECK(success);
|
| + bool used_in_matching = false;
|
| + mime_types_dict->GetBoolean("used_in_matching", &used_in_matching);
|
| + plugin->AddMimeType(mime_type, used_in_matching);
|
| + }
|
| + }
|
| return plugin;
|
| }
|
|
|
| @@ -167,38 +187,19 @@ bool PluginFinder::FindPlugin(
|
| base::AutoLock lock(mutex_);
|
| if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder))
|
| return false;
|
| - for (DictionaryValue::Iterator plugin_it(*plugin_list_);
|
| - plugin_it.HasNext(); plugin_it.Advance()) {
|
| - const DictionaryValue* plugin = NULL;
|
| - if (!plugin_it.value().GetAsDictionary(&plugin)) {
|
| - NOTREACHED();
|
| - continue;
|
| - }
|
| - std::string language_str;
|
| - bool success = plugin->GetString("lang", &language_str);
|
| - if (language_str != language)
|
| - continue;
|
| - const ListValue* mime_types = NULL;
|
| - plugin->GetList("mime_types", &mime_types);
|
| - DCHECK(success);
|
| - for (ListValue::const_iterator mime_type_it = mime_types->begin();
|
| - mime_type_it != mime_types->end(); ++mime_type_it) {
|
| - std::string mime_type_str;
|
| - success = (*mime_type_it)->GetAsString(&mime_type_str);
|
| - DCHECK(success);
|
| - if (mime_type_str == mime_type) {
|
| - std::string identifier = plugin_it.key();
|
| - std::map<std::string, PluginMetadata*>::const_iterator metadata_it =
|
| - identifier_plugin_.find(identifier);
|
| - DCHECK(metadata_it != identifier_plugin_.end());
|
| - *plugin_metadata = metadata_it->second->Clone();
|
| -
|
| - std::map<std::string, PluginInstaller*>::const_iterator installer_it =
|
| - installers_.find(identifier);
|
| - DCHECK(installer_it != installers_.end());
|
| - *installer = installer_it->second;
|
| - return true;
|
| - }
|
| +
|
| + std::map<std::string, PluginMetadata*>::const_iterator metadata_it =
|
| + identifier_plugin_.begin();
|
| + for (; metadata_it != identifier_plugin_.end(); ++metadata_it) {
|
| + if (language == metadata_it->second->language() &&
|
| + metadata_it->second->HasMimeType(mime_type)) {
|
| + *plugin_metadata = metadata_it->second->Clone();
|
| +
|
| + std::map<std::string, PluginInstaller*>::const_iterator installer_it =
|
| + installers_.find(metadata_it->second->identifier());
|
| + DCHECK(installer_it != installers_.end());
|
| + *installer = installer_it->second;
|
| + return true;
|
| }
|
| }
|
| return false;
|
| @@ -239,16 +240,14 @@ string16 PluginFinder::FindPluginNameWithIdentifier(
|
| scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata(
|
| const webkit::WebPluginInfo& plugin) {
|
| base::AutoLock lock(mutex_);
|
| - if (name_plugin_.find(plugin.name) != name_plugin_.end())
|
| - return name_plugin_[plugin.name]->Clone();
|
| -
|
| // Use the group name matcher to find the plug-in metadata we want.
|
| for (std::map<std::string, PluginMetadata*>::const_iterator it =
|
| identifier_plugin_.begin(); it != identifier_plugin_.end(); ++it) {
|
| - if (!it->second->MatchesPlugin(plugin))
|
| + string16 matching_name;
|
| + if (!it->second->MatchesPlugin(plugin, &matching_name))
|
| continue;
|
|
|
| - name_plugin_[plugin.name] = it->second;
|
| + name_plugin_[matching_name] = it->second;
|
| return it->second->Clone();
|
| }
|
|
|
| @@ -258,8 +257,8 @@ scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata(
|
| PluginMetadata* metadata = new PluginMetadata(identifier,
|
| GetGroupName(plugin),
|
| false, GURL(), GURL(),
|
| - GetGroupName(plugin));
|
| -
|
| + GetGroupName(plugin),
|
| + "");
|
| name_plugin_[plugin.name] = metadata;
|
| identifier_plugin_[identifier] = metadata;
|
| return metadata->Clone();
|
|
|