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

Unified Diff: chrome/browser/plugin_prefs.h

Issue 7564006: Rename PluginUpdater to PluginPrefs and make it per-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 4 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
Index: chrome/browser/plugin_prefs.h
diff --git a/chrome/browser/plugin_updater.h b/chrome/browser/plugin_prefs.h
similarity index 59%
rename from chrome/browser/plugin_updater.h
rename to chrome/browser/plugin_prefs.h
index dc9cfaf6ab7012122fa8fefece627d356024c8e4..eae234c590dce50038d38db76b14d8ffef01b767 100644
--- a/chrome/browser/plugin_updater.h
+++ b/chrome/browser/plugin_prefs.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PLUGIN_UPDATER_H_
-#define CHROME_BROWSER_PLUGIN_UPDATER_H_
+#ifndef CHROME_BROWSER_PLUGIN_PREFS_H_
+#define CHROME_BROWSER_PLUGIN_PREFS_H_
#pragma once
#include <set>
@@ -12,7 +12,9 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/memory/singleton.h"
+#include "base/task.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
#include "content/common/notification_observer.h"
class NotificationDetails;
@@ -31,59 +33,69 @@ struct WebPluginInfo;
}
}
-class PluginUpdater : public NotificationObserver {
+class PluginPrefs : public ProfileKeyedService,
Elliot Glaysher 2011/08/04 17:51:00 Consider calling this PluginService, if to have a
Bernhard Bauer 2011/08/05 13:42:20 There is already a singleton in content/ called Pl
+ public NotificationObserver {
public:
- // Get a list of all the plugin groups. The caller should take ownership
- // of the returned ListValue.
- static base::ListValue* GetPluginGroupsData();
+ // This should be called before the first profile is created.
Elliot Glaysher 2011/08/04 17:51:00 Please mention that this will initialize the facto
Bernhard Bauer 2011/08/05 13:42:20 Done.
+ static void Initialize();
+
+ // This method should only be called on the UI thread.
+ 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::StringType& file_path);
+ void EnablePlugin(bool enable, const FilePath& file_path);
+
+ // Returns whether the plugin is enabled or not.
+ bool IsPluginEnabled(const webkit::npapi::WebPluginInfo& plugin);
- // Associates the PluginUpdater with |profile|. This enables or disables
+ // Associates the PluginPrefs with |profile|. This enables or disables
// plugin groups as defined by the user's preferences.
void SetProfile(Profile* profile);
- // Called at shutdown before the profile is destroyed.
- void Shutdown();
-
// Write the enable/disable status to the user's preference file.
- void UpdatePreferences(Profile* profile, int delay_ms);
+ void UpdatePreferences(int delay_ms);
// NotificationObserver method overrides
virtual void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details);
- static PluginUpdater* GetInstance();
-
static void RegisterPrefs(PrefService* prefs);
+ // ProfileKeyedService methods:
+ virtual void Shutdown() OVERRIDE;
+
private:
- PluginUpdater();
- virtual ~PluginUpdater() {}
+ class Factory;
+ struct PluginInfo;
+
+ PluginPrefs();
+ virtual ~PluginPrefs() {}
// Called on the file thread to get the data necessary to update the saved
- // preferences. The profile pointer is only to be passed to the UI thread.
- static void GetPreferencesDataOnFileThread(void* profile);
+ // preferences.
+ static void GetPreferencesDataOnFileThread(PluginInfo* plugin_info,
+ Task* callback);
// Called on the UI thread with the plugin data to save the preferences.
- static void OnUpdatePreferences(
- Profile* profile,
- const std::vector<webkit::npapi::WebPluginInfo>& plugins,
- const std::vector<webkit::npapi::PluginGroup>& groups);
+ void OnUpdatePreferences(const PluginInfo* plugin_info);
+
+ // Called on the UI thread after |OnUpdatePreference| to make sure that
+ // |plugin_info| isn't leaked even when the PluginPrefs instance should go
+ // away.
+ static void DeletePluginInfo(PluginInfo* plugin_info);
// 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.
- static void OnNotifyPluginStatusChanged();
+ void OnNotifyPluginStatusChanged();
- static base::DictionaryValue* CreatePluginFileSummary(
+ base::DictionaryValue* CreatePluginFileSummary(
const webkit::npapi::WebPluginInfo& plugin);
// Force plugins to be enabled or disabled due to policy.
@@ -97,14 +109,16 @@ class PluginUpdater : public NotificationObserver {
void ListValueToStringSet(const base::ListValue* src,
std::set<string16>* dest);
- // Needed to allow singleton instantiation using private constructor.
- friend struct DefaultSingletonTraits<PluginUpdater>;
+ // Weak pointer, owned by the profile.
+ PrefService* prefs_;
+
+ ScopedRunnableMethodFactory<PluginPrefs> factory_;
PrefChangeRegistrar registrar_;
bool notify_pending_;
- DISALLOW_COPY_AND_ASSIGN(PluginUpdater);
+ DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
};
-#endif // CHROME_BROWSER_PLUGIN_UPDATER_H_
+#endif // CHROME_BROWSER_PLUGIN_PREFS_H_

Powered by Google App Engine
This is Rietveld 408576698