| Index: chrome/browser/ui/webui/plugins_ui.cc
|
| diff --git a/chrome/browser/ui/webui/plugins_ui.cc b/chrome/browser/ui/webui/plugins_ui.cc
|
| index 1b9676f66e7579a50c5f86043bab5fce23968cf8..3466e0b78e8f94f18bbff6d6e8ae698411cd2863 100644
|
| --- a/chrome/browser/ui/webui/plugins_ui.cc
|
| +++ b/chrome/browser/ui/webui/plugins_ui.cc
|
| @@ -66,6 +66,11 @@ using webkit::WebPluginInfo;
|
|
|
| namespace {
|
|
|
| +// Helper callback method to process result of CanEnablePlugin method.
|
| +void CheckCanEnablePluginCallback(bool can_enable) {
|
| + DCHECK(can_enable);
|
| +}
|
| +
|
| ChromeWebUIDataSource* CreatePluginsUIHTMLSource() {
|
| ChromeWebUIDataSource* source =
|
| new ChromeWebUIDataSource(chrome::kChromeUIPluginsHost);
|
| @@ -174,12 +179,15 @@ class PluginsDOMHandler : public WebUIMessageHandler,
|
|
|
| // Called on the UI thread when the plugin information is ready.
|
| void PluginsLoaded(PluginFinder* plugin_finder,
|
| - const std::vector<PluginGroup>& groups);
|
| + const std::vector<webkit::WebPluginInfo>& plugins);
|
|
|
| content::NotificationRegistrar registrar_;
|
|
|
| base::WeakPtrFactory<PluginsDOMHandler> weak_ptr_factory_;
|
|
|
| + typedef base::hash_map<std::string, std::vector<const WebPluginInfo*> >
|
| + PluginGroups;
|
| +
|
| // This pref guards the value whether about:plugins is in the details mode or
|
| // not.
|
| BooleanPrefMember show_details_;
|
| @@ -240,7 +248,7 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) {
|
| }
|
| bool enable = enable_str == "true";
|
|
|
| - PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
|
| + scoped_refptr<PluginPrefs> plugin_prefs(PluginPrefs::GetForProfile(profile));
|
| if (is_group_str == "true") {
|
| string16 group_name;
|
| if (!args->GetString(0, &group_name)) {
|
| @@ -266,9 +274,10 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) {
|
| NOTREACHED();
|
| return;
|
| }
|
| - DCHECK(plugin_prefs->CanEnablePlugin(enable, FilePath(file_path)));
|
| +
|
| plugin_prefs->EnablePlugin(enable, FilePath(file_path),
|
| - base::Bind(&base::DoNothing));
|
| + base::Bind(&base::DoNothing),
|
| + base::Bind(&CheckCanEnablePluginCallback));
|
| }
|
| }
|
|
|
| @@ -334,32 +343,43 @@ void PluginsDOMHandler::GetPluginFinder() {
|
| }
|
|
|
| void PluginsDOMHandler::LoadPlugins(PluginFinder* plugin_finder) {
|
| - PluginService::GetInstance()->GetPluginGroups(
|
| + PluginService::GetInstance()->GetPlugins(
|
| base::Bind(&PluginsDOMHandler::PluginsLoaded,
|
| weak_ptr_factory_.GetWeakPtr(), plugin_finder));
|
| }
|
|
|
| -void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder,
|
| - const std::vector<PluginGroup>& groups) {
|
| +void PluginsDOMHandler::PluginsLoaded(
|
| + PluginFinder* plugin_finder,
|
| + const std::vector<webkit::WebPluginInfo>& plugins) {
|
| Profile* profile = Profile::FromWebUI(web_ui());
|
| PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
|
|
|
| ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard();
|
|
|
| - // Construct DictionaryValues to return to the UI
|
| + // Group plug-ins by identifier. This is done to be able to display
|
| + // the plug-ins in UI in a grouped fashion.
|
| + PluginGroups groups;
|
| + for (size_t i = 0; i < plugins.size(); ++i) {
|
| + PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugins[i]);
|
| + groups[installer->identifier()].push_back(&plugins[i]);
|
| + }
|
| +
|
| + // Construct DictionaryValues to return to UI.
|
| ListValue* plugin_groups_data = new ListValue();
|
| - for (size_t i = 0; i < groups.size(); ++i) {
|
| - const PluginGroup& group = groups[i];
|
| - if (group.IsEmpty())
|
| - continue;
|
| + for (PluginGroups::const_iterator it = groups.begin();
|
| + it != groups.end(); ++it) {
|
| + const std::vector<const WebPluginInfo*>& group_plugins = it->second;
|
| ListValue* plugin_files = new ListValue();
|
| - string16 group_name = group.GetGroupName();
|
| + PluginInstaller* plugin_installer =
|
| + plugin_finder->GetPluginInstaller(*group_plugins[0]);
|
| + string16 group_name = plugin_installer->name();
|
| + std::string group_identifier = plugin_installer->identifier();
|
| bool group_enabled = false;
|
| bool all_plugins_enabled_by_policy = true;
|
| bool all_plugins_disabled_by_policy = true;
|
| const WebPluginInfo* active_plugin = NULL;
|
| - for (size_t j = 0; j < group.web_plugin_infos().size(); ++j) {
|
| - const WebPluginInfo& group_plugin = group.web_plugin_infos()[j];
|
| + for (size_t j = 0; j < group_plugins.size(); ++j) {
|
| + const WebPluginInfo& group_plugin = *group_plugins[j];
|
|
|
| DictionaryValue* plugin_file = new DictionaryValue();
|
| plugin_file->SetString("name", group_plugin.name);
|
| @@ -404,7 +424,7 @@ void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder,
|
| } else {
|
| all_plugins_enabled_by_policy = false;
|
| if (plugin_status == PluginPrefs::POLICY_DISABLED ||
|
| - group_status == PluginPrefs::POLICY_DISABLED) {
|
| + group_status == PluginPrefs::POLICY_DISABLED) {
|
| enabled_mode = "disabledByPolicy";
|
| } else {
|
| all_plugins_disabled_by_policy = false;
|
| @@ -423,16 +443,16 @@ void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder,
|
|
|
| group_data->Set("plugin_files", plugin_files);
|
| group_data->SetString("name", group_name);
|
| - group_data->SetString("id", group.identifier());
|
| + group_data->SetString("id", group_identifier);
|
| group_data->SetString("description", active_plugin->desc);
|
| group_data->SetString("version", active_plugin->version);
|
|
|
| #if defined(ENABLE_PLUGIN_INSTALLATION)
|
| PluginInstaller* installer =
|
| - plugin_finder->FindPluginWithIdentifier(group.identifier());
|
| + plugin_finder->FindPluginWithIdentifier(group_identifier);
|
| if (installer) {
|
| bool out_of_date = installer->GetSecurityStatus(*active_plugin) ==
|
| - PluginInstaller::SECURITY_STATUS_OUT_OF_DATE;
|
| + PluginInstaller::SECURITY_STATUS_OUT_OF_DATE;
|
| group_data->SetBoolean("critical", out_of_date);
|
| group_data->SetString("update_url", installer->plugin_url().spec());
|
| }
|
| @@ -454,12 +474,13 @@ void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder,
|
| if (group_enabled) {
|
| const DictionaryValue* whitelist = profile->GetPrefs()->GetDictionary(
|
| prefs::kContentSettingsPluginWhitelist);
|
| - whitelist->GetBoolean(group.identifier(), &always_allowed);
|
| + whitelist->GetBoolean(group_identifier, &always_allowed);
|
| }
|
| group_data->SetBoolean("alwaysAllowed", always_allowed);
|
|
|
| plugin_groups_data->Append(group_data);
|
| }
|
| +
|
| DictionaryValue results;
|
| results.Set("plugins", plugin_groups_data);
|
| web_ui()->CallJavascriptFunction("returnPluginsData", results);
|
|
|