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

Unified Diff: chrome/browser/plugins/chrome_plugin_service_filter.cc

Issue 2285553002: [HBD] Gate the advertising of Flash on Site Engagement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tidying Created 4 years, 3 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
Index: chrome/browser/plugins/chrome_plugin_service_filter.cc
diff --git a/chrome/browser/plugins/chrome_plugin_service_filter.cc b/chrome/browser/plugins/chrome_plugin_service_filter.cc
index 1c1f506d3ac1bd7d7e5a1bfbc36661e8a2a02d2d..949851a00110060749c1caf1556ae17a1ea43444 100644
--- a/chrome/browser/plugins/chrome_plugin_service_filter.cc
+++ b/chrome/browser/plugins/chrome_plugin_service_filter.cc
@@ -7,37 +7,28 @@
#include <utility>
#include "base/bind.h"
-#include "base/logging.h"
-#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
-#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
-#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/plugins/plugin_filter_utils.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_metadata.h"
-#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/plugins/plugins_field_trial.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/render_messages.h"
#include "components/content_settings/content/common/content_settings_messages.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
-#include "components/infobars/core/confirm_infobar_delegate.h"
-#include "components/infobars/core/infobar.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_context.h"
-#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_constants.h"
-#include "ui/base/window_open_disposition.h"
+#include "url/gurl.h"
-using base::UserMetricsAction;
using content::BrowserThread;
using content::PluginService;
@@ -68,6 +59,8 @@ void AuthorizeRenderer(content::RenderFrameHost* render_frame_host) {
} // namespace
+// ChromePluginServiceFilter inner struct definitions.
+
struct ChromePluginServiceFilter::ContextInfo {
ContextInfo(
const scoped_refptr<PluginPrefs>& plugin_prefs,
@@ -99,6 +92,20 @@ ChromePluginServiceFilter::ContextInfo::~ContextInfo() {
host_content_settings_map->RemoveObserver(&observer);
}
+ChromePluginServiceFilter::OverriddenPlugin::OverriddenPlugin()
+ : render_frame_id(MSG_ROUTING_NONE) {}
+
+ChromePluginServiceFilter::OverriddenPlugin::~OverriddenPlugin() {}
+
+ChromePluginServiceFilter::ProcessDetails::ProcessDetails() {}
+
+ChromePluginServiceFilter::ProcessDetails::ProcessDetails(
+ const ProcessDetails& other) = default;
+
+ChromePluginServiceFilter::ProcessDetails::~ProcessDetails() {}
+
+// ChromePluginServiceFilter definitions.
+
// static
ChromePluginServiceFilter* ChromePluginServiceFilter::GetInstance() {
return base::Singleton<ChromePluginServiceFilter>::get();
@@ -109,8 +116,9 @@ void ChromePluginServiceFilter::RegisterResourceContext(Profile* profile,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::AutoLock lock(lock_);
resource_context_map_[context] = base::MakeUnique<ContextInfo>(
- PluginPrefs::GetForProfile(profile),
- HostContentSettingsMapFactory::GetForProfile(profile), profile);
+ GetPluginPrefsForProfile(profile),
+ HostContentSettingsMapFactory::GetForProfile(profile),
+ profile);
}
void ChromePluginServiceFilter::UnregisterResourceContext(
@@ -133,6 +141,26 @@ void ChromePluginServiceFilter::OverridePluginForFrame(
details->overridden_plugins.push_back(overridden_plugin);
}
+void ChromePluginServiceFilter::AuthorizePlugin(
+ int render_process_id,
+ const base::FilePath& plugin_path) {
+ base::AutoLock auto_lock(lock_);
+ ProcessDetails* details = GetOrRegisterProcess(render_process_id);
+ details->authorized_plugins.insert(plugin_path);
+}
+
+void ChromePluginServiceFilter::AuthorizeAllPlugins(
+ content::WebContents* web_contents,
+ bool load_blocked,
+ const std::string& identifier) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ web_contents->ForEachFrame(base::Bind(&AuthorizeRenderer));
+ if (load_blocked) {
+ web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins(
+ MSG_ROUTING_NONE, identifier));
+ }
+}
+
bool ChromePluginServiceFilter::IsPluginAvailable(
int render_process_id,
int render_frame_id,
@@ -164,12 +192,23 @@ bool ChromePluginServiceFilter::IsPluginAvailable(
if (context_info_it == resource_context_map_.end())
return false;
- if (!context_info_it->second->plugin_prefs.get()->IsPluginEnabled(*plugin))
+ const ContextInfo* context_info = context_info_it->second.get();
+ if (!context_info->plugin_prefs.get()->IsPluginEnabled(*plugin))
return false;
// Check whether PreferHtmlOverPlugins feature is enabled.
if (plugin->name == base::ASCIIToUTF16(content::kFlashPluginName) &&
base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) {
+
+ // Check whether the site meets the site engagement cutoff for making Flash
+ // available. This is impossible if |policy_url| is empty.
+ if (!policy_url.is_empty() &&
+ PluginsFieldTrial::HasSufficientEngagementForFlash(
+ context_info->host_content_settings_map.get(), policy_url)) {
+ return true;
+ }
+
+ // Otherwise, we check the content setting.
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
std::unique_ptr<PluginMetadata> plugin_metadata =
PluginFinder::GetInstance()->GetPluginMetadata(*plugin);
@@ -179,7 +218,7 @@ bool ChromePluginServiceFilter::IsPluginAvailable(
// Flash embed hosted on the same origin as the main frame origin is allowed
// to run.
GetPluginContentSetting(
- context_info_it->second->host_content_settings_map.get(), *plugin,
+ context_info->host_content_settings_map.get(), *plugin,
policy_url, url, plugin_metadata->identifier(), &plugin_setting,
nullptr, nullptr);
plugin_setting = PluginsFieldTrial::EffectiveContentSetting(
@@ -209,26 +248,6 @@ bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id,
ContainsKey(details->authorized_plugins, base::FilePath()));
}
-void ChromePluginServiceFilter::AuthorizePlugin(
- int render_process_id,
- const base::FilePath& plugin_path) {
- base::AutoLock auto_lock(lock_);
- ProcessDetails* details = GetOrRegisterProcess(render_process_id);
- details->authorized_plugins.insert(plugin_path);
-}
-
-void ChromePluginServiceFilter::AuthorizeAllPlugins(
- content::WebContents* web_contents,
- bool load_blocked,
- const std::string& identifier) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- web_contents->ForEachFrame(base::Bind(&AuthorizeRenderer));
- if (load_blocked) {
- web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins(
- MSG_ROUTING_NONE, identifier));
- }
-}
-
ChromePluginServiceFilter::ChromePluginServiceFilter() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
@@ -237,7 +256,11 @@ ChromePluginServiceFilter::ChromePluginServiceFilter() {
content::NotificationService::AllSources());
}
-ChromePluginServiceFilter::~ChromePluginServiceFilter() {
+ChromePluginServiceFilter::~ChromePluginServiceFilter() {}
+
+scoped_refptr<PluginPrefs> ChromePluginServiceFilter::GetPluginPrefsForProfile(
+ Profile* profile) {
+ return PluginPrefs::GetForProfile(profile);
}
void ChromePluginServiceFilter::Observe(
@@ -284,19 +307,3 @@ ChromePluginServiceFilter::GetProcess(
return NULL;
return &it->second;
}
-
-ChromePluginServiceFilter::OverriddenPlugin::OverriddenPlugin()
- : render_frame_id(MSG_ROUTING_NONE) {
-}
-
-ChromePluginServiceFilter::OverriddenPlugin::~OverriddenPlugin() {
-}
-
-ChromePluginServiceFilter::ProcessDetails::ProcessDetails() {
-}
-
-ChromePluginServiceFilter::ProcessDetails::ProcessDetails(
- const ProcessDetails& other) = default;
-
-ChromePluginServiceFilter::ProcessDetails::~ProcessDetails() {
-}

Powered by Google App Engine
This is Rietveld 408576698