| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/plugins/plugins_field_trial.h" | 5 #include "chrome/browser/plugins/plugins_field_trial.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/browser/plugins/plugin_utils.h" |
| 9 #include "chrome/common/chrome_features.h" | 10 #include "chrome/common/chrome_features.h" |
| 10 #include "components/variations/variations_associated_data.h" | 11 #include "components/variations/variations_associated_data.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 // The default site engagement threshold to allow Flash to be presented as an | 15 // The default site engagement threshold to allow Flash to be presented as an |
| 15 // available plugin. This value is not used for normal uses, but only for | 16 // available plugin. This value is not used for normal uses, but only for |
| 16 // developers / testers that don't have a field trial configuration. | 17 // developers / testers that don't have a field trial configuration. |
| 17 const double kDefaultSiteEngagementThresholdForFlash = 30.0; | 18 const double kDefaultSiteEngagementThresholdForFlash = 30.0; |
| 18 | 19 |
| 19 } // namespace | 20 } // namespace |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 const char* PluginsFieldTrial::kSiteEngagementThresholdForFlashKey = | 23 const char* PluginsFieldTrial::kSiteEngagementThresholdForFlashKey = |
| 23 "engagement_threshold_for_flash"; | 24 "engagement_threshold_for_flash"; |
| 24 | 25 |
| 25 // static | 26 // static |
| 26 ContentSetting PluginsFieldTrial::EffectiveContentSetting( | 27 ContentSetting PluginsFieldTrial::EffectiveContentSetting( |
| 28 const HostContentSettingsMap* host_content_settings_map, |
| 27 ContentSettingsType type, | 29 ContentSettingsType type, |
| 28 ContentSetting setting) { | 30 ContentSetting setting) { |
| 29 if (type != CONTENT_SETTINGS_TYPE_PLUGINS || | 31 if (type != CONTENT_SETTINGS_TYPE_PLUGINS || |
| 30 setting != ContentSetting::CONTENT_SETTING_ASK) { | 32 setting != ContentSetting::CONTENT_SETTING_ASK) { |
| 31 return setting; | 33 return setting; |
| 32 } | 34 } |
| 33 | 35 |
| 34 // For Plugins, ASK is obsolete. Show as BLOCK or, if PreferHtmlOverPlugins | 36 // For Plugins, ASK is obsolete. Show as BLOCK or, if PreferHtmlOverPlugins |
| 35 // feature is enabled, as DETECT_IMPORTANT_CONTENT to reflect actual behavior. | 37 // feature is enabled, as DETECT_IMPORTANT_CONTENT to reflect actual behavior. |
| 36 return base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins) | 38 return PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map) |
| 37 ? ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT | 39 ? ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT |
| 38 : ContentSetting::CONTENT_SETTING_BLOCK; | 40 : ContentSetting::CONTENT_SETTING_BLOCK; |
| 39 } | 41 } |
| 40 | 42 |
| 41 // static | 43 // static |
| 42 double PluginsFieldTrial::GetSiteEngagementThresholdForFlash() { | 44 double PluginsFieldTrial::GetSiteEngagementThresholdForFlash() { |
| 43 double threshold = -1; | 45 double threshold = -1; |
| 44 std::string param = variations::GetVariationParamValueByFeature( | 46 std::string param = variations::GetVariationParamValueByFeature( |
| 45 features::kPreferHtmlOverPlugins, | 47 features::kPreferHtmlOverPlugins, |
| 46 PluginsFieldTrial::kSiteEngagementThresholdForFlashKey); | 48 PluginsFieldTrial::kSiteEngagementThresholdForFlashKey); |
| 47 if (base::StringToDouble(param, &threshold) && threshold >= 0) | 49 if (base::StringToDouble(param, &threshold) && threshold >= 0) |
| 48 return threshold; | 50 return threshold; |
| 49 return kDefaultSiteEngagementThresholdForFlash; | 51 return kDefaultSiteEngagementThresholdForFlash; |
| 50 } | 52 } |
| OLD | NEW |