| 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_prefs.h" | 5 #include "chrome/browser/plugins/plugin_prefs.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/location.h" | 15 #include "base/location.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/pattern.h" | 18 #include "base/strings/pattern.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 475 |
| 475 base::FilePath internal_dir; | 476 base::FilePath internal_dir; |
| 476 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) | 477 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) |
| 477 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); | 478 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); |
| 478 | 479 |
| 479 base::AutoLock auto_lock(lock_); | 480 base::AutoLock auto_lock(lock_); |
| 480 | 481 |
| 481 // Add the plugin files. | 482 // Add the plugin files. |
| 482 std::set<base::string16> group_names; | 483 std::set<base::string16> group_names; |
| 483 for (size_t i = 0; i < plugins.size(); ++i) { | 484 for (size_t i = 0; i < plugins.size(); ++i) { |
| 484 base::DictionaryValue* summary = new base::DictionaryValue(); | 485 std::unique_ptr<base::DictionaryValue> summary(new base::DictionaryValue()); |
| 485 summary->SetString("path", plugins[i].path.value()); | 486 summary->SetString("path", plugins[i].path.value()); |
| 486 summary->SetString("name", plugins[i].name); | 487 summary->SetString("name", plugins[i].name); |
| 487 summary->SetString("version", plugins[i].version); | 488 summary->SetString("version", plugins[i].version); |
| 488 bool enabled = true; | 489 bool enabled = true; |
| 489 plugin_state_.Get(plugins[i].path, &enabled); | 490 plugin_state_.Get(plugins[i].path, &enabled); |
| 490 summary->SetBoolean("enabled", enabled); | 491 summary->SetBoolean("enabled", enabled); |
| 491 plugins_list->Append(summary); | 492 plugins_list->Append(std::move(summary)); |
| 492 | 493 |
| 493 std::unique_ptr<PluginMetadata> plugin_metadata( | 494 std::unique_ptr<PluginMetadata> plugin_metadata( |
| 494 finder->GetPluginMetadata(plugins[i])); | 495 finder->GetPluginMetadata(plugins[i])); |
| 495 // Insert into a set of all group names. | 496 // Insert into a set of all group names. |
| 496 group_names.insert(plugin_metadata->name()); | 497 group_names.insert(plugin_metadata->name()); |
| 497 } | 498 } |
| 498 | 499 |
| 499 // Add the plugin groups. | 500 // Add the plugin groups. |
| 500 for (std::set<base::string16>::const_iterator it = group_names.begin(); | 501 for (std::set<base::string16>::const_iterator it = group_names.begin(); |
| 501 it != group_names.end(); ++it) { | 502 it != group_names.end(); ++it) { |
| 502 base::DictionaryValue* summary = new base::DictionaryValue(); | 503 std::unique_ptr<base::DictionaryValue> summary(new base::DictionaryValue()); |
| 503 summary->SetString("name", *it); | 504 summary->SetString("name", *it); |
| 504 bool enabled = true; | 505 bool enabled = true; |
| 505 std::map<base::string16, bool>::iterator gstate_it = | 506 std::map<base::string16, bool>::iterator gstate_it = |
| 506 plugin_group_state_.find(*it); | 507 plugin_group_state_.find(*it); |
| 507 if (gstate_it != plugin_group_state_.end()) | 508 if (gstate_it != plugin_group_state_.end()) |
| 508 enabled = gstate_it->second; | 509 enabled = gstate_it->second; |
| 509 summary->SetBoolean("enabled", enabled); | 510 summary->SetBoolean("enabled", enabled); |
| 510 plugins_list->Append(summary); | 511 plugins_list->Append(std::move(summary)); |
| 511 } | 512 } |
| 512 } | 513 } |
| 513 | 514 |
| 514 void PluginPrefs::NotifyPluginStatusChanged() { | 515 void PluginPrefs::NotifyPluginStatusChanged() { |
| 515 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 516 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 516 content::NotificationService::current()->Notify( | 517 content::NotificationService::current()->Notify( |
| 517 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 518 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 518 content::Source<Profile>(profile_), | 519 content::Source<Profile>(profile_), |
| 519 content::NotificationService::NoDetails()); | 520 content::NotificationService::NoDetails()); |
| 520 } | 521 } |
| OLD | NEW |