Commit 3b6456d4 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add metrics for Flash ephemeral permissions.

A metric is added to count the number of times Flash permissions are
set for a website. The counter is separated based on whether this is the
first granting of permission or the next times.

Bug: 865933
Change-Id: If33aaf4915109f6e7ed49dc1e7142c64b6981fac
Reviewed-on: https://chromium-review.googlesource.com/1145197Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarMarkus Heintz <markusheintz@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579759}
parent 1e9ceb73
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "components/content_settings/core/browser/website_settings_registry.h" #include "components/content_settings/core/browser/website_settings_registry.h"
#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_utils.h" #include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h" #include "components/content_settings/core/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -187,6 +188,13 @@ content_settings::PatternPair GetPatternsForContentSettingsType( ...@@ -187,6 +188,13 @@ content_settings::PatternPair GetPatternsForContentSettingsType(
return patterns; return patterns;
} }
// This enum is used to collect Flash permission data.
enum class FlashPermissions {
kFirstTime = 0,
kRepeated = 1,
kMaxValue = kRepeated,
};
} // namespace } // namespace
HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
...@@ -510,6 +518,23 @@ void HostContentSettingsMap::SetContentSettingCustomScope( ...@@ -510,6 +518,23 @@ void HostContentSettingsMap::SetContentSettingCustomScope(
DCHECK(content_settings::ContentSettingsRegistry::GetInstance()->Get( DCHECK(content_settings::ContentSettingsRegistry::GetInstance()->Get(
content_type)); content_type));
// Record stats on Flash permission grants with ephemeral storage.
if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS &&
setting == CONTENT_SETTING_ALLOW &&
base::FeatureList::IsEnabled(
content_settings::features::kEnableEphemeralFlashPermission)) {
GURL url(primary_pattern.ToString());
ContentSettingsPattern temp_patterns[2];
std::unique_ptr<base::Value> value(GetContentSettingValueAndPatterns(
content_settings_providers_[PREF_PROVIDER].get(), url, url,
CONTENT_SETTINGS_TYPE_PLUGINS_DATA, resource_identifier, is_incognito_,
temp_patterns, temp_patterns + 1));
UMA_HISTOGRAM_ENUMERATION(
"ContentSettings.EphemeralFlashPermission",
value ? FlashPermissions::kRepeated : FlashPermissions::kFirstTime);
}
std::unique_ptr<base::Value> value; std::unique_ptr<base::Value> value;
// A value of CONTENT_SETTING_DEFAULT implies deleting the content setting. // A value of CONTENT_SETTING_DEFAULT implies deleting the content setting.
if (setting != CONTENT_SETTING_DEFAULT) { if (setting != CONTENT_SETTING_DEFAULT) {
......
...@@ -7221,6 +7221,11 @@ Called by update_net_error_codes.py.--> ...@@ -7221,6 +7221,11 @@ Called by update_net_error_codes.py.-->
<int value="6" label="Clicked 'Always show on mobile'"/> <int value="6" label="Clicked 'Always show on mobile'"/>
</enum> </enum>
<enum name="ContentSettings.EphemeralFlashPermission">
<int value="0" label="The First time permission is granted to a host."/>
<int value="1" label="Subsequant grants to a host."/>
</enum>
<enum name="ContentSettingScheme"> <enum name="ContentSettingScheme">
<int value="0" label="(wildcard)"/> <int value="0" label="(wildcard)"/>
<int value="1" label="(other)"/> <int value="1" label="(other)"/>
...@@ -13593,6 +13593,14 @@ uploading your change for review. ...@@ -13593,6 +13593,14 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="ContentSettings.EphemeralFlashPermission"
enum="ContentSettings.EphemeralFlashPermission" expires_after="M71">
<owner>rhalavati@chromium.org</owner>
<summary>
Records the number of times Flash permission is granted for a host.
</summary>
</histogram>
<histogram name="ContentSettings.Exceptions"> <histogram name="ContentSettings.Exceptions">
<owner>lshang@chromium.org</owner> <owner>lshang@chromium.org</owner>
<summary> <summary>
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