Skip to content

Commit

Permalink
Revert 101269 - Store plug-in enabled/disabled state in PluginPrefs i…
Browse files Browse the repository at this point in the history
…nstead of WebPluginInfo, to allow different sets of enabled/disabled plug-ins to be specified per profile.

BUG=80794
TEST=Open two profiles, disable different plugins in them.

Review URL: http://codereview.chromium.org/7848025

TBR=bauerb@chromium.org
Review URL: http://codereview.chromium.org/7901015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101272 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bauerb@chromium.org committed Sep 15, 2011
1 parent 682ef68 commit 3eff9e2
Show file tree
Hide file tree
Showing 30 changed files with 1,151 additions and 650 deletions.
14 changes: 10 additions & 4 deletions chrome/browser/automation/testing_automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3536,9 +3536,12 @@ void TestingAutomationProvider::EnablePlugin(Browser* browser,
if (!args->GetString("path", &path)) {
reply.SendError("path not specified.");
return;
} else if (!webkit::npapi::PluginList::Singleton()->EnablePlugin(
FilePath(path))) {
reply.SendError(StringPrintf("Could not enable plugin for path %s.",
path.c_str()));
return;
}
PluginPrefs::GetForProfile(browser->profile())->EnablePlugin(
true, FilePath(path));
reply.SendSuccess(NULL);
}

Expand All @@ -3553,9 +3556,12 @@ void TestingAutomationProvider::DisablePlugin(Browser* browser,
if (!args->GetString("path", &path)) {
reply.SendError("path not specified.");
return;
} else if (!webkit::npapi::PluginList::Singleton()->DisablePlugin(
FilePath(path))) {
reply.SendError(StringPrintf("Could not disable plugin for path %s.",
path.c_str()));
return;
}
PluginPrefs::GetForProfile(browser->profile())->EnablePlugin(
false, FilePath(path));
reply.SendSuccess(NULL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "base/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/common/chrome_paths.h"
#include "content/browser/browser_thread.h"
#include "content/common/pepper_plugin_registry.h"
Expand Down Expand Up @@ -108,6 +107,7 @@ bool SupportsPepperInterface(const char* interface_name) {
bool MakePepperFlashPluginInfo(const FilePath& flash_path,
const Version& flash_version,
bool out_of_process,
bool enabled,
PepperPluginInfo* plugin_info) {
if (!flash_version.IsValid())
return false;
Expand All @@ -119,6 +119,7 @@ bool MakePepperFlashPluginInfo(const FilePath& flash_path,
plugin_info->is_out_of_process = out_of_process;
plugin_info->path = flash_path;
plugin_info->name = kFlashPluginName;
plugin_info->enabled = enabled;

// The description is like "Shockwave Flash 10.2 r154".
plugin_info->description = StringPrintf("%s %d.%d r%d",
Expand All @@ -142,9 +143,8 @@ void RegisterPepperFlashWithChrome(const FilePath& path,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PepperPluginInfo plugin_info;
// Register it as out-of-process and disabled.
if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
if (!MakePepperFlashPluginInfo(path, version, true, false, &plugin_info))
return;
PluginPrefs::EnablePluginGlobally(false, plugin_info.path);
webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(
plugin_info.ToWebPluginInfo());
webkit::npapi::PluginList::Singleton()->RefreshPlugins();
Expand Down
21 changes: 10 additions & 11 deletions chrome/browser/pdf_unsupported_feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/chrome_plugin_service_filter.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/chrome_plugin_service_filter.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"
Expand Down Expand Up @@ -116,13 +116,14 @@ string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const {

void PDFEnableAdobeReaderInfoBarDelegate::OnYes() {
UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK"));
webkit::npapi::PluginList::Singleton()->EnableGroup(false,
ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName));
Profile* profile =
Profile::FromBrowserContext(tab_contents_->browser_context());
PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
plugin_prefs->EnablePluginGroup(
true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName));
plugin_prefs->EnablePluginGroup(
false, ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName));
plugin_prefs->UpdatePreferences(0);
}

void PDFEnableAdobeReaderInfoBarDelegate::OnNo() {
Expand All @@ -141,9 +142,11 @@ void OpenUsingReader(TabContentsWrapper* tab,
InfoBarDelegate* old_delegate,
InfoBarDelegate* new_delegate) {
WebPluginInfo plugin = reader_plugin;
// Give the plugin a new version so that the renderer doesn't show the blocked
// The plugin is disabled, so enable it to get around the renderer check.
// Also give it a new version so that the renderer doesn't show the blocked
// plugin UI if it's vulnerable, since we already went through the
// interstitial.
plugin.enabled = WebPluginInfo::USER_ENABLED;
plugin.version = ASCIIToUTF16("11.0.0.0");

ChromePluginServiceFilter::GetInstance()->OverridePluginForTab(
Expand Down Expand Up @@ -281,12 +284,11 @@ PDFUnsupportedFeatureInfoBarDelegate::PDFUnsupportedFeatureInfoBarDelegate(
}

UserMetrics::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarShown"));
const std::vector<WebPluginInfo>& plugins =
reader_group->web_plugin_infos();
std::vector<WebPluginInfo> plugins = reader_group->web_plugin_infos();
DCHECK_EQ(plugins.size(), 1u);
reader_webplugininfo_ = plugins[0];

reader_vulnerable_ = reader_group->IsVulnerable(reader_webplugininfo_);
reader_vulnerable_ = reader_group->IsVulnerable();
if (!reader_vulnerable_) {
scoped_ptr<Version> version(PluginGroup::CreateVersionFromString(
reader_webplugininfo_.version));
Expand Down Expand Up @@ -380,11 +382,8 @@ void PDFHasUnsupportedFeature(TabContentsWrapper* tab) {
string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName));

// If the Reader plugin is disabled by policy, don't prompt them.
PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile());
if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) ==
PluginPrefs::POLICY_DISABLED) {
if (PluginGroup::IsPluginNameDisabledByPolicy(reader_group_name))
return;
}

PluginGroup* reader_group = NULL;
std::vector<PluginGroup> plugin_groups;
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/plugin_exceptions_table_model_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ class PluginExceptionsTableModelTest : public testing::Test {
webkit::WebPluginInfo foo_plugin;
foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
foo_plugin.name = ASCIIToUTF16("FooPlugin");
foo_plugin.enabled =
webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED;
scoped_ptr<webkit::npapi::PluginGroup> foo_group(
webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin));
plugins.push_back(*foo_group);

webkit::WebPluginInfo bar_plugin;
bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar"));
bar_plugin.name = ASCIIToUTF16("BarPlugin");
bar_plugin.enabled =
webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED;
scoped_ptr<webkit::npapi::PluginGroup> bar_group(
webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin));
plugins.push_back(*bar_group);
Expand Down
Loading

0 comments on commit 3eff9e2

Please sign in to comment.