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

Side by Side 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: alphabetize 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/pdf_unsupported_feature.cc ('k') | chrome/browser/plugin_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PLUGIN_UPDATER_H_ 5 #ifndef CHROME_BROWSER_PLUGIN_PREFS_H_
6 #define CHROME_BROWSER_PLUGIN_UPDATER_H_ 6 #define CHROME_BROWSER_PLUGIN_PREFS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/ref_counted.h"
15 #include "chrome/browser/prefs/pref_change_registrar.h" 15 #include "chrome/browser/prefs/pref_change_registrar.h"
16 #include "content/common/notification_observer.h" 16 #include "content/common/notification_observer.h"
17 17
18 class NotificationDetails; 18 class NotificationDetails;
19 class NotificationSource; 19 class NotificationSource;
20 class Profile; 20 class Profile;
21 21
22 namespace content {
23 class ResourceContext;
24 }
25
22 namespace base { 26 namespace base {
23 class DictionaryValue; 27 class DictionaryValue;
24 class ListValue; 28 class ListValue;
25 } 29 }
26 30
27 namespace webkit { 31 namespace webkit {
28 namespace npapi { 32 namespace npapi {
29 class PluginGroup; 33 class PluginGroup;
30 struct WebPluginInfo; 34 struct WebPluginInfo;
31 } 35 }
32 } 36 }
33 37
34 class PluginUpdater : public NotificationObserver { 38 // This class stores information about whether a plug-in or a plug-in group is
39 // enabled or disabled.
40 // Except for the |IsPluginEnabled| method, it should only be used on the UI
41 // thread.
42 class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>,
43 public NotificationObserver {
35 public: 44 public:
36 // Get a list of all the plugin groups. The caller should take ownership 45 // Initializes the factory for this class for dependency tracking.
37 // of the returned ListValue. 46 // This should be called before the first profile is created.
38 static base::ListValue* GetPluginGroupsData(); 47 static void Initialize();
48
49 static PluginPrefs* GetForProfile(Profile* profile);
39 50
40 // Enable or disable a plugin group. 51 // Enable or disable a plugin group.
41 void EnablePluginGroup(bool enable, const string16& group_name); 52 void EnablePluginGroup(bool enable, const string16& group_name);
42 53
43 // Enable or disable a specific plugin file. 54 // Enable or disable a specific plugin file.
44 void EnablePlugin(bool enable, const FilePath::StringType& file_path); 55 void EnablePlugin(bool enable, const FilePath& file_path);
45 56
46 // Associates the PluginUpdater with |profile|. This enables or disables 57 // Returns whether the plugin is enabled or not.
47 // plugin groups as defined by the user's preferences. 58 bool IsPluginEnabled(const webkit::npapi::WebPluginInfo& plugin);
48 void SetProfile(Profile* profile);
49
50 // Called at shutdown before the profile is destroyed.
51 void Shutdown();
52 59
53 // Write the enable/disable status to the user's preference file. 60 // Write the enable/disable status to the user's preference file.
54 void UpdatePreferences(Profile* profile, int delay_ms); 61 void UpdatePreferences(int delay_ms);
55 62
56 // NotificationObserver method overrides 63 // NotificationObserver method overrides
57 virtual void Observe(int type, 64 virtual void Observe(int type,
58 const NotificationSource& source, 65 const NotificationSource& source,
59 const NotificationDetails& details); 66 const NotificationDetails& details);
60 67
61 static PluginUpdater* GetInstance();
62
63 static void RegisterPrefs(PrefService* prefs); 68 static void RegisterPrefs(PrefService* prefs);
64 69
70 void ShutdownOnUIThread();
71
65 private: 72 private:
66 PluginUpdater(); 73 friend class base::RefCountedThreadSafe<PluginPrefs>;
67 virtual ~PluginUpdater() {} 74
75 class Factory;
76
77 PluginPrefs();
78 virtual ~PluginPrefs();
79
80 // Associates the PluginPrefs with |profile|. This enables or disables
81 // plugin groups as defined by the user's preferences.
82 void SetProfile(Profile* profile);
68 83
69 // Called on the file thread to get the data necessary to update the saved 84 // Called on the file thread to get the data necessary to update the saved
70 // preferences. The profile pointer is only to be passed to the UI thread. 85 // preferences.
71 static void GetPreferencesDataOnFileThread(void* profile); 86 void GetPreferencesDataOnFileThread();
72 87
73 // Called on the UI thread with the plugin data to save the preferences. 88 // Called on the UI thread with the plugin data to save the preferences.
74 static void OnUpdatePreferences( 89 void OnUpdatePreferences(std::vector<webkit::npapi::WebPluginInfo> plugins,
75 Profile* profile, 90 std::vector<webkit::npapi::PluginGroup> groups);
76 const std::vector<webkit::npapi::WebPluginInfo>& plugins,
77 const std::vector<webkit::npapi::PluginGroup>& groups);
78 91
79 // Queues sending the notification that plugin data has changed. This is done 92 // Queues sending the notification that plugin data has changed. This is done
80 // so that if a bunch of changes happen, we only send one notification. 93 // so that if a bunch of changes happen, we only send one notification.
81 void NotifyPluginStatusChanged(); 94 void NotifyPluginStatusChanged();
82 95
83 // Used for the post task to notify that plugin enabled status changed. 96 // Used for the post task to notify that plugin enabled status changed.
84 static void OnNotifyPluginStatusChanged(); 97 void OnNotifyPluginStatusChanged();
85 98
86 static base::DictionaryValue* CreatePluginFileSummary( 99 base::DictionaryValue* CreatePluginFileSummary(
87 const webkit::npapi::WebPluginInfo& plugin); 100 const webkit::npapi::WebPluginInfo& plugin);
88 101
89 // Force plugins to be enabled or disabled due to policy. 102 // Force plugins to be enabled or disabled due to policy.
90 // |disabled_list| contains the list of StringValues of the names of the 103 // |disabled_list| contains the list of StringValues of the names of the
91 // policy-disabled plugins, |exceptions_list| the policy-allowed plugins, 104 // policy-disabled plugins, |exceptions_list| the policy-allowed plugins,
92 // and |enabled_list| the policy-enabled plugins. 105 // and |enabled_list| the policy-enabled plugins.
93 void UpdatePluginsStateFromPolicy(const base::ListValue* disabled_list, 106 void UpdatePluginsStateFromPolicy(const base::ListValue* disabled_list,
94 const base::ListValue* exceptions_list, 107 const base::ListValue* exceptions_list,
95 const base::ListValue* enabled_list); 108 const base::ListValue* enabled_list);
96 109
97 void ListValueToStringSet(const base::ListValue* src, 110 void ListValueToStringSet(const base::ListValue* src,
98 std::set<string16>* dest); 111 std::set<string16>* dest);
99 112
100 // Needed to allow singleton instantiation using private constructor. 113 // Weak pointer, owned by the profile.
101 friend struct DefaultSingletonTraits<PluginUpdater>; 114 PrefService* prefs_;
102 115
103 PrefChangeRegistrar registrar_; 116 PrefChangeRegistrar registrar_;
104 117
105 bool notify_pending_; 118 bool notify_pending_;
106 119
107 DISALLOW_COPY_AND_ASSIGN(PluginUpdater); 120 DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
108 }; 121 };
109 122
110 #endif // CHROME_BROWSER_PLUGIN_UPDATER_H_ 123 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/pdf_unsupported_feature.cc ('k') | chrome/browser/plugin_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698