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

Unified Diff: chrome/browser/plugins/plugins_field_trial.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/plugins_field_trial.cc
diff --git a/chrome/browser/plugins/plugins_field_trial.cc b/chrome/browser/plugins/plugins_field_trial.cc
index 68d3d957432c554b800687e63d6a6b089bdb82cd..3dc9e27f50248d2c5c2221ec4ffdcfa0e47c480f 100644
--- a/chrome/browser/plugins/plugins_field_trial.cc
+++ b/chrome/browser/plugins/plugins_field_trial.cc
@@ -5,7 +5,33 @@
#include "chrome/browser/plugins/plugins_field_trial.h"
#include "base/feature_list.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/common/chrome_features.h"
+#include "components/content_settings/core/browser/host_content_settings_map.h"
+#include "components/variations/variations_associated_data.h"
+
+namespace {
+
+// The default site engagement threshold to allow Flash to be presented as an
+// available plugin.
+const double kSiteEngagementThresholdForFlash = 1.0;
+
+double GetSiteEngagementThresholdForFlash() {
+ double threshold = -1;
+ std::string param = variations::GetVariationParamValueByFeature(
+ features::kPreferHtmlOverPlugins,
+ PluginsFieldTrial::kSiteEngagementThresholdForFlashKey);
+ if (base::StringToDouble(param, &threshold) && threshold >= 0)
+ return threshold;
+ return kSiteEngagementThresholdForFlash;
+}
+
+} // namespace
+
+// static
+const char* PluginsFieldTrial::kSiteEngagementThresholdForFlashKey =
+ "engagement_threshold_for_flash";
// static
ContentSetting PluginsFieldTrial::EffectiveContentSetting(
@@ -22,3 +48,11 @@ ContentSetting PluginsFieldTrial::EffectiveContentSetting(
? ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT
: ContentSetting::CONTENT_SETTING_BLOCK;
}
+
+// static
+bool PluginsFieldTrial::HasSufficientEngagementForFlash(
+ HostContentSettingsMap* settings,
+ const GURL& url) {
+ return SiteEngagementService::GetScoreFromSettings(settings, url) >=
+ GetSiteEngagementThresholdForFlash();
+}

Powered by Google App Engine
This is Rietveld 408576698