Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4990)

Unified Diff: chrome/browser/plugin_prefs.h

Issue 7901015: Revert 101269 - Store plug-in enabled/disabled state in PluginPrefs instead of WebPluginInfo, to ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/plugin_exceptions_table_model_unittest.cc ('k') | chrome/browser/plugin_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/plugin_prefs.h
===================================================================
--- chrome/browser/plugin_prefs.h (revision 101271)
+++ chrome/browser/plugin_prefs.h (working copy)
@@ -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 @@
// 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 @@
// 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);
+ // Used for the post task to notify that plugin enabled status changed.
+ void OnNotifyPluginStatusChanged();
- // Checks if |name| matches any of the patterns in |pattern_set|.
- static bool IsStringMatchedInSet(const string16& name,
- const std::set<string16>& pattern_set);
+ base::DictionaryValue* CreatePluginFileSummary(
+ const webkit::WebPluginInfo& plugin);
- // Guards access to the following data structures.
- mutable base::Lock lock_;
+ // 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::map<FilePath, bool> plugin_state_;
- std::map<string16, bool> plugin_group_state_;
+ void ListValueToStringSet(const base::ListValue* src,
+ std::set<string16>* dest);
- 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 (which owns us).
+ // Weak pointer, owned by the profile.
PrefService* prefs_;
PrefChangeRegistrar registrar_;
+ bool notify_pending_;
+
DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
};
Property changes on: chrome/browser/plugin_prefs.h
___________________________________________________________________
Added: svn:mergeinfo
« no previous file with comments | « chrome/browser/plugin_exceptions_table_model_unittest.cc ('k') | chrome/browser/plugin_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698