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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/plugins/plugin_metadata.h" | 18 #include "chrome/browser/plugins/plugin_metadata.h" |
| 19 #include "chrome/common/features.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/grit/browser_resources.h" | 21 #include "chrome/grit/browser_resources.h" |
21 #include "components/prefs/pref_registry_simple.h" | 22 #include "components/prefs/pref_registry_simple.h" |
22 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/plugin_service.h" | 25 #include "content/public/browser/plugin_service.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
27 | 28 |
28 #if defined(ENABLE_PLUGIN_INSTALLATION) | 29 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
29 #include "chrome/browser/plugins/plugin_installer.h" | 30 #include "chrome/browser/plugins/plugin_installer.h" |
30 #endif | 31 #endif |
31 | 32 |
32 using base::DictionaryValue; | 33 using base::DictionaryValue; |
33 using content::PluginService; | 34 using content::PluginService; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 typedef std::map<std::string, PluginMetadata*> PluginMap; | 38 typedef std::map<std::string, PluginMetadata*> PluginMap; |
38 | 39 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 RecordBuiltInPluginListError(PluginListError::SCHEMA_ERROR); | 240 RecordBuiltInPluginListError(PluginListError::SCHEMA_ERROR); |
240 return nullptr; | 241 return nullptr; |
241 } | 242 } |
242 | 243 |
243 DCHECK_EQ(base::JSONReader::JSON_NO_ERROR, error_code); | 244 DCHECK_EQ(base::JSONReader::JSON_NO_ERROR, error_code); |
244 RecordBuiltInPluginListError(PluginListError::PLUGIN_LIST_NO_ERROR); | 245 RecordBuiltInPluginListError(PluginListError::PLUGIN_LIST_NO_ERROR); |
245 return static_cast<base::DictionaryValue*>(value.release()); | 246 return static_cast<base::DictionaryValue*>(value.release()); |
246 } | 247 } |
247 | 248 |
248 PluginFinder::~PluginFinder() { | 249 PluginFinder::~PluginFinder() { |
249 #if defined(ENABLE_PLUGIN_INSTALLATION) | 250 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
250 base::STLDeleteValues(&installers_); | 251 base::STLDeleteValues(&installers_); |
251 #endif | 252 #endif |
252 base::STLDeleteValues(&identifier_plugin_); | 253 base::STLDeleteValues(&identifier_plugin_); |
253 } | 254 } |
254 | 255 |
255 #if defined(ENABLE_PLUGIN_INSTALLATION) | 256 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
256 bool PluginFinder::FindPlugin( | 257 bool PluginFinder::FindPlugin( |
257 const std::string& mime_type, | 258 const std::string& mime_type, |
258 const std::string& language, | 259 const std::string& language, |
259 PluginInstaller** installer, | 260 PluginInstaller** installer, |
260 std::unique_ptr<PluginMetadata>* plugin_metadata) { | 261 std::unique_ptr<PluginMetadata>* plugin_metadata) { |
261 if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder)) | 262 if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder)) |
262 return false; | 263 return false; |
263 | 264 |
264 base::AutoLock lock(mutex_); | 265 base::AutoLock lock(mutex_); |
265 PluginMap::const_iterator metadata_it = identifier_plugin_.begin(); | 266 PluginMap::const_iterator metadata_it = identifier_plugin_.begin(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 base::STLDeleteValues(&identifier_plugin_); | 314 base::STLDeleteValues(&identifier_plugin_); |
314 | 315 |
315 for (base::DictionaryValue::Iterator plugin_it(*plugin_list); | 316 for (base::DictionaryValue::Iterator plugin_it(*plugin_list); |
316 !plugin_it.IsAtEnd(); plugin_it.Advance()) { | 317 !plugin_it.IsAtEnd(); plugin_it.Advance()) { |
317 const base::DictionaryValue* plugin = NULL; | 318 const base::DictionaryValue* plugin = NULL; |
318 const std::string& identifier = plugin_it.key(); | 319 const std::string& identifier = plugin_it.key(); |
319 if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { | 320 if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { |
320 DCHECK(!identifier_plugin_[identifier]); | 321 DCHECK(!identifier_plugin_[identifier]); |
321 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); | 322 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); |
322 | 323 |
323 #if defined(ENABLE_PLUGIN_INSTALLATION) | 324 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
324 if (installers_.find(identifier) == installers_.end()) | 325 if (installers_.find(identifier) == installers_.end()) |
325 installers_[identifier] = new PluginInstaller(); | 326 installers_[identifier] = new PluginInstaller(); |
326 #endif | 327 #endif |
327 } | 328 } |
328 } | 329 } |
329 } | 330 } |
330 | 331 |
331 std::unique_ptr<PluginMetadata> PluginFinder::GetPluginMetadata( | 332 std::unique_ptr<PluginMetadata> PluginFinder::GetPluginMetadata( |
332 const content::WebPluginInfo& plugin) { | 333 const content::WebPluginInfo& plugin) { |
333 base::AutoLock lock(mutex_); | 334 base::AutoLock lock(mutex_); |
(...skipping 19 matching lines...) Expand all Loading... |
353 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); | 354 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); |
354 | 355 |
355 DCHECK(metadata->MatchesPlugin(plugin)); | 356 DCHECK(metadata->MatchesPlugin(plugin)); |
356 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) | 357 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) |
357 identifier = GetLongIdentifier(plugin); | 358 identifier = GetLongIdentifier(plugin); |
358 | 359 |
359 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); | 360 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); |
360 identifier_plugin_[identifier] = metadata; | 361 identifier_plugin_[identifier] = metadata; |
361 return metadata->Clone(); | 362 return metadata->Clone(); |
362 } | 363 } |
OLD | NEW |