| 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/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/prefs/public/pref_change_registrar.h" | 14 #include "base/prefs/public/pref_change_registrar.h" |
| 15 #include "base/prefs/public/pref_observer.h" |
| 15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 16 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" | 19 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
| 19 #include "content/public/browser/notification_observer.h" | |
| 20 | 20 |
| 21 class Profile; | 21 class Profile; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class ListValue; | 24 class ListValue; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace webkit { | 27 namespace webkit { |
| 28 struct WebPluginInfo; | 28 struct WebPluginInfo; |
| 29 namespace npapi { | 29 namespace npapi { |
| 30 class PluginList; | 30 class PluginList; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 // This class stores information about whether a plug-in or a plug-in group is | 34 // This class stores information about whether a plug-in or a plug-in group is |
| 35 // enabled or disabled. | 35 // enabled or disabled. |
| 36 // Except where otherwise noted, it can be used on every thread. | 36 // Except where otherwise noted, it can be used on every thread. |
| 37 class PluginPrefs : public RefcountedProfileKeyedService, | 37 class PluginPrefs : public RefcountedProfileKeyedService, |
| 38 public content::NotificationObserver { | 38 public PrefObserver { |
| 39 public: | 39 public: |
| 40 enum PolicyStatus { | 40 enum PolicyStatus { |
| 41 NO_POLICY = 0, // Neither enabled or disabled by policy. | 41 NO_POLICY = 0, // Neither enabled or disabled by policy. |
| 42 POLICY_ENABLED, | 42 POLICY_ENABLED, |
| 43 POLICY_DISABLED, | 43 POLICY_DISABLED, |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Returns the instance associated with |profile|, creating it if necessary. | 46 // Returns the instance associated with |profile|, creating it if necessary. |
| 47 static scoped_refptr<PluginPrefs> GetForProfile(Profile* profile); | 47 static scoped_refptr<PluginPrefs> GetForProfile(Profile* profile); |
| 48 | 48 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 PolicyStatus PolicyStatusForPlugin(const string16& name) const; | 78 PolicyStatus PolicyStatusForPlugin(const string16& name) const; |
| 79 | 79 |
| 80 // Returns whether the plugin is enabled or not. | 80 // Returns whether the plugin is enabled or not. |
| 81 bool IsPluginEnabled(const webkit::WebPluginInfo& plugin) const; | 81 bool IsPluginEnabled(const webkit::WebPluginInfo& plugin) const; |
| 82 | 82 |
| 83 void set_profile(Profile* profile) { profile_ = profile; } | 83 void set_profile(Profile* profile) { profile_ = profile; } |
| 84 | 84 |
| 85 // RefCountedProfileKeyedBase method override. | 85 // RefCountedProfileKeyedBase method override. |
| 86 virtual void ShutdownOnUIThread() OVERRIDE; | 86 virtual void ShutdownOnUIThread() OVERRIDE; |
| 87 | 87 |
| 88 // content::NotificationObserver method override. | 88 // PrefObserver method override. |
| 89 virtual void Observe(int type, | 89 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 90 const content::NotificationSource& source, | 90 const std::string& pref_name) OVERRIDE; |
| 91 const content::NotificationDetails& details) OVERRIDE; | |
| 92 | 91 |
| 93 private: | 92 private: |
| 94 friend class base::RefCountedThreadSafe<PluginPrefs>; | 93 friend class base::RefCountedThreadSafe<PluginPrefs>; |
| 95 friend class PluginPrefsTest; | 94 friend class PluginPrefsTest; |
| 96 | 95 |
| 97 // PluginState stores a mapping from plugin path to enable/disable state. We | 96 // PluginState stores a mapping from plugin path to enable/disable state. We |
| 98 // don't simply use a std::map, because we would like to keep the state of | 97 // don't simply use a std::map, because we would like to keep the state of |
| 99 // some plugins in sync with each other. | 98 // some plugins in sync with each other. |
| 100 class PluginState { | 99 class PluginState { |
| 101 public: | 100 public: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // PluginList to use for testing. If this is NULL, defaults to the global | 174 // PluginList to use for testing. If this is NULL, defaults to the global |
| 176 // singleton. | 175 // singleton. |
| 177 webkit::npapi::PluginList* plugin_list_; | 176 webkit::npapi::PluginList* plugin_list_; |
| 178 | 177 |
| 179 PrefChangeRegistrar registrar_; | 178 PrefChangeRegistrar registrar_; |
| 180 | 179 |
| 181 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); | 180 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); |
| 182 }; | 181 }; |
| 183 | 182 |
| 184 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ | 183 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_PREFS_H_ |
| OLD | NEW |