Commit 53b5a520 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED

Two consumers:
- PluginStatusPrefSetter - was unused, so it's deleted.
- ChromePluginServiceFilter - the action taken when receiving the
  notification can be moved to the notification's source, i.e.
  PluginPrefs.

Note that the enable status can only change for the pdf viewer plugin,
so it wasn't a very aptly-named notification (at this point in history).

Bug: 268984
Change-Id: I1aebd7d90f8e70c3031d7e7911bb1388c8e88c8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1671849Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Auto-Submit: Evan Stade <estade@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671914}
parent 3de8ec1c
...@@ -4677,8 +4677,6 @@ jumbo_split_static_library("browser") { ...@@ -4677,8 +4677,6 @@ jumbo_split_static_library("browser") {
"plugins/plugin_prefs_factory.h", "plugins/plugin_prefs_factory.h",
"plugins/plugin_response_interceptor_url_loader_throttle.cc", "plugins/plugin_response_interceptor_url_loader_throttle.cc",
"plugins/plugin_response_interceptor_url_loader_throttle.h", "plugins/plugin_response_interceptor_url_loader_throttle.h",
"plugins/plugin_status_pref_setter.cc",
"plugins/plugin_status_pref_setter.h",
"plugins/plugin_utils.cc", "plugins/plugin_utils.cc",
"plugins/plugin_utils.h", "plugins/plugin_utils.h",
"plugins/plugins_resource_service.cc", "plugins/plugins_resource_service.cc",
......
...@@ -332,10 +332,6 @@ enum NotificationType { ...@@ -332,10 +332,6 @@ enum NotificationType {
// The source is the browser's FullscreenController, no details. // The source is the browser's FullscreenController, no details.
NOTIFICATION_MOUSE_LOCK_CHANGED, NOTIFICATION_MOUSE_LOCK_CHANGED,
// Sent by the PluginPrefs when there is a change of plugin enable/disable
// status. The source is the profile.
NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
// Sent when a global error has changed and the error UI should update it // Sent when a global error has changed and the error UI should update it
// self. The source is a Source<Profile> containing the profile for the // self. The source is a Source<Profile> containing the profile for the
// error. The detail is a GlobalError object that has changed or NULL if // error. The detail is a GlobalError object that has changed or NULL if
......
...@@ -8,18 +8,17 @@ ...@@ -8,18 +8,17 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/plugins/flash_temporary_permission_tracker.h" #include "chrome/browser/plugins/flash_temporary_permission_tracker.h"
#include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/plugins/plugin_metadata.h"
#include "chrome/browser/plugins/plugin_utils.h" #include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
...@@ -249,8 +248,6 @@ ChromePluginServiceFilter::ChromePluginServiceFilter() { ...@@ -249,8 +248,6 @@ ChromePluginServiceFilter::ChromePluginServiceFilter() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
content::NotificationService::AllSources());
} }
ChromePluginServiceFilter::~ChromePluginServiceFilter() {} ChromePluginServiceFilter::~ChromePluginServiceFilter() {}
...@@ -260,28 +257,12 @@ void ChromePluginServiceFilter::Observe( ...@@ -260,28 +257,12 @@ void ChromePluginServiceFilter::Observe(
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
switch (type) { DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CLOSED, type);
case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { int render_process_id =
int render_process_id = content::Source<content::RenderProcessHost>(source).ptr()->GetID();
content::Source<content::RenderProcessHost>(source).ptr()->GetID();
base::AutoLock auto_lock(lock_);
base::AutoLock auto_lock(lock_); plugin_details_.erase(render_process_id);
plugin_details_.erase(render_process_id);
break;
}
case chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: {
Profile* profile = content::Source<Profile>(source).ptr();
PluginService::GetInstance()->PurgePluginListCache(profile, false);
if (profile && profile->HasOffTheRecordProfile()) {
PluginService::GetInstance()->PurgePluginListCache(
profile->GetOffTheRecordProfile(), false);
}
break;
}
default: {
NOTREACHED();
}
}
} }
ChromePluginServiceFilter::ProcessDetails* ChromePluginServiceFilter::ProcessDetails*
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/plugins/plugin_metadata.h"
#include "chrome/browser/plugins/plugin_prefs_factory.h" #include "chrome/browser/plugins/plugin_prefs_factory.h"
...@@ -29,8 +28,6 @@ ...@@ -29,8 +28,6 @@
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service.h"
#include "content/public/common/webplugininfo.h" #include "content/public/common/webplugininfo.h"
...@@ -65,7 +62,6 @@ scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile( ...@@ -65,7 +62,6 @@ scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile(
PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin( PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin(
const base::string16& name) const { const base::string16& name) const {
base::AutoLock auto_lock(lock_);
// Special handling for PDF based on its specific policy. // Special handling for PDF based on its specific policy.
if (IsPDFViewerPlugin(name) && always_open_pdf_externally_) if (IsPDFViewerPlugin(name) && always_open_pdf_externally_)
...@@ -94,11 +90,14 @@ bool PluginPrefs::IsPluginEnabled(const content::WebPluginInfo& plugin) const { ...@@ -94,11 +90,14 @@ bool PluginPrefs::IsPluginEnabled(const content::WebPluginInfo& plugin) const {
} }
void PluginPrefs::UpdatePdfPolicy(const std::string& pref_name) { void PluginPrefs::UpdatePdfPolicy(const std::string& pref_name) {
base::AutoLock auto_lock(lock_);
always_open_pdf_externally_ = always_open_pdf_externally_ =
prefs_->GetBoolean(prefs::kPluginsAlwaysOpenPdfExternally); prefs_->GetBoolean(prefs::kPluginsAlwaysOpenPdfExternally);
NotifyPluginStatusChanged(); content::PluginService::GetInstance()->PurgePluginListCache(profile_, false);
if (profile_->HasOffTheRecordProfile()) {
content::PluginService::GetInstance()->PurgePluginListCache(
profile_->GetOffTheRecordProfile(), false);
}
} }
void PluginPrefs::SetPrefs(PrefService* prefs) { void PluginPrefs::SetPrefs(PrefService* prefs) {
...@@ -175,44 +174,22 @@ void PluginPrefs::SetPrefs(PrefService* prefs) { ...@@ -175,44 +174,22 @@ void PluginPrefs::SetPrefs(PrefService* prefs) {
} }
} // Scoped update of prefs::kPluginsPluginsList. } // Scoped update of prefs::kPluginsPluginsList.
always_open_pdf_externally_ = UpdatePdfPolicy(prefs::kPluginsAlwaysOpenPdfExternally);
prefs_->GetBoolean(prefs::kPluginsAlwaysOpenPdfExternally);
registrar_.Init(prefs_); registrar_.Init(prefs_);
// Because pointers to our own members will remain unchanged for the
// lifetime of |registrar_| (which we also own), we can bind their
// pointer values directly in the callbacks to avoid string-based
// lookups at notification time.
registrar_.Add(prefs::kPluginsAlwaysOpenPdfExternally, registrar_.Add(prefs::kPluginsAlwaysOpenPdfExternally,
base::Bind(&PluginPrefs::UpdatePdfPolicy, base::Bind(&PluginPrefs::UpdatePdfPolicy,
base::Unretained(this))); base::Unretained(this)));
NotifyPluginStatusChanged();
} }
void PluginPrefs::ShutdownOnUIThread() { void PluginPrefs::ShutdownOnUIThread() {
prefs_ = NULL; prefs_ = nullptr;
registrar_.RemoveAll(); registrar_.RemoveAll();
} }
PluginPrefs::PluginPrefs() : always_open_pdf_externally_(false), PluginPrefs::PluginPrefs() = default;
profile_(NULL), PluginPrefs::~PluginPrefs() = default;
prefs_(NULL) {
}
PluginPrefs::~PluginPrefs() {
}
void PluginPrefs::SetAlwaysOpenPdfExternallyForTests( void PluginPrefs::SetAlwaysOpenPdfExternallyForTests(
bool always_open_pdf_externally) { bool always_open_pdf_externally) {
always_open_pdf_externally_ = always_open_pdf_externally; always_open_pdf_externally_ = always_open_pdf_externally;
} }
void PluginPrefs::NotifyPluginStatusChanged() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
content::Source<Profile>(profile_),
content::NotificationService::NoDetails());
}
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "components/keyed_service/core/refcounted_keyed_service.h" #include "components/keyed_service/core/refcounted_keyed_service.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -74,19 +73,12 @@ class PluginPrefs : public RefcountedKeyedService { ...@@ -74,19 +73,12 @@ class PluginPrefs : public RefcountedKeyedService {
// Allows unit tests to directly set the AlwaysOpenPdfExternally pref. // Allows unit tests to directly set the AlwaysOpenPdfExternally pref.
void SetAlwaysOpenPdfExternallyForTests(bool always_open_pdf_externally); void SetAlwaysOpenPdfExternallyForTests(bool always_open_pdf_externally);
// Sends the notification that plugin data has changed. bool always_open_pdf_externally_ = false;
void NotifyPluginStatusChanged();
// Guards access to the following data structures. Profile* profile_ = nullptr;
mutable base::Lock lock_;
bool always_open_pdf_externally_;
// Weak pointer, owns us. Only used as a notification source.
Profile* profile_;
// Weak pointer, owned by the profile. // Weak pointer, owned by the profile.
PrefService* prefs_; PrefService* prefs_ = nullptr;
PrefChangeRegistrar registrar_; PrefChangeRegistrar registrar_;
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/plugins/plugin_status_pref_setter.h"
#include "base/bind.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/pepper_flash_settings_manager.h"
#include "chrome/browser/plugins/plugin_data_remover_helper.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/webplugininfo.h"
using content::BrowserThread;
using content::PluginService;
PluginStatusPrefSetter::PluginStatusPrefSetter()
: profile_(NULL),
factory_(this) {}
PluginStatusPrefSetter::~PluginStatusPrefSetter() {
}
void PluginStatusPrefSetter::Init(
Profile* profile,
const BooleanPrefMember::NamedChangeCallback& observer) {
clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
profile->GetPrefs(), observer);
pepper_flash_settings_enabled_.Init(prefs::kPepperFlashSettingsEnabled,
profile->GetPrefs(), observer);
profile_ = profile;
registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
content::Source<Profile>(profile));
StartUpdate();
}
void PluginStatusPrefSetter::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, type);
StartUpdate();
}
void PluginStatusPrefSetter::StartUpdate() {
PluginService::GetInstance()->GetPlugins(
base::BindOnce(&PluginStatusPrefSetter::GotPlugins, factory_.GetWeakPtr(),
PluginPrefs::GetForProfile(profile_)));
}
void PluginStatusPrefSetter::GotPlugins(
scoped_refptr<PluginPrefs> plugin_prefs,
const std::vector<content::WebPluginInfo>& plugins) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Set the values on the PrefService instead of through the PrefMembers to
// notify observers if they changed.
profile_->GetPrefs()->SetBoolean(
clear_plugin_lso_data_enabled_.GetPrefName().c_str(),
PluginDataRemoverHelper::IsSupported(plugin_prefs.get()));
profile_->GetPrefs()->SetBoolean(
pepper_flash_settings_enabled_.GetPrefName().c_str(),
PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs.get(), NULL));
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PLUGINS_PLUGIN_STATUS_PREF_SETTER_H_
#define CHROME_BROWSER_PLUGINS_PLUGIN_STATUS_PREF_SETTER_H_
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class PluginPrefs;
class PrefService;
class Profile;
namespace content {
struct WebPluginInfo;
}
// Helper class modeled after BooleanPrefMember to (asynchronously) update
// preferences related to plugin enable status.
// It should only be used from the UI thread. The client has to make sure that
// the passed profile outlives this object.
class PluginStatusPrefSetter : public content::NotificationObserver {
public:
PluginStatusPrefSetter();
~PluginStatusPrefSetter() override;
// Binds the preferences in the profile's PrefService, notifying |observer| if
// any value changes.
// This asynchronously calls the PluginService to get the list of installed
// plugins.
void Init(Profile* profile,
const BooleanPrefMember::NamedChangeCallback& observer);
bool IsClearPluginLSODataEnabled() const {
return clear_plugin_lso_data_enabled_.GetValue();
}
bool IsPepperFlashSettingsEnabled() const {
return pepper_flash_settings_enabled_.GetValue();
}
// content::NotificationObserver methods:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
private:
void StartUpdate();
void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs,
const std::vector<content::WebPluginInfo>& plugins);
content::NotificationRegistrar registrar_;
// Weak pointer.
Profile* profile_;
// Whether clearing LSO data is supported.
BooleanPrefMember clear_plugin_lso_data_enabled_;
// Whether we should show Pepper Flash-specific settings.
BooleanPrefMember pepper_flash_settings_enabled_;
base::WeakPtrFactory<PluginStatusPrefSetter> factory_;
DISALLOW_COPY_AND_ASSIGN(PluginStatusPrefSetter);
};
#endif // CHROME_BROWSER_PLUGINS_PLUGIN_STATUS_PREF_SETTER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment