OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/plugins/plugin_finder.h" | 5 #include "chrome/browser/plugins/plugin_finder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 string16 name; | 89 string16 name; |
90 success = plugin_dict->GetString("name", &name); | 90 success = plugin_dict->GetString("name", &name); |
91 DCHECK(success); | 91 DCHECK(success); |
92 bool display_url = false; | 92 bool display_url = false; |
93 plugin_dict->GetBoolean("displayurl", &display_url); | 93 plugin_dict->GetBoolean("displayurl", &display_url); |
94 string16 group_name_matcher; | 94 string16 group_name_matcher; |
95 success = plugin_dict->GetString("group_name_matcher", &group_name_matcher); | 95 success = plugin_dict->GetString("group_name_matcher", &group_name_matcher); |
96 DCHECK(success); | 96 DCHECK(success); |
97 std::string language_str; | 97 std::string language_str; |
98 plugin_dict->GetString("lang", &language_str); | 98 plugin_dict->GetString("lang", &language_str); |
99 | 99 bool use_pattern_matching = false; |
| 100 plugin_dict->GetBoolean("use_pattern_matching", &use_pattern_matching); |
100 PluginMetadata* plugin = new PluginMetadata(identifier, | 101 PluginMetadata* plugin = new PluginMetadata(identifier, |
101 name, | 102 name, |
102 display_url, | 103 display_url, |
103 GURL(url), | 104 GURL(url), |
104 GURL(help_url), | 105 GURL(help_url), |
105 group_name_matcher, | 106 group_name_matcher, |
106 language_str); | 107 language_str, |
| 108 use_pattern_matching); |
107 const ListValue* versions = NULL; | 109 const ListValue* versions = NULL; |
108 if (plugin_dict->GetList("versions", &versions)) { | 110 if (plugin_dict->GetList("versions", &versions)) { |
109 for (ListValue::const_iterator it = versions->begin(); | 111 for (ListValue::const_iterator it = versions->begin(); |
110 it != versions->end(); ++it) { | 112 it != versions->end(); ++it) { |
111 DictionaryValue* version_dict = NULL; | 113 DictionaryValue* version_dict = NULL; |
112 if (!(*it)->GetAsDictionary(&version_dict)) { | 114 if (!(*it)->GetAsDictionary(&version_dict)) { |
113 NOTREACHED(); | 115 NOTREACHED(); |
114 continue; | 116 continue; |
115 } | 117 } |
116 std::string version; | 118 std::string version; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 return it->second->Clone(); | 284 return it->second->Clone(); |
283 } | 285 } |
284 | 286 |
285 // The plug-in metadata was not found, create a dummy one holding | 287 // The plug-in metadata was not found, create a dummy one holding |
286 // the name, identifier and group name only. | 288 // the name, identifier and group name only. |
287 std::string identifier = GetIdentifier(plugin); | 289 std::string identifier = GetIdentifier(plugin); |
288 PluginMetadata* metadata = new PluginMetadata(identifier, | 290 PluginMetadata* metadata = new PluginMetadata(identifier, |
289 GetGroupName(plugin), | 291 GetGroupName(plugin), |
290 false, GURL(), GURL(), | 292 false, GURL(), GURL(), |
291 plugin.name, | 293 plugin.name, |
292 ""); | 294 "", false); |
293 for (size_t i = 0; i < plugin.mime_types.size(); ++i) | 295 for (size_t i = 0; i < plugin.mime_types.size(); ++i) |
294 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); | 296 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); |
295 | 297 |
296 DCHECK(metadata->MatchesPlugin(plugin)); | 298 DCHECK(metadata->MatchesPlugin(plugin)); |
297 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) | 299 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) |
298 identifier = GetLongIdentifier(plugin); | 300 identifier = GetLongIdentifier(plugin); |
299 | 301 |
300 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); | 302 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); |
301 identifier_plugin_[identifier] = metadata; | 303 identifier_plugin_[identifier] = metadata; |
302 return metadata->Clone(); | 304 return metadata->Clone(); |
303 } | 305 } |
304 | 306 |
305 void PluginFinder::InitInternal() { | 307 void PluginFinder::InitInternal() { |
306 for (DictionaryValue::Iterator plugin_it(*plugin_list_); | 308 for (DictionaryValue::Iterator plugin_it(*plugin_list_); |
307 plugin_it.HasNext(); plugin_it.Advance()) { | 309 plugin_it.HasNext(); plugin_it.Advance()) { |
308 DictionaryValue* plugin = NULL; | 310 DictionaryValue* plugin = NULL; |
309 const std::string& identifier = plugin_it.key(); | 311 const std::string& identifier = plugin_it.key(); |
310 if (plugin_list_->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { | 312 if (plugin_list_->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { |
311 DCHECK(!identifier_plugin_[identifier]); | 313 DCHECK(!identifier_plugin_[identifier]); |
312 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); | 314 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); |
313 | 315 |
314 #if defined(ENABLE_PLUGIN_INSTALLATION) | 316 #if defined(ENABLE_PLUGIN_INSTALLATION) |
315 if (installers_.find(identifier) == installers_.end()) | 317 if (installers_.find(identifier) == installers_.end()) |
316 installers_[identifier] = new PluginInstaller(); | 318 installers_[identifier] = new PluginInstaller(); |
317 #endif | 319 #endif |
318 } | 320 } |
319 } | 321 } |
320 } | 322 } |
OLD | NEW |