| Index: chrome/browser/plugin_prefs.h
|
| diff --git a/chrome/browser/plugin_prefs.h b/chrome/browser/plugin_prefs.h
|
| index d55a6000c15fae5a1cb57b1d7cd8b33b6fd1d13b..aa3cb2302aaf23e54a1e827972f11afaae7907a8 100644
|
| --- a/chrome/browser/plugin_prefs.h
|
| +++ b/chrome/browser/plugin_prefs.h
|
| @@ -6,12 +6,14 @@
|
| #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"
|
|
|
| @@ -42,6 +44,12 @@ class PluginGroup;
|
| 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();
|
| @@ -57,17 +65,25 @@ class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>,
|
| void SetPrefs(PrefService* prefs);
|
|
|
| // Enable or disable a plugin group.
|
| + // This method should only be called on the FILE thread.
|
| void EnablePluginGroup(bool enable, const string16& group_name);
|
|
|
| // Enable or disable a specific plugin file.
|
| + // This method should only be called on the FILE thread.
|
| void EnablePlugin(bool enable, const FilePath& file_path);
|
|
|
| + // All plug-ins default to being enabled until they're disabled by the user.
|
| + // This allows us to let a plug-in start out disabled, even for profiles that
|
| + // don't exist yet.
|
| + static void EnablePluginDefault(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);
|
|
|
| - // 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,
|
| @@ -79,47 +95,51 @@ class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>,
|
|
|
| private:
|
| friend class base::RefCountedThreadSafe<PluginPrefs>;
|
| + friend class PluginPrefsTest;
|
|
|
| class Factory;
|
|
|
| virtual ~PluginPrefs();
|
|
|
| + 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::WebPluginInfo> plugins,
|
| - std::vector<webkit::npapi::PluginGroup> groups);
|
| + void OnUpdatePreferences(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.
|
| + // Sends the notification that plugin data has changed.
|
| void NotifyPluginStatusChanged();
|
|
|
| // Used for the post task to notify that plugin enabled status changed.
|
| void OnNotifyPluginStatusChanged();
|
|
|
| - base::DictionaryValue* CreatePluginFileSummary(
|
| - const webkit::WebPluginInfo& plugin);
|
| + 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);
|
|
|
| - // 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);
|
| + mutable base::Lock lock_;
|
|
|
| - void ListValueToStringSet(const base::ListValue* src,
|
| - std::set<string16>* dest);
|
| + std::map<FilePath, bool> plugin_state_;
|
| + std::map<string16, bool> plugin_group_state_;
|
| +
|
| + std::set<string16> policy_disabled_plugin_patterns_;
|
| + std::set<string16> policy_disabled_plugin_exception_patterns_;
|
| + std::set<string16> policy_enabled_plugin_patterns_;
|
|
|
| // Weak pointer, owned by the profile.
|
| PrefService* prefs_;
|
|
|
| PrefChangeRegistrar registrar_;
|
|
|
| - bool notify_pending_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
|
| };
|
|
|
|
|