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

Unified Diff: chrome/browser/plugin_status_pref_setter.h

Issue 10387161: Pepper Flash settings integration: add UI for "deauthorize content licenses". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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_status_pref_setter.h
diff --git a/chrome/browser/plugin_status_pref_setter.h b/chrome/browser/plugin_status_pref_setter.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4da7d4a067990270ec0a20cfb442a22d459103f
--- /dev/null
+++ b/chrome/browser/plugin_status_pref_setter.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2012 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_STATUS_PREF_SETTER_H_
+#define CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
+#pragma once
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/prefs/pref_member.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class PluginPrefs;
+class PrefService;
+class Profile;
+
+namespace webkit {
+struct WebPluginInfo;
+}
+
+// Helper class modeled after BooleanPrefMember to (asynchronously) update
+// preferences related to plugin enable status.
+// It should only be used from the UI thread. The user has to make sure that
+// the passed PluginStatusPrefSetter::Client objects and profile outlive this
+// object.
+class PluginStatusPrefSetter : public content::NotificationObserver {
+ public:
+ PluginStatusPrefSetter();
+ virtual ~PluginStatusPrefSetter();
+
+ class Client {
+ public:
+ Client();
+ virtual ~Client();
+
+ virtual const char* GetPrefName() const = 0;
+ virtual bool CalculatePrefValue(PluginPrefs* plugin_prefs) = 0;
+
+ // Called by PluginStatusPrefSetter.
+ void Init(PrefService* prefs, content::NotificationObserver* observer);
+
+ bool GetValue() const { return pref_.GetValue(); }
+
+ protected:
+ BooleanPrefMember pref_;
+ };
+
+ // Binds |clients| to the preferences in the profile's PrefService, notifying
+ // |observer| if any value changes.
+ // This asynchronously calls the PluginService to get the list of installed
+ // plug-ins.
+ void Init(const std::vector<Client*>& clients,
+ Profile* profile,
+ content::NotificationObserver* observer);
+
+ // content::NotificationObserver methods:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ void StartUpdate();
+ void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs,
+ const std::vector<webkit::WebPluginInfo>& plugins);
+
+ // Not owned by this object.
+ std::vector<Client*> clients_;
+ content::NotificationRegistrar registrar_;
+ // Weak pointer.
+ Profile* profile_;
+ base::WeakPtrFactory<PluginStatusPrefSetter> factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginStatusPrefSetter);
+};
+
+#endif // CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_

Powered by Google App Engine
This is Rietveld 408576698