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

Unified Diff: chrome/browser/plugin_updater.cc

Issue 3238015: Fix two bugs for setting the pdf plugin on by default:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/plugin_updater.cc
===================================================================
--- chrome/browser/plugin_updater.cc (revision 57889)
+++ chrome/browser/plugin_updater.cc (working copy)
@@ -91,10 +91,13 @@
NPAPI::PluginList::Singleton()->DisablePlugin(file_path);
}
+// Note: if you change this to false from true, you must update
+// kPluginsEnabledInternalPDF to be a new name (i.e. add 2, 3, 4...) at end.
static bool enable_internal_pdf_ = true;
void DisablePluginGroupsFromPrefs(Profile* profile) {
bool update_internal_dir = false;
+ bool update_preferences = false;
FilePath last_internal_dir =
profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory);
FilePath cur_internal_dir;
@@ -105,8 +108,17 @@
prefs::kPluginsLastInternalDirectory, cur_internal_dir);
}
+ if (!enable_internal_pdf_) {
+ // This DCHECK guards against us disabling/enabling the pdf plugin more than
+ // once without renaming the flag that tells us whether we can enable it
+ // automatically. Each time we disable the plugin by default after it was
+ // enabled by default, we need to rename that flag.
+ DCHECK(!profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF));
+ }
+
bool found_internal_pdf = false;
bool force_enable_internal_pdf = false;
+ string16 pdf_group_name;
FilePath pdf_path;
PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
FilePath::StringType pdf_path_str = pdf_path.value();
@@ -152,14 +164,21 @@
if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) {
found_internal_pdf = true;
+ plugin->GetString("name", &pdf_group_name);
if (!enabled && force_enable_internal_pdf) {
enabled = true;
plugin->SetBoolean("enabled", true);
+ update_preferences = true; // Can't modify the list during looping.
}
}
if (!enabled)
NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path);
} 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.
+ if (force_enable_internal_pdf && pdf_group_name == group_name)
+ continue;
+
// Otherwise this is a list of groups.
EnablePluginGroup(false, group_name);
}
@@ -207,6 +226,9 @@
// overridden the default.
NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path);
}
+
+ if (update_preferences)
+ UpdatePreferences(profile);
}
void DisableOutdatedPluginGroups() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698