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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
6 #define CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/prefs/pref_member.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16
17 class PluginPrefs;
18 class PrefService;
19 class Profile;
20
21 namespace webkit {
22 struct WebPluginInfo;
23 }
24
25 // Helper class modeled after BooleanPrefMember to (asynchronously) update
26 // preferences related to plugin enable status.
27 // It should only be used from the UI thread. The user has to make sure that
28 // the passed PluginStatusPrefSetter::Client objects and profile outlive this
29 // object.
30 class PluginStatusPrefSetter : public content::NotificationObserver {
31 public:
32 PluginStatusPrefSetter();
33 virtual ~PluginStatusPrefSetter();
34
35 class Client {
36 public:
37 Client();
38 virtual ~Client();
39
40 virtual const char* GetPrefName() const = 0;
41 virtual bool CalculatePrefValue(PluginPrefs* plugin_prefs) = 0;
42
43 // Called by PluginStatusPrefSetter.
44 void Init(PrefService* prefs, content::NotificationObserver* observer);
45
46 bool GetValue() const { return pref_.GetValue(); }
47
48 protected:
49 BooleanPrefMember pref_;
50 };
51
52 // Binds |clients| to the preferences in the profile's PrefService, notifying
53 // |observer| if any value changes.
54 // This asynchronously calls the PluginService to get the list of installed
55 // plug-ins.
56 void Init(const std::vector<Client*>& clients,
57 Profile* profile,
58 content::NotificationObserver* observer);
59
60 // content::NotificationObserver methods:
61 virtual void Observe(int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE;
64
65 private:
66 void StartUpdate();
67 void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs,
68 const std::vector<webkit::WebPluginInfo>& plugins);
69
70 // Not owned by this object.
71 std::vector<Client*> clients_;
72 content::NotificationRegistrar registrar_;
73 // Weak pointer.
74 Profile* profile_;
75 base::WeakPtrFactory<PluginStatusPrefSetter> factory_;
76
77 DISALLOW_COPY_AND_ASSIGN(PluginStatusPrefSetter);
78 };
79
80 #endif // CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698