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> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::string16& name) const; | 70 PolicyStatus PolicyStatusForPlugin(const base::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 content::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 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 |
84 // PluginState stores a mapping from plugin path to enable/disable state. We | 84 // PluginState stores a mapping from plugin path to enable/disable state. We |
85 // don't simply use a std::map, because we would like to keep the state of | 85 // don't simply use a std::map, because we would like to keep the state of |
86 // some plugins in sync with each other. | 86 // some plugins in sync with each other. |
87 class PluginState { | 87 class PluginState { |
88 public: | 88 public: |
89 PluginState(); | 89 PluginState(); |
90 ~PluginState(); | 90 ~PluginState(); |
91 | 91 |
92 // Returns whether |plugin| is found. If |plugin| cannot be found, | 92 // Returns whether |plugin| is found. If |plugin| cannot be found, |
93 // |*enabled| won't be touched. | 93 // |*enabled| won't be touched. |
94 bool Get(const base::FilePath& plugin, bool* enabled) const; | 94 bool Get(const base::FilePath& plugin, bool* enabled) const; |
95 void Set(const base::FilePath& plugin, bool enabled); | 95 void Set(const base::FilePath& plugin, bool enabled); |
96 | 96 |
97 private: | 97 private: |
98 base::FilePath ConvertMapKey(const base::FilePath& plugin) const; | 98 base::FilePath ConvertMapKey(const base::FilePath& plugin) const; |
99 | 99 |
100 std::map<base::FilePath, bool> state_; | 100 std::map<base::FilePath, bool> state_; |
101 }; | 101 }; |
102 | 102 |
103 virtual ~PluginPrefs(); | 103 ~PluginPrefs() override; |
104 | 104 |
105 // Called to update one of the policy_xyz patterns below when a | 105 // Called to update one of the policy_xyz patterns below when a |
106 // preference changes. | 106 // preference changes. |
107 void UpdatePatternsAndNotify(std::set<base::string16>* patterns, | 107 void UpdatePatternsAndNotify(std::set<base::string16>* patterns, |
108 const std::string& pref_name); | 108 const std::string& pref_name); |
109 | 109 |
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<base::string16>& disabled_patterns, | 112 const std::set<base::string16>& disabled_patterns, |
113 const std::set<base::string16>& disabled_exception_patterns, | 113 const std::set<base::string16>& disabled_exception_patterns, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |