Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / plugin_updater.h
blob0d1c8568f0e1fa2e65d673788559aaead8c7d259
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.
5 #ifndef CHROME_BROWSER_PLUGIN_UPDATER_H_
6 #define CHROME_BROWSER_PLUGIN_UPDATER_H_
7 #pragma once
9 #include <set>
10 #include <vector>
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"
18 class DictionaryValue;
19 class ListValue;
20 class NotificationDetails;
21 class NotificationSource;
22 class Profile;
24 namespace webkit {
25 namespace npapi {
26 class PluginGroup;
27 struct WebPluginInfo;
31 class PluginUpdater : public NotificationObserver {
32 public:
33 // Get a list of all the plugin groups. The caller should take ownership
34 // of the returned ListValue.
35 static ListValue* GetPluginGroupsData();
37 // Enable or disable a plugin group.
38 void EnablePluginGroup(bool enable, const string16& group_name);
40 // Enable or disable a specific plugin file.
41 void EnablePlugin(bool enable, const FilePath::StringType& file_path);
43 // Associates the PluginUpdater with |profile|. This enables or disables
44 // plugin groups as defined by the user's preferences.
45 void SetProfile(Profile* profile);
47 // Called at shutdown before the profile is destroyed.
48 void Shutdown();
50 // Write the enable/disable status to the user's preference file.
51 void UpdatePreferences(Profile* profile, int delay_ms);
53 // NotificationObserver method overrides
54 virtual void Observe(NotificationType type,
55 const NotificationSource& source,
56 const NotificationDetails& details);
58 static PluginUpdater* GetInstance();
60 static void RegisterPrefs(PrefService* prefs);
62 private:
63 PluginUpdater();
64 virtual ~PluginUpdater() {}
66 // Called on the file thread to get the data necessary to update the saved
67 // preferences. The profile pointer is only to be passed to the UI thread.
68 static void GetPreferencesDataOnFileThread(void* profile);
70 // Called on the UI thread with the plugin data to save the preferences.
71 static void OnUpdatePreferences(
72 Profile* profile,
73 const std::vector<webkit::npapi::WebPluginInfo>& plugins,
74 const std::vector<webkit::npapi::PluginGroup>& groups);
76 // Queues sending the notification that plugin data has changed. This is done
77 // so that if a bunch of changes happen, we only send one notification.
78 void NotifyPluginStatusChanged();
80 // Used for the post task to notify that plugin enabled status changed.
81 static void OnNotifyPluginStatusChanged();
83 static DictionaryValue* CreatePluginFileSummary(
84 const webkit::npapi::WebPluginInfo& plugin);
86 // Force plugins to be enabled or disabled due to policy.
87 // |disabled_list| contains the list of StringValues of the names of the
88 // policy-disabled plugins, |exceptions_list| the policy-allowed plugins,
89 // and |enabled_list| the policy-enabled plugins.
90 void UpdatePluginsStateFromPolicy(const ListValue* disabled_list,
91 const ListValue* exceptions_list,
92 const ListValue* enabled_list);
94 void ListValueToStringSet(const ListValue* src, std::set<string16>* dest);
96 // Needed to allow singleton instantiation using private constructor.
97 friend struct DefaultSingletonTraits<PluginUpdater>;
99 PrefChangeRegistrar registrar_;
101 bool notify_pending_;
103 DISALLOW_COPY_AND_ASSIGN(PluginUpdater);
106 #endif // CHROME_BROWSER_PLUGIN_UPDATER_H_