OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PLUGINS_PLUGIN_PREFS_H_ | 5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ |
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ | 6 #define CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
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/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
18 #include "components/browser_context_keyed_service/refcounted_browser_context_ke
yed_service.h" | 18 #include "components/browser_context_keyed_service/refcounted_browser_context_ke
yed_service.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class ListValue; | 23 class ListValue; |
24 } | 24 } |
25 | 25 |
26 namespace webkit { | 26 namespace content { |
27 struct WebPluginInfo; | 27 struct WebPluginInfo; |
28 } | 28 } |
29 | 29 |
30 // This class stores information about whether a plug-in or a plug-in group is | 30 // This class stores information about whether a plug-in or a plug-in group is |
31 // enabled or disabled. | 31 // enabled or disabled. |
32 // Except where otherwise noted, it can be used on every thread. | 32 // Except where otherwise noted, it can be used on every thread. |
33 class PluginPrefs : public RefcountedBrowserContextKeyedService { | 33 class PluginPrefs : public RefcountedBrowserContextKeyedService { |
34 public: | 34 public: |
35 enum PolicyStatus { | 35 enum PolicyStatus { |
36 NO_POLICY = 0, // Neither enabled or disabled by policy. | 36 NO_POLICY = 0, // Neither enabled or disabled by policy. |
(...skipping 26 matching lines...) Expand all Loading... |
63 // with 'false' passed to it. Otherwise the plug-in state is changed | 63 // with 'false' passed to it. Otherwise the plug-in state is changed |
64 // and |callback| is run with 'true' passed to it. | 64 // and |callback| is run with 'true' passed to it. |
65 void EnablePlugin(bool enable, const base::FilePath& file_path, | 65 void EnablePlugin(bool enable, const base::FilePath& file_path, |
66 const base::Callback<void(bool)>& callback); | 66 const base::Callback<void(bool)>& callback); |
67 | 67 |
68 // Returns whether there is a policy enabling or disabling plug-ins of the | 68 // Returns whether there is a policy enabling or disabling plug-ins of the |
69 // given name. | 69 // given name. |
70 PolicyStatus PolicyStatusForPlugin(const string16& name) const; | 70 PolicyStatus PolicyStatusForPlugin(const string16& name) const; |
71 | 71 |
72 // Returns whether the plugin is enabled or not. | 72 // Returns whether the plugin is enabled or not. |
73 bool IsPluginEnabled(const webkit::WebPluginInfo& plugin) const; | 73 bool IsPluginEnabled(const content::WebPluginInfo& plugin) const; |
74 | 74 |
75 void set_profile(Profile* profile) { profile_ = profile; } | 75 void set_profile(Profile* profile) { profile_ = profile; } |
76 | 76 |
77 // RefCountedProfileKeyedBase method override. | 77 // RefCountedProfileKeyedBase method override. |
78 virtual void ShutdownOnUIThread() OVERRIDE; | 78 virtual void ShutdownOnUIThread() OVERRIDE; |
79 | 79 |
80 private: | 80 private: |
81 friend class base::RefCountedThreadSafe<PluginPrefs>; | 81 friend class base::RefCountedThreadSafe<PluginPrefs>; |
82 friend class PluginPrefsTest; | 82 friend class PluginPrefsTest; |
83 | 83 |
(...skipping 26 matching lines...) Expand all Loading... |
110 // Allows unit tests to directly set enforced plug-in patterns. | 110 // Allows unit tests to directly set enforced plug-in patterns. |
111 void SetPolicyEnforcedPluginPatterns( | 111 void SetPolicyEnforcedPluginPatterns( |
112 const std::set<string16>& disabled_patterns, | 112 const std::set<string16>& disabled_patterns, |
113 const std::set<string16>& disabled_exception_patterns, | 113 const std::set<string16>& disabled_exception_patterns, |
114 const std::set<string16>& enabled_patterns); | 114 const std::set<string16>& enabled_patterns); |
115 | 115 |
116 // Callback for after the plugin groups have been loaded. | 116 // Callback for after the plugin groups have been loaded. |
117 void EnablePluginGroupInternal( | 117 void EnablePluginGroupInternal( |
118 bool enabled, | 118 bool enabled, |
119 const string16& group_name, | 119 const string16& group_name, |
120 const std::vector<webkit::WebPluginInfo>& plugins); | 120 const std::vector<content::WebPluginInfo>& plugins); |
121 void EnablePluginInternal( | 121 void EnablePluginInternal( |
122 bool enabled, | 122 bool enabled, |
123 const base::FilePath& path, | 123 const base::FilePath& path, |
124 PluginFinder* plugin_finder, | 124 PluginFinder* plugin_finder, |
125 const base::Callback<void(bool)>& callback, | 125 const base::Callback<void(bool)>& callback, |
126 const std::vector<webkit::WebPluginInfo>& plugins); | 126 const std::vector<content::WebPluginInfo>& plugins); |
127 | 127 |
128 // Called on the UI thread with the plugin data to save the preferences. | 128 // Called on the UI thread with the plugin data to save the preferences. |
129 void OnUpdatePreferences(const std::vector<webkit::WebPluginInfo>& plugins); | 129 void OnUpdatePreferences(const std::vector<content::WebPluginInfo>& plugins); |
130 | 130 |
131 // Sends the notification that plugin data has changed. | 131 // Sends the notification that plugin data has changed. |
132 void NotifyPluginStatusChanged(); | 132 void NotifyPluginStatusChanged(); |
133 | 133 |
134 static void ListValueToStringSet(const base::ListValue* src, | 134 static void ListValueToStringSet(const base::ListValue* src, |
135 std::set<string16>* dest); | 135 std::set<string16>* dest); |
136 | 136 |
137 // Checks if |name| matches any of the patterns in |pattern_set|. | 137 // Checks if |name| matches any of the patterns in |pattern_set|. |
138 static bool IsStringMatchedInSet(const string16& name, | 138 static bool IsStringMatchedInSet(const string16& name, |
139 const std::set<string16>& pattern_set); | 139 const std::set<string16>& pattern_set); |
(...skipping 13 matching lines...) Expand all Loading... |
153 | 153 |
154 // Weak pointer, owned by the profile. | 154 // Weak pointer, owned by the profile. |
155 PrefService* prefs_; | 155 PrefService* prefs_; |
156 | 156 |
157 PrefChangeRegistrar registrar_; | 157 PrefChangeRegistrar registrar_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); | 159 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); |
160 }; | 160 }; |
161 | 161 |
162 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ | 162 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ |
OLD | NEW |