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" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 return nullptr; | 240 return nullptr; |
241 } | 241 } |
242 | 242 |
243 DCHECK_EQ(base::JSONReader::JSON_NO_ERROR, error_code); | 243 DCHECK_EQ(base::JSONReader::JSON_NO_ERROR, error_code); |
244 RecordBuiltInPluginListError(PluginListError::PLUGIN_LIST_NO_ERROR); | 244 RecordBuiltInPluginListError(PluginListError::PLUGIN_LIST_NO_ERROR); |
245 return static_cast<base::DictionaryValue*>(value.release()); | 245 return static_cast<base::DictionaryValue*>(value.release()); |
246 } | 246 } |
247 | 247 |
248 PluginFinder::~PluginFinder() { | 248 PluginFinder::~PluginFinder() { |
249 #if defined(ENABLE_PLUGIN_INSTALLATION) | 249 #if defined(ENABLE_PLUGIN_INSTALLATION) |
250 STLDeleteValues(&installers_); | 250 base::STLDeleteValues(&installers_); |
251 #endif | 251 #endif |
252 STLDeleteValues(&identifier_plugin_); | 252 base::STLDeleteValues(&identifier_plugin_); |
253 } | 253 } |
254 | 254 |
255 #if defined(ENABLE_PLUGIN_INSTALLATION) | 255 #if defined(ENABLE_PLUGIN_INSTALLATION) |
256 bool PluginFinder::FindPlugin( | 256 bool PluginFinder::FindPlugin( |
257 const std::string& mime_type, | 257 const std::string& mime_type, |
258 const std::string& language, | 258 const std::string& language, |
259 PluginInstaller** installer, | 259 PluginInstaller** installer, |
260 std::unique_ptr<PluginMetadata>* plugin_metadata) { | 260 std::unique_ptr<PluginMetadata>* plugin_metadata) { |
261 if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder)) | 261 if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder)) |
262 return false; | 262 return false; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 const base::DictionaryValue* plugin_list) { | 303 const base::DictionaryValue* plugin_list) { |
304 base::AutoLock lock(mutex_); | 304 base::AutoLock lock(mutex_); |
305 int version = 0; // If no version is defined, we default to 0. | 305 int version = 0; // If no version is defined, we default to 0. |
306 const char kVersionKey[] = "x-version"; | 306 const char kVersionKey[] = "x-version"; |
307 plugin_list->GetInteger(kVersionKey, &version); | 307 plugin_list->GetInteger(kVersionKey, &version); |
308 if (version <= version_) | 308 if (version <= version_) |
309 return; | 309 return; |
310 | 310 |
311 version_ = version; | 311 version_ = version; |
312 | 312 |
313 STLDeleteValues(&identifier_plugin_); | 313 base::STLDeleteValues(&identifier_plugin_); |
314 | 314 |
315 for (base::DictionaryValue::Iterator plugin_it(*plugin_list); | 315 for (base::DictionaryValue::Iterator plugin_it(*plugin_list); |
316 !plugin_it.IsAtEnd(); plugin_it.Advance()) { | 316 !plugin_it.IsAtEnd(); plugin_it.Advance()) { |
317 const base::DictionaryValue* plugin = NULL; | 317 const base::DictionaryValue* plugin = NULL; |
318 const std::string& identifier = plugin_it.key(); | 318 const std::string& identifier = plugin_it.key(); |
319 if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { | 319 if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) { |
320 DCHECK(!identifier_plugin_[identifier]); | 320 DCHECK(!identifier_plugin_[identifier]); |
321 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); | 321 identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin); |
322 | 322 |
323 #if defined(ENABLE_PLUGIN_INSTALLATION) | 323 #if defined(ENABLE_PLUGIN_INSTALLATION) |
(...skipping 29 matching lines...) Expand all Loading... |
353 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); | 353 metadata->AddMatchingMimeType(plugin.mime_types[i].mime_type); |
354 | 354 |
355 DCHECK(metadata->MatchesPlugin(plugin)); | 355 DCHECK(metadata->MatchesPlugin(plugin)); |
356 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) | 356 if (identifier_plugin_.find(identifier) != identifier_plugin_.end()) |
357 identifier = GetLongIdentifier(plugin); | 357 identifier = GetLongIdentifier(plugin); |
358 | 358 |
359 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); | 359 DCHECK(identifier_plugin_.find(identifier) == identifier_plugin_.end()); |
360 identifier_plugin_[identifier] = metadata; | 360 identifier_plugin_[identifier] = metadata; |
361 return metadata->Clone(); | 361 return metadata->Clone(); |
362 } | 362 } |
OLD | NEW |