summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 00:21:34 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 00:21:34 +0000
commitcec1b8d4524bd0ce53a7b08b4263c788a5b6d72b (patch)
treec229241e080953f2ff84966f1e969747b6129268 /webkit
parent50d8766af20bd48bce1094039153291e31c0e0bf (diff)
downloadchromium_src-cec1b8d4524bd0ce53a7b08b4263c788a5b6d72b.zip
chromium_src-cec1b8d4524bd0ce53a7b08b4263c788a5b6d72b.tar.gz
chromium_src-cec1b8d4524bd0ce53a7b08b4263c788a5b6d72b.tar.bz2
Implement chrome://plugins page that can disable plugins.
BUG=736 TEST=Go to chrome://plugins/. Should be able to enable/disable plugins. Enabled/disabled plugins should persist between sessions. Review URL: http://codereview.chromium.org/1085003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/plugin_lib_mac.mm2
-rw-r--r--webkit/glue/plugins/plugin_lib_posix.cc1
-rw-r--r--webkit/glue/plugins/plugin_list.cc78
-rw-r--r--webkit/glue/plugins/plugin_list.h22
-rw-r--r--webkit/glue/webplugininfo.h3
5 files changed, 104 insertions, 2 deletions
diff --git a/webkit/glue/plugins/plugin_lib_mac.mm b/webkit/glue/plugins/plugin_lib_mac.mm
index 64d34c3..b6ced70 100644
--- a/webkit/glue/plugins/plugin_lib_mac.mm
+++ b/webkit/glue/plugins/plugin_lib_mac.mm
@@ -123,6 +123,7 @@ bool ReadPlistPluginInfo(const FilePath& filename, CFBundleRef bundle,
info->desc = base::SysNSStringToWide(plugin_desc);
else
info->desc = UTF8ToWide(filename.BaseName().value());
+ info->enabled = true;
return true;
}
@@ -220,6 +221,7 @@ bool ReadSTRPluginInfo(const FilePath& filename, CFBundleRef bundle,
info->desc = UTF8ToWide(plugin_descs[0]);
else
info->desc = UTF8ToWide(filename.BaseName().value());
+ info->enabled = true;
return true;
}
diff --git a/webkit/glue/plugins/plugin_lib_posix.cc b/webkit/glue/plugins/plugin_lib_posix.cc
index e738b67..6541a66 100644
--- a/webkit/glue/plugins/plugin_lib_posix.cc
+++ b/webkit/glue/plugins/plugin_lib_posix.cc
@@ -131,6 +131,7 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename,
return false;
info->path = filename;
+ info->enabled = true;
// Attempt to swap in the wrapped plugin if this is nspluginwrapper.
UnwrapNSPluginWrapper(&dl, &info->path);
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index e8565d8..d0199d4 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/plugin_list.h"
+#include <algorithm>
+
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -106,6 +108,7 @@ bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
info->desc = pvi.file_description;
info->version = pvi.file_version;
info->path = pvi.path;
+ info->enabled = true;
for (size_t i = 0; i < mime_types.size(); ++i) {
WebPluginMimeType mime_type;
@@ -214,7 +217,17 @@ void PluginList::LoadPlugins(bool refresh) {
base::TimeDelta elapsed = end_time - start_time;
DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms.";
+ // Only update the data now since loading plugins can take a while.
AutoLock lock(lock_);
+
+ // Go through and mark new plugins in the disabled list as, well, disabled.
+ for (std::vector<WebPluginInfo>::iterator it = new_plugins.begin();
+ it != new_plugins.end();
+ ++it) {
+ if (disabled_plugins_.find(it->path) != disabled_plugins_.end())
+ it->enabled = false;
+ }
+
plugins_ = new_plugins;
plugins_loaded_ = true;
}
@@ -331,6 +344,20 @@ void PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
*plugins = plugins_;
}
+void PluginList::GetEnabledPlugins(bool refresh,
+ std::vector<WebPluginInfo>* plugins) {
+ LoadPlugins(refresh);
+
+ plugins->clear();
+ AutoLock lock(lock_);
+ for (std::vector<WebPluginInfo>::const_iterator it = plugins_.begin();
+ it != plugins_.end();
+ ++it) {
+ if (it->enabled)
+ plugins->push_back(*it);
+ }
+}
+
bool PluginList::GetPluginInfo(const GURL& url,
const std::string& mime_type,
bool allow_wildcard,
@@ -362,6 +389,55 @@ bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
return false;
}
+bool PluginList::EnablePlugin(const FilePath& filename) {
+ AutoLock lock(lock_);
+
+ bool did_enable = false;
+
+ std::set<FilePath>::iterator entry = disabled_plugins_.find(filename);
+ if (entry == disabled_plugins_.end())
+ return did_enable; // Early exit if plugin not in disabled list.
+
+ disabled_plugins_.erase(entry); // Remove from disabled list.
+
+ // Set enabled flags if necessary.
+ for (std::vector<WebPluginInfo>::iterator it = plugins_.begin();
+ it != plugins_.end();
+ ++it) {
+ if (it->path == filename) {
+ DCHECK(!it->enabled); // Should have been disabled.
+ it->enabled = true;
+ did_enable = true;
+ }
+ }
+
+ return did_enable;
+}
+
+bool PluginList::DisablePlugin(const FilePath& filename) {
+ AutoLock lock(lock_);
+
+ bool did_disable = false;
+
+ if (disabled_plugins_.find(filename) != disabled_plugins_.end())
+ return did_disable; // Early exit if plugin already in disabled list.
+
+ disabled_plugins_.insert(filename); // Add to disabled list.
+
+ // Unset enabled flags if necessary.
+ for (std::vector<WebPluginInfo>::iterator it = plugins_.begin();
+ it != plugins_.end();
+ ++it) {
+ if (it->path == filename) {
+ DCHECK(it->enabled); // Should have been enabled.
+ it->enabled = false;
+ did_disable = true;
+ }
+ }
+
+ return did_disable;
+}
+
void PluginList::Shutdown() {
// TODO
}
diff --git a/webkit/glue/plugins/plugin_list.h b/webkit/glue/plugins/plugin_list.h
index 0017399..91bf23f 100644
--- a/webkit/glue/plugins/plugin_list.h
+++ b/webkit/glue/plugins/plugin_list.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
#define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
+#include <set>
#include <string>
#include <vector>
#include <set>
@@ -114,9 +115,12 @@ class PluginList {
// Shutdown all plugins. Should be called at process teardown.
void Shutdown();
- // Get all the plugins
+ // Get all the plugins.
void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
+ // Get all the enabled plugins.
+ void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
+
// Returns true if a plugin is found for the given url and mime type.
// The mime type which corresponds to the URL is optionally returned
// back.
@@ -137,6 +141,19 @@ class PluginList {
void LoadPlugin(const FilePath& filename,
std::vector<WebPluginInfo>* plugins);
+ // Enable a specific plugin, specified by path. Returns |true| iff a plugin
+ // currently in the plugin list was actually enabled as a result; regardless
+ // of return value, if a plugin is found in the future with the given name, it
+ // will be enabled. Note that plugins are enabled by default as far as
+ // |PluginList| is concerned.
+ bool EnablePlugin(const FilePath& filename);
+
+ // Disable a specific plugin, specified by path. Returns |true| iff a plugin
+ // currently in the plugin list was actually disabled as a result; regardless
+ // of return value, if a plugin is found in the future with the given name, it
+ // will be disabled.
+ bool DisablePlugin(const FilePath& filename);
+
private:
// Constructors are private for singletons
PluginList();
@@ -222,6 +239,9 @@ class PluginList {
// Holds information about internal plugins.
std::vector<PluginVersionInfo> internal_plugins_;
+ // Path names of plugins to disable (the default is to enable them all).
+ std::set<FilePath> disabled_plugins_;
+
// Need synchronization for the above members since this object can be
// accessed on multiple threads.
Lock lock_;
diff --git a/webkit/glue/webplugininfo.h b/webkit/glue/webplugininfo.h
index 77c59ea..21f34df 100644
--- a/webkit/glue/webplugininfo.h
+++ b/webkit/glue/webplugininfo.h
@@ -39,6 +39,9 @@ struct WebPluginInfo {
// A list of all the mime types that this plugin supports.
std::vector<WebPluginMimeType> mime_types;
+
+ // Whether the plugin is enabled.
+ bool enabled;
};
#endif // WEBKIT_GLUE_WEBPLUGININFO_H_