Index: chrome/browser/plugin_updater.cc |
diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc |
index 63e5bb6e31b6b05de55a7db3fc463474ce73f030..923fdc9dc12e1fb1cf6c7feb6d55ab45b9b469d3 100644 |
--- a/chrome/browser/plugin_updater.cc |
+++ b/chrome/browser/plugin_updater.cc |
@@ -66,10 +66,13 @@ void PluginUpdater::EnablePluginGroup(bool enable, const string16& group_name) { |
void PluginUpdater::EnablePluginFile(bool enable, |
const FilePath::StringType& path) { |
FilePath file_path(path); |
- if (enable && !PluginGroup::IsPluginPathDisabledByPolicy(file_path)) |
+ bool disabled_by_policy = |
+ PluginGroup::IsPluginPathDisabledByPolicy(file_path); |
+ if (enable && !disabled_by_policy) |
NPAPI::PluginList::Singleton()->EnablePlugin(file_path); |
else |
- NPAPI::PluginList::Singleton()->DisablePlugin(file_path); |
+ NPAPI::PluginList::Singleton()->DisablePlugin(file_path, |
+ disabled_by_policy); |
NotifyPluginStatusChanged(); |
} |
@@ -190,7 +193,7 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) { |
} |
} |
if (!enabled) |
- NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); |
+ NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path, false); |
} else if (!enabled && plugin->GetString("name", &group_name)) { |
// Don't disable this group if it's for the pdf plugin and we just |
// forced it on. |
@@ -213,7 +216,7 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) { |
!force_internal_pdf_for_this_run) { |
// The internal PDF plugin is disabled by default, and the user hasn't |
// overridden the default. |
- NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); |
+ NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path, false); |
EnablePluginGroup(false, pdf_group_name); |
} |
@@ -239,22 +242,30 @@ void PluginUpdater::UpdatePreferences(Profile* profile, int delay_ms) { |
void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) { |
std::vector<WebPluginInfo> plugins; |
NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
+ NPAPI::PluginList::DisabledPluginsList disabled_plugins; |
+ NPAPI::PluginList::Singleton()->GetDisabledPlugins(&disabled_plugins); |
std::vector<PluginGroup> groups; |
NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups); |
+ NPAPI::PluginList::DisabledGroupsList disabled_groups; |
+ NPAPI::PluginList::Singleton()->GetDisabledGroups(&disabled_groups); |
BrowserThread::PostTask( |
BrowserThread::UI, |
FROM_HERE, |
NewRunnableFunction( |
&PluginUpdater::OnUpdatePreferences, |
- static_cast<Profile*>(profile), plugins, groups)); |
+ static_cast<Profile*>(profile), |
+ plugins, groups, |
+ disabled_plugins, disabled_groups)); |
} |
void PluginUpdater::OnUpdatePreferences( |
Profile* profile, |
const std::vector<WebPluginInfo>& plugins, |
- const std::vector<PluginGroup>& groups) { |
+ const std::vector<PluginGroup>& groups, |
+ const NPAPI::PluginList::DisabledPluginsList& disabled_plugins, |
+ const NPAPI::PluginList::DisabledGroupsList& disabled_groups) { |
ListValue* plugins_list = profile->GetPrefs()->GetMutableList( |
prefs::kPluginsPluginsList); |
plugins_list->Clear(); |
@@ -268,16 +279,34 @@ void PluginUpdater::OnUpdatePreferences( |
for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); |
it != plugins.end(); |
++it) { |
- plugins_list->Append(CreatePluginFileSummary(*it)); |
+ DictionaryValue* summary = CreatePluginFileSummary(*it); |
+ NPAPI::PluginList::DisabledPluginsList::const_iterator entry = |
+ disabled_plugins.find(it->path); |
+ // If the plugin is disabled only by policy don't store this state in the |
+ // user pref store. |
+ if (entry != disabled_plugins.end() && |
+ entry->second == NPAPI::PluginList::POLICY) |
danno
2010/12/14 09:43:39
Add methods to check this so the code looks more l
pastarmovj
2010/12/15 14:44:51
This doesn't seem to me to bring any more strucure
|
+ summary->SetBoolean("enabled", true); |
+ plugins_list->Append(summary); |
} |
// Add the groups as well. |
- for (size_t i = 0; i < groups.size(); ++i) { |
+ for (std::vector<PluginGroup>::const_iterator it = groups.begin(); |
+ it != groups.end(); |
+ ++it) { |
// Don't save preferences for vulnerable pugins. |
if (!CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kDisableOutdatedPlugins) || |
- !groups[i].IsVulnerable()) { |
- plugins_list->Append(groups[i].GetSummary()); |
+ !it->IsVulnerable()) { |
danno
2010/12/14 09:43:39
Might make code more readable to switch order of t
pastarmovj
2010/12/15 14:44:51
Done.
|
+ DictionaryValue* summary = it->GetSummary(); |
+ NPAPI::PluginList::DisabledGroupsList::const_iterator entry = |
+ disabled_groups.find(it->GetGroupName()); |
+ // If the plugin is disabled only by policy don't store this state in the |
+ // user pref store. |
+ if (entry != disabled_groups.end() && |
+ entry->second == NPAPI::PluginList::POLICY) |
+ summary->SetBoolean("enabled", true); |
+ plugins_list->Append(summary); |
} |
} |
} |