diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 09:42:23 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 09:42:23 +0000 |
commit | 3eff9e2e46c00ec5c0316fef6c44355793f1906d (patch) | |
tree | b4a346aefc756be26707cfa00952d906df8c95ba /chrome/browser/plugin_prefs.h | |
parent | 682ef685be471686d07513f4e44e59c9a71cf356 (diff) | |
download | chromium_src-3eff9e2e46c00ec5c0316fef6c44355793f1906d.zip chromium_src-3eff9e2e46c00ec5c0316fef6c44355793f1906d.tar.gz chromium_src-3eff9e2e46c00ec5c0316fef6c44355793f1906d.tar.bz2 |
Revert 101269 - Store plug-in enabled/disabled state in PluginPrefs instead of WebPluginInfo, to allow different sets of enabled/disabled plug-ins to be specified per profile.
BUG=80794
TEST=Open two profiles, disable different plugins in them.
Review URL: http://codereview.chromium.org/7848025
TBR=bauerb@chromium.org
Review URL: http://codereview.chromium.org/7901015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_prefs.h')
-rw-r--r-- | chrome/browser/plugin_prefs.h | 86 |
1 files changed, 30 insertions, 56 deletions
diff --git a/chrome/browser/plugin_prefs.h b/chrome/browser/plugin_prefs.h index ecfd585..d55a600 100644 --- a/chrome/browser/plugin_prefs.h +++ b/chrome/browser/plugin_prefs.h @@ -6,14 +6,12 @@ #define CHROME_BROWSER_PLUGIN_PREFS_H_ #pragma once -#include <map> #include <set> #include <vector> #include "base/basictypes.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" -#include "base/synchronization/lock.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "content/common/notification_observer.h" @@ -39,16 +37,11 @@ class PluginGroup; // This class stores information about whether a plug-in or a plug-in group is // enabled or disabled. -// Except where otherwise noted, it can be used on every thread. +// Except for the |IsPluginEnabled| method, it should only be used on the UI +// thread. class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>, public NotificationObserver { public: - enum PolicyStatus { - NO_POLICY = 0, // Neither enabled or disabled by policy. - POLICY_ENABLED, - POLICY_DISABLED, - }; - // Initializes the factory for this class for dependency tracking. // This should be called before the first profile is created. static void Initialize(); @@ -56,96 +49,77 @@ class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>, // Returns the instance associated with |profile|, creating it if necessary. static PluginPrefs* GetForProfile(Profile* profile); - // Usually the PluginPrefs associated with a TestingProfile is NULL. - // This method overrides that for a given TestingProfile, returning the newly - // created PluginPrefs object. - static PluginPrefs* GetForTestingProfile(Profile* profile); - // Creates a new instance. This method should only be used for testing. PluginPrefs(); // Associates this instance with |prefs|. This enables or disables // plugin groups as defined by the user's preferences. - // This method should only be called on the UI thread. void SetPrefs(PrefService* prefs); - // Detaches from the PrefService before it is destroyed. - // As the name says, this method should only be called on the UI thread. - void ShutdownOnUIThread(); - // 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); - // Enable or disable a plug-in in all profiles. This sets a default for - // profiles which are created later as well. - // This method should only be called on the UI thread. - static void EnablePluginGlobally(bool enable, const FilePath& file_path); - - // Returns whether there is a policy enabling or disabling plug-ins of the - // given name. - PolicyStatus PolicyStatusForPlugin(const string16& name); - // Returns whether the plugin is enabled or not. bool IsPluginEnabled(const webkit::WebPluginInfo& plugin); - // Registers the preferences used by this class. - // This method should only be called on the UI thread. - static void RegisterPrefs(PrefService* prefs); + // Write the enable/disable status to the user's preference file. + void UpdatePreferences(int delay_ms); - // NotificationObserver method override. + // NotificationObserver method overrides virtual void Observe(int type, const NotificationSource& source, - const NotificationDetails& details) OVERRIDE; + const NotificationDetails& details); + + static void RegisterPrefs(PrefService* prefs); + + void ShutdownOnUIThread(); private: friend class base::RefCountedThreadSafe<PluginPrefs>; - friend class PluginPrefsTest; class Factory; virtual ~PluginPrefs(); - // Allows unit tests to directly set enforced plug-in patterns. - void SetPolicyEnforcedPluginPatterns( - const std::set<string16>& disabled_patterns, - const std::set<string16>& disabled_exception_patterns, - const std::set<string16>& enabled_patterns); - // 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::npapi::PluginGroup> groups); + void OnUpdatePreferences(std::vector<webkit::WebPluginInfo> plugins, + std::vector<webkit::npapi::PluginGroup> groups); - // Sends the notification that plugin data has changed. + // 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(); - static void ListValueToStringSet(const base::ListValue* src, - std::set<string16>* dest); - - // Checks if |name| matches any of the patterns in |pattern_set|. - static bool IsStringMatchedInSet(const string16& name, - const std::set<string16>& pattern_set); + // Used for the post task to notify that plugin enabled status changed. + void OnNotifyPluginStatusChanged(); - // Guards access to the following data structures. - mutable base::Lock lock_; + base::DictionaryValue* CreatePluginFileSummary( + const webkit::WebPluginInfo& plugin); - std::map<FilePath, bool> plugin_state_; - std::map<string16, bool> plugin_group_state_; + // 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); - std::set<string16> policy_disabled_plugin_patterns_; - std::set<string16> policy_disabled_plugin_exception_patterns_; - std::set<string16> policy_enabled_plugin_patterns_; + void ListValueToStringSet(const base::ListValue* src, + std::set<string16>* dest); - // Weak pointer, owned by the profile (which owns us). + // Weak pointer, owned by the profile. PrefService* prefs_; PrefChangeRegistrar registrar_; + bool notify_pending_; + DISALLOW_COPY_AND_ASSIGN(PluginPrefs); }; |