summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 23:14:46 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 23:14:46 +0000
commitfbf3714a8a46a52a95501aeaa73300b12bdfbae1 (patch)
treeef0c750c7c4c626a6051626098d7aa40c096c390 /chrome/browser/dom_ui
parent99bb53e5bed242585c66c3903d5df7d5a06560b4 (diff)
downloadchromium_src-fbf3714a8a46a52a95501aeaa73300b12bdfbae1.zip
chromium_src-fbf3714a8a46a52a95501aeaa73300b12bdfbae1.tar.gz
chromium_src-fbf3714a8a46a52a95501aeaa73300b12bdfbae1.tar.bz2
Revert 51110 because of regression 47858- Group plugins in about:plugins and show update link for out-of-date ones.
Tracking patch by mavrommatis, original review here: <http://codereview.chromium.org/1991005> Original description follows: (1) Group plugins with the same name together. (2) Show a download link for plugin versions with known security problems in about:plugins. BUG=3910 TEST=Open "chrome://plugins", see that plugins are grouped, and that any vulnerable plugins are marked red. Try enabling and disabling plugin groups. Review URL: http://codereview.chromium.org/2835018 TBR=bauerb@chromium.org Review URL: http://codereview.chromium.org/2805048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/plugins_ui.cc126
1 files changed, 95 insertions, 31 deletions
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc
index 00e8a31..d14df5c 100644
--- a/chrome/browser/dom_ui/plugins_ui.cc
+++ b/chrome/browser/dom_ui/plugins_ui.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
-#include "chrome/browser/plugin_updater.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_paths.h"
@@ -71,12 +70,6 @@ void PluginsUIHTMLSource::StartDataRequest(const std::string& path,
l10n_util::GetString(IDS_PLUGINS_NONE_INSTALLED));
localized_strings.SetString(L"pluginDisabled",
l10n_util::GetString(IDS_PLUGINS_DISABLED_PLUGIN));
- localized_strings.SetString(L"pluginDownload",
- l10n_util::GetString(IDS_PLUGINS_DOWNLOAD));
- localized_strings.SetString(L"pluginName",
- l10n_util::GetString(IDS_PLUGINS_NAME));
- localized_strings.SetString(L"pluginPriority",
- l10n_util::GetString(IDS_PLUGINS_PRIORITY));
localized_strings.SetString(L"pluginVersion",
l10n_util::GetString(IDS_PLUGINS_VERSION));
localized_strings.SetString(L"pluginDescription",
@@ -143,6 +136,10 @@ class PluginsDOMHandler : public DOMMessageHandler {
void HandleShowTermsOfServiceMessage(const Value* value);
private:
+ // Creates a dictionary containing all the information about the given plugin;
+ // this is put into the list to "return" for the "requestPluginsData" message.
+ DictionaryValue* CreatePluginDetailValue(const WebPluginInfo& plugin);
+
// Creates a dictionary containing the important parts of the information
// about the given plugin; this is put into a list and saved in prefs.
DictionaryValue* CreatePluginSummaryValue(const WebPluginInfo& plugin);
@@ -166,8 +163,18 @@ void PluginsDOMHandler::RegisterMessages() {
void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) {
DictionaryValue* results = new DictionaryValue();
- // Grouped plugins.
- results->Set(L"plugins", PluginUpdater::GetInstance()->GetPluginGroupsData());
+ // Add plugins to the results structure.
+ ListValue* plugins_list = new ListValue();
+
+ std::vector<WebPluginInfo> plugins;
+ NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
+
+ for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin();
+ it != plugins.end();
+ ++it) {
+ plugins_list->Append(CreatePluginDetailValue(*it));
+ }
+ results->Set(L"plugins", plugins_list);
dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results);
}
@@ -179,35 +186,26 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) {
return;
const ListValue* list = static_cast<const ListValue*>(value);
- if (list->GetSize() != 3)
+ if (list->GetSize() != 2)
return;
+ FilePath::StringType plugin_path;
std::string enable_str;
- std::string is_group_str;
- if (!list->GetString(1, &enable_str) ||
- !list->GetString(2, &is_group_str))
+ if (!list->GetString(0, &plugin_path) ||
+ !list->GetString(1, &enable_str))
return;
- if (is_group_str == "true") {
- std::wstring group_name;
- if (!list->GetString(0, &group_name))
- return;
-
- PluginUpdater::GetInstance()->EnablePluginGroup(enable_str == "true",
- WideToUTF16(group_name));
- } else {
- FilePath::StringType file_path;
- if (!list->GetString(0, &file_path))
- return;
+ if (enable_str == "true")
+ NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(plugin_path));
+ else
+ NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(plugin_path));
- PluginUpdater::GetInstance()->EnablePluginFile(enable_str == "true",
- file_path);
- }
-
- // TODO(viettrungluu): We might also want to ensure that the plugins
+ // TODO(viettrungluu): It's morally wrong to do this here (it should be done
+ // by the plugins service), and we might also want to ensure that the plugins
// list is always written to prefs even when the user hasn't disabled a
- // plugin. <http://crbug.com/39101>
- PluginUpdater::GetInstance()->UpdatePreferences(dom_ui_->GetProfile());
+ // plugin. This will require refactoring the plugin list and service.
+ // <http://crbug.com/39101>
+ UpdatePreferences();
}
void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) {
@@ -218,6 +216,72 @@ void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) {
browser->window()->Show();
}
+DictionaryValue* PluginsDOMHandler::CreatePluginDetailValue(
+ const WebPluginInfo& plugin) {
+ DictionaryValue* plugin_data = new DictionaryValue();
+ plugin_data->SetString(L"path", plugin.path.value());
+ plugin_data->SetStringFromUTF16(L"name", plugin.name);
+ plugin_data->SetStringFromUTF16(L"version", plugin.version);
+ plugin_data->SetStringFromUTF16(L"description", plugin.desc);
+ plugin_data->SetBoolean(L"enabled", plugin.enabled);
+
+ ListValue* mime_types = new ListValue();
+ for (std::vector<WebPluginMimeType>::const_iterator type_it =
+ plugin.mime_types.begin();
+ type_it != plugin.mime_types.end();
+ ++type_it) {
+ DictionaryValue* mime_type = new DictionaryValue();
+ mime_type->SetString(L"mimeType", type_it->mime_type);
+ mime_type->SetStringFromUTF16(L"description", type_it->description);
+
+ ListValue* file_extensions = new ListValue();
+ for (std::vector<std::string>::const_iterator ext_it =
+ type_it->file_extensions.begin();
+ ext_it != type_it->file_extensions.end();
+ ++ext_it) {
+ file_extensions->Append(new StringValue(*ext_it));
+ }
+ mime_type->Set(L"fileExtensions", file_extensions);
+
+ mime_types->Append(mime_type);
+ }
+ plugin_data->Set(L"mimeTypes", mime_types);
+
+ return plugin_data;
+}
+
+DictionaryValue* PluginsDOMHandler::CreatePluginSummaryValue(
+ const WebPluginInfo& plugin) {
+ DictionaryValue* plugin_data = new DictionaryValue();
+ plugin_data->SetString(L"path", plugin.path.value());
+ plugin_data->SetStringFromUTF16(L"name", plugin.name);
+ plugin_data->SetStringFromUTF16(L"version", plugin.version);
+ plugin_data->SetBoolean(L"enabled", plugin.enabled);
+ return plugin_data;
+}
+
+// TODO(viettrungluu): move this (and the registration of the prefs into the
+// plugins service.
+void PluginsDOMHandler::UpdatePreferences() {
+ PrefService* prefs = dom_ui_->GetProfile()->GetPrefs();
+
+ FilePath internal_dir;
+ if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir))
+ prefs->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir);
+
+ ListValue* plugins_list = prefs->GetMutableList(prefs::kPluginsPluginsList);
+ plugins_list->Clear();
+
+ std::vector<WebPluginInfo> plugins;
+ NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
+
+ for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin();
+ it != plugins.end();
+ ++it) {
+ plugins_list->Append(CreatePluginSummaryValue(*it));
+ }
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////