Skip to content

Commit

Permalink
Fix bug with enabling/disabling the pdf plugin, related to plugin gro…
Browse files Browse the repository at this point in the history
…uping work.

BUG=58329
Review URL: http://codereview.chromium.org/3618015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61864 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jam@chromium.org committed Oct 7, 2010
1 parent 6a75795 commit cceaf85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions chrome/browser/plugin_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pepper_plugin_registry.h"
#include "chrome/common/pref_names.h"
#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/plugin_list.h"
Expand Down Expand Up @@ -138,7 +140,7 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) {

bool found_internal_pdf = false;
bool force_enable_internal_pdf = false;
string16 pdf_group_name;
string16 pdf_group_name = ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName);
FilePath pdf_path;
PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
FilePath::StringType pdf_path_str = pdf_path.value();
Expand Down Expand Up @@ -184,7 +186,6 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) {

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);
Expand Down Expand Up @@ -215,6 +216,7 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) {
// 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()->EnableGroup(false, pdf_group_name);
}

if (update_preferences)
Expand Down
14 changes: 10 additions & 4 deletions chrome/common/pepper_plugin_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#include "chrome/common/chrome_switches.h"
#include "remoting/client/plugin/pepper_entrypoints.h"

const char* PepperPluginRegistry::kPDFPluginName = "Chrome PDF Viewer";
const char* PepperPluginRegistry::kPDFPluginMimeType = "application/pdf";
const char* PepperPluginRegistry::kPDFPluginExtension = "pdf";
const char* PepperPluginRegistry::kPDFPluginDescription =
"Portable Document Format";

PepperPluginInfo::PepperPluginInfo() : is_internal(false) {
}

Expand Down Expand Up @@ -115,10 +121,10 @@ void PepperPluginRegistry::GetExtraPlugins(
if (skip_pdf_file_check || file_util::PathExists(path)) {
PepperPluginInfo pdf;
pdf.path = path;
pdf.name = "Chrome PDF Viewer";
pdf.mime_types.push_back("application/pdf");
pdf.file_extensions = "pdf";
pdf.type_descriptions = "Portable Document Format";
pdf.name = kPDFPluginName;
pdf.mime_types.push_back(kPDFPluginMimeType);
pdf.file_extensions = kPDFPluginExtension;
pdf.type_descriptions = kPDFPluginDescription;
plugins->push_back(pdf);

skip_pdf_file_check = true;
Expand Down
5 changes: 5 additions & 0 deletions chrome/common/pepper_plugin_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ struct PepperPluginInfo {
// This class holds references to all of the known pepper plugin modules.
class PepperPluginRegistry {
public:
static const char* kPDFPluginName;
static const char* kPDFPluginMimeType;
static const char* kPDFPluginExtension;
static const char* kPDFPluginDescription;

static PepperPluginRegistry* GetInstance();

// Returns the list of known pepper plugins. This method is static so that
Expand Down

0 comments on commit cceaf85

Please sign in to comment.