| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PLUGIN_PREFS_H_ | |
| 6 #define CHROME_BROWSER_PLUGIN_PREFS_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <set> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/file_path.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 16 #include "content/common/notification_observer.h" | |
| 17 | |
| 18 class NotificationDetails; | |
| 19 class NotificationSource; | |
| 20 class Profile; | |
| 21 | |
| 22 namespace content { | |
| 23 class ResourceContext; | |
| 24 } | |
| 25 | |
| 26 namespace base { | |
| 27 class DictionaryValue; | |
| 28 class ListValue; | |
| 29 } | |
| 30 | |
| 31 namespace webkit { | |
| 32 namespace npapi { | |
| 33 class PluginGroup; | |
| 34 struct WebPluginInfo; | |
| 35 } | |
| 36 } | |
| 37 | |
| 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 { | |
| 44 public: | |
| 45 // Initializes the factory for this class for dependency tracking. | |
| 46 // This should be called before the first profile is created. | |
| 47 static void Initialize(); | |
| 48 | |
| 49 static PluginPrefs* GetForProfile(Profile* profile); | |
| 50 | |
| 51 // Enable or disable a plugin group. | |
| 52 void EnablePluginGroup(bool enable, const string16& group_name); | |
| 53 | |
| 54 // Enable or disable a specific plugin file. | |
| 55 void EnablePlugin(bool enable, const FilePath& file_path); | |
| 56 | |
| 57 // Returns whether the plugin is enabled or not. | |
| 58 bool IsPluginEnabled(const webkit::npapi::WebPluginInfo& plugin); | |
| 59 | |
| 60 // Write the enable/disable status to the user's preference file. | |
| 61 void UpdatePreferences(int delay_ms); | |
| 62 | |
| 63 // NotificationObserver method overrides | |
| 64 virtual void Observe(int type, | |
| 65 const NotificationSource& source, | |
| 66 const NotificationDetails& details); | |
| 67 | |
| 68 static void RegisterPrefs(PrefService* prefs); | |
| 69 | |
| 70 void ShutdownOnUIThread(); | |
| 71 | |
| 72 private: | |
| 73 friend class base::RefCountedThreadSafe<PluginPrefs>; | |
| 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); | |
| 83 | |
| 84 // Called on the file thread to get the data necessary to update the saved | |
| 85 // preferences. | |
| 86 void GetPreferencesDataOnFileThread(); | |
| 87 | |
| 88 // Called on the UI thread with the plugin data to save the preferences. | |
| 89 void OnUpdatePreferences(std::vector<webkit::npapi::WebPluginInfo> plugins, | |
| 90 std::vector<webkit::npapi::PluginGroup> groups); | |
| 91 | |
| 92 // Queues sending the notification that plugin data has changed. This is done | |
| 93 // so that if a bunch of changes happen, we only send one notification. | |
| 94 void NotifyPluginStatusChanged(); | |
| 95 | |
| 96 // Used for the post task to notify that plugin enabled status changed. | |
| 97 void OnNotifyPluginStatusChanged(); | |
| 98 | |
| 99 base::DictionaryValue* CreatePluginFileSummary( | |
| 100 const webkit::npapi::WebPluginInfo& plugin); | |
| 101 | |
| 102 // Force plugins to be enabled or disabled due to policy. | |
| 103 // |disabled_list| contains the list of StringValues of the names of the | |
| 104 // policy-disabled plugins, |exceptions_list| the policy-allowed plugins, | |
| 105 // and |enabled_list| the policy-enabled plugins. | |
| 106 void UpdatePluginsStateFromPolicy(const base::ListValue* disabled_list, | |
| 107 const base::ListValue* exceptions_list, | |
| 108 const base::ListValue* enabled_list); | |
| 109 | |
| 110 void ListValueToStringSet(const base::ListValue* src, | |
| 111 std::set<string16>* dest); | |
| 112 | |
| 113 // Weak pointer, owned by the profile. | |
| 114 PrefService* prefs_; | |
| 115 | |
| 116 PrefChangeRegistrar registrar_; | |
| 117 | |
| 118 bool notify_pending_; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); | |
| 121 }; | |
| 122 | |
| 123 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_ | |
| OLD | NEW |