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_UPDATER_H_ | |
6 #define CHROME_BROWSER_PLUGIN_UPDATER_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/singleton.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 base { | |
23 class DictionaryValue; | |
24 class ListValue; | |
25 } | |
26 | |
27 namespace webkit { | |
28 namespace npapi { | |
29 class PluginGroup; | |
30 struct WebPluginInfo; | |
31 } | |
32 } | |
33 | |
34 class PluginUpdater : public NotificationObserver { | |
35 public: | |
36 // Get a list of all the plugin groups. The caller should take ownership | |
37 // of the returned ListValue. | |
38 static base::ListValue* GetPluginGroupsData(); | |
39 | |
40 // Enable or disable a plugin group. | |
41 void EnablePluginGroup(bool enable, const string16& group_name); | |
42 | |
43 // Enable or disable a specific plugin file. | |
44 void EnablePlugin(bool enable, const FilePath::StringType& file_path); | |
45 | |
46 // Associates the PluginUpdater with |profile|. This enables or disables | |
47 // plugin groups as defined by the user's preferences. | |
48 void SetProfile(Profile* profile); | |
49 | |
50 // Called at shutdown before the profile is destroyed. | |
51 void Shutdown(); | |
52 | |
53 // Write the enable/disable status to the user's preference file. | |
54 void UpdatePreferences(Profile* profile, int delay_ms); | |
55 | |
56 // NotificationObserver method overrides | |
57 virtual void Observe(int type, | |
58 const NotificationSource& source, | |
59 const NotificationDetails& details); | |
60 | |
61 static PluginUpdater* GetInstance(); | |
62 | |
63 static void RegisterPrefs(PrefService* prefs); | |
64 | |
65 private: | |
66 PluginUpdater(); | |
67 virtual ~PluginUpdater() {} | |
68 | |
69 // Called on the file thread to get the data necessary to update the saved | |
70 // preferences. The profile pointer is only to be passed to the UI thread. | |
71 static void GetPreferencesDataOnFileThread(void* profile); | |
72 | |
73 // Called on the UI thread with the plugin data to save the preferences. | |
74 static void OnUpdatePreferences( | |
75 Profile* profile, | |
76 const std::vector<webkit::npapi::WebPluginInfo>& plugins, | |
77 const std::vector<webkit::npapi::PluginGroup>& groups); | |
78 | |
79 // Queues sending the notification that plugin data has changed. This is done | |
80 // so that if a bunch of changes happen, we only send one notification. | |
81 void NotifyPluginStatusChanged(); | |
82 | |
83 // Used for the post task to notify that plugin enabled status changed. | |
84 static void OnNotifyPluginStatusChanged(); | |
85 | |
86 static base::DictionaryValue* CreatePluginFileSummary( | |
87 const webkit::npapi::WebPluginInfo& plugin); | |
88 | |
89 // Force plugins to be enabled or disabled due to policy. | |
90 // |disabled_list| contains the list of StringValues of the names of the | |
91 // policy-disabled plugins, |exceptions_list| the policy-allowed plugins, | |
92 // and |enabled_list| the policy-enabled plugins. | |
93 void UpdatePluginsStateFromPolicy(const base::ListValue* disabled_list, | |
94 const base::ListValue* exceptions_list, | |
95 const base::ListValue* enabled_list); | |
96 | |
97 void ListValueToStringSet(const base::ListValue* src, | |
98 std::set<string16>* dest); | |
99 | |
100 // Needed to allow singleton instantiation using private constructor. | |
101 friend struct DefaultSingletonTraits<PluginUpdater>; | |
102 | |
103 PrefChangeRegistrar registrar_; | |
104 | |
105 bool notify_pending_; | |
106 | |
107 DISALLOW_COPY_AND_ASSIGN(PluginUpdater); | |
108 }; | |
109 | |
110 #endif // CHROME_BROWSER_PLUGIN_UPDATER_H_ | |
OLD | NEW |