Chromium Code Reviews| 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_PLUGIN_PREFS_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_PREFS_H_ |
| 6 #define CHROME_BROWSER_PLUGIN_PREFS_H_ | 6 #define CHROME_BROWSER_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/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 15 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 16 #include "chrome/browser/plugin_finder.h" | |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" | 18 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class ListValue; | 24 class ListValue; |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 PluginPrefs(); | 59 PluginPrefs(); |
| 59 | 60 |
| 60 // Associates this instance with |prefs|. This enables or disables | 61 // Associates this instance with |prefs|. This enables or disables |
| 61 // plugin groups as defined by the user's preferences. | 62 // plugin groups as defined by the user's preferences. |
| 62 // This method should only be called on the UI thread. | 63 // This method should only be called on the UI thread. |
| 63 void SetPrefs(PrefService* prefs); | 64 void SetPrefs(PrefService* prefs); |
| 64 | 65 |
| 65 // Enable or disable a plugin group. | 66 // Enable or disable a plugin group. |
| 66 void EnablePluginGroup(bool enable, const string16& group_name); | 67 void EnablePluginGroup(bool enable, const string16& group_name); |
| 67 | 68 |
| 68 // Returns true if the plug-in state can be enabled or disabled according to | 69 // Checks if the plug-in state can be enabled or disabled according to |
| 69 // |enable|, false if the plug-in state cannot be changed because of a policy. | 70 // |enable| or if the plug-in state cannot be changed because of a policy. |
| 70 bool CanEnablePlugin(bool enable, const FilePath& file_path); | 71 void CanEnablePlugin(bool enable, const FilePath& file_path, |
|
Bernhard Bauer
2012/08/24 08:15:34
I think we could combine these methods. There are
ibraaaa
2012/08/24 15:51:29
I wanted to leave this in another CL with modifyin
| |
| 72 const base::Callback<void(bool)>& cb); | |
| 71 | 73 |
| 72 // Enables or disables a specific plugin file, and calls |callback| | 74 // Enables or disables a specific plugin file, and calls |callback| |
| 73 // afterwards. | 75 // afterwards. |
| 74 // If the plug-in state cannot be changed because of a policy (as indicated | 76 // If the plug-in state cannot be changed because of a policy (as indicated |
| 75 // by |CanEnablePlugin|), it will be silently ignored. | 77 // by |CanEnablePlugin|), it will be silently ignored. |
| 76 void EnablePlugin(bool enable, const FilePath& file_path, | 78 void EnablePlugin(bool enable, const FilePath& file_path, |
| 77 const base::Closure& callback); | 79 const base::Closure& callback); |
| 78 | 80 |
| 79 // Enables or disables a plug-in in all profiles, and calls |callback| | 81 // Enables or disables a plug-in in all profiles, and calls |callback| |
| 80 // afterwards. This sets a default for profiles which are created later as | 82 // afterwards. This sets a default for profiles which are created later as |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // Sends the notification that plugin data has changed. | 145 // Sends the notification that plugin data has changed. |
| 144 void NotifyPluginStatusChanged(); | 146 void NotifyPluginStatusChanged(); |
| 145 | 147 |
| 146 static void ListValueToStringSet(const base::ListValue* src, | 148 static void ListValueToStringSet(const base::ListValue* src, |
| 147 std::set<string16>* dest); | 149 std::set<string16>* dest); |
| 148 | 150 |
| 149 // Checks if |name| matches any of the patterns in |pattern_set|. | 151 // Checks if |name| matches any of the patterns in |pattern_set|. |
| 150 static bool IsStringMatchedInSet(const string16& name, | 152 static bool IsStringMatchedInSet(const string16& name, |
| 151 const std::set<string16>& pattern_set); | 153 const std::set<string16>& pattern_set); |
| 152 | 154 |
| 155 // Callback method called by 'CanEnablePlugin' method. | |
| 156 // It performs the actual logic to check if a plug-in can be enabled. | |
| 157 void CanEnablePluginCallback(bool enabled, const FilePath& path, | |
| 158 const base::Callback<void(bool)>& cb, | |
| 159 PluginFinder* finder); | |
| 160 | |
| 153 // Guards access to the following data structures. | 161 // Guards access to the following data structures. |
| 154 mutable base::Lock lock_; | 162 mutable base::Lock lock_; |
| 155 | 163 |
| 156 std::map<FilePath, bool> plugin_state_; | 164 std::map<FilePath, bool> plugin_state_; |
| 157 std::map<string16, bool> plugin_group_state_; | 165 std::map<string16, bool> plugin_group_state_; |
| 158 | 166 |
| 159 std::set<string16> policy_disabled_plugin_patterns_; | 167 std::set<string16> policy_disabled_plugin_patterns_; |
| 160 std::set<string16> policy_disabled_plugin_exception_patterns_; | 168 std::set<string16> policy_disabled_plugin_exception_patterns_; |
| 161 std::set<string16> policy_enabled_plugin_patterns_; | 169 std::set<string16> policy_enabled_plugin_patterns_; |
| 162 | 170 |
| 163 // Weak pointer, owns us. Only used as a notification source. | 171 // Weak pointer, owns us. Only used as a notification source. |
| 164 Profile* profile_; | 172 Profile* profile_; |
| 165 | 173 |
| 166 // Weak pointer, owned by the profile. | 174 // Weak pointer, owned by the profile. |
| 167 PrefService* prefs_; | 175 PrefService* prefs_; |
| 168 | 176 |
| 169 // PluginList to use for testing. If this is NULL, defaults to the global | 177 // PluginList to use for testing. If this is NULL, defaults to the global |
| 170 // singleton. | 178 // singleton. |
| 171 webkit::npapi::PluginList* plugin_list_; | 179 webkit::npapi::PluginList* plugin_list_; |
| 172 | 180 |
| 173 PrefChangeRegistrar registrar_; | 181 PrefChangeRegistrar registrar_; |
| 174 | 182 |
| 175 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); | 183 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); |
| 176 }; | 184 }; |
| 177 | 185 |
| 178 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_ | 186 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_ |
| OLD | NEW |