Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3892)

Unified Diff: chrome/browser/plugin_updater.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Plugin reloading works completely now. Lint made happy as well. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/plugin_updater.cc
diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc
index 63e5bb6e31b6b05de55a7db3fc463474ce73f030..0597a116b87e9f1f00a10f8409e6f32ff70e3106 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::DisabledPlugins disabled_plugins =
+ NPAPI::PluginList::Singleton()->GetDisabledPlugins();
std::vector<PluginGroup> groups;
NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups);
+ NPAPI::PluginList::DisabledGroups disabled_groups =
+ NPAPI::PluginList::Singleton()->GetDisabledGroups();
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::DisabledPlugins& disabled_plugins,
+ const NPAPI::PluginList::DisabledGroups& 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::DisabledPlugins::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)
+ 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());
+ if (!it->IsVulnerable() ||
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableOutdatedPlugins)) {
+ DictionaryValue* summary = it->GetSummary();
+ NPAPI::PluginList::DisabledGroups::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);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698