diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 10:36:59 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 10:36:59 +0000 |
commit | 8a2713686b6631c559ac4505747089fb2f93aeb6 (patch) | |
tree | df6c9ea119b68d5416bd04026359710380baacaa /chrome/browser/plugin_prefs.h | |
parent | 4c19b042ea31bd393d2265656f94339d1c3d82ff (diff) | |
download | chromium_src-8a2713686b6631c559ac4505747089fb2f93aeb6.zip chromium_src-8a2713686b6631c559ac4505747089fb2f93aeb6.tar.gz chromium_src-8a2713686b6631c559ac4505747089fb2f93aeb6.tar.bz2 |
Reland r96364: Rename PluginUpdater to PluginPrefs and make it per-profile.
BUG=80794
TEST=none
Review URL: http://codereview.chromium.org/7639017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_prefs.h')
-rw-r--r-- | chrome/browser/plugin_prefs.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/chrome/browser/plugin_prefs.h b/chrome/browser/plugin_prefs.h new file mode 100644 index 0000000..ae19ad4 --- /dev/null +++ b/chrome/browser/plugin_prefs.h @@ -0,0 +1,123 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_PLUGIN_PREFS_H_ +#define CHROME_BROWSER_PLUGIN_PREFS_H_ +#pragma once + +#include <set> +#include <vector> + +#include "base/basictypes.h" +#include "base/file_path.h" +#include "base/memory/ref_counted.h" +#include "chrome/browser/prefs/pref_change_registrar.h" +#include "content/common/notification_observer.h" + +class NotificationDetails; +class NotificationSource; +class Profile; + +namespace content { +class ResourceContext; +} + +namespace base { +class DictionaryValue; +class ListValue; +} + +namespace webkit { +struct WebPluginInfo; +namespace npapi { +class PluginGroup; +} +} + +// This class stores information about whether a plug-in or a plug-in group is +// enabled or disabled. +// Except for the |IsPluginEnabled| method, it should only be used on the UI +// thread. +class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>, + public NotificationObserver { + public: + // Initializes the factory for this class for dependency tracking. + // This should be called before the first profile is created. + static void Initialize(); + + static PluginPrefs* GetForProfile(Profile* profile); + + // Enable or disable a plugin group. + void EnablePluginGroup(bool enable, const string16& group_name); + + // Enable or disable a specific plugin file. + void EnablePlugin(bool enable, const FilePath& file_path); + + // Returns whether the plugin is enabled or not. + bool IsPluginEnabled(const webkit::WebPluginInfo& plugin); + + // Write the enable/disable status to the user's preference file. + void UpdatePreferences(int delay_ms); + + // NotificationObserver method overrides + virtual void Observe(int type, + const NotificationSource& source, + const NotificationDetails& details); + + static void RegisterPrefs(PrefService* prefs); + + void ShutdownOnUIThread(); + + private: + friend class base::RefCountedThreadSafe<PluginPrefs>; + + class Factory; + + PluginPrefs(); + virtual ~PluginPrefs(); + + // Associates the PluginPrefs with |profile|. This enables or disables + // plugin groups as defined by the user's preferences. + void SetProfile(Profile* profile); + + // Called on the file thread to get the data necessary to update the saved + // preferences. + void GetPreferencesDataOnFileThread(); + + // Called on the UI thread with the plugin data to save the preferences. + void OnUpdatePreferences(std::vector<webkit::WebPluginInfo> plugins, + std::vector<webkit::npapi::PluginGroup> groups); + + // Queues sending the notification that plugin data has changed. This is done + // so that if a bunch of changes happen, we only send one notification. + void NotifyPluginStatusChanged(); + + // Used for the post task to notify that plugin enabled status changed. + void OnNotifyPluginStatusChanged(); + + base::DictionaryValue* CreatePluginFileSummary( + const webkit::WebPluginInfo& plugin); + + // Force plugins to be enabled or disabled due to policy. + // |disabled_list| contains the list of StringValues of the names of the + // policy-disabled plugins, |exceptions_list| the policy-allowed plugins, + // and |enabled_list| the policy-enabled plugins. + void UpdatePluginsStateFromPolicy(const base::ListValue* disabled_list, + const base::ListValue* exceptions_list, + const base::ListValue* enabled_list); + + void ListValueToStringSet(const base::ListValue* src, + std::set<string16>* dest); + + // Weak pointer, owned by the profile. + PrefService* prefs_; + + PrefChangeRegistrar registrar_; + + bool notify_pending_; + + DISALLOW_COPY_AND_ASSIGN(PluginPrefs); +}; + +#endif // CHROME_BROWSER_PLUGIN_PREFS_H_ |