summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_service.cc
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 /chrome/browser/plugin_service.cc
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 'chrome/browser/plugin_service.cc')
-rw-r--r--chrome/browser/plugin_service.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 987d68e..12a15e1 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -10,12 +10,15 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/thread.h"
+#include "base/values.h"
#include "base/waitable_event.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/plugin_process_host.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/common/chrome_paths.h"
@@ -25,6 +28,7 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#ifndef DISABLE_NACL
#include "native_client/src/trusted/plugin/nacl_entry_points.h"
@@ -48,6 +52,34 @@ static void NotifyPluginsOfActivation() {
bool PluginService::enable_chrome_plugins_ = true;
// static
+void PluginService::InitGlobalInstance(Profile* profile) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ // Disable plugins listed as disabled in prefs.
+ if (const ListValue* saved_plugins_list =
+ profile->GetPrefs()->GetList(prefs::kPluginsPluginsList)) {
+ for (ListValue::const_iterator it = saved_plugins_list->begin();
+ it != saved_plugins_list->end();
+ ++it) {
+ if (!(*it)->IsType(Value::TYPE_DICTIONARY)) {
+ LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList;
+ continue; // Oops, don't know what to do with this item.
+ }
+
+ DictionaryValue* plugin = static_cast<DictionaryValue*>(*it);
+ FilePath::StringType path;
+ bool enabled = true;
+ plugin->GetBoolean(L"enabled", &enabled);
+ if (!enabled && plugin->GetString(L"path", &path))
+ NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(path));
+ }
+ }
+
+ // Have Chrome plugins write their data to the profile directory.
+ GetInstance()->SetChromePluginDataDir(profile->GetPath());
+}
+
+// static
PluginService* PluginService::GetInstance() {
return Singleton<PluginService>::get();
}