Commit 7d1795d4 authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

Clipboard: Add UMA metrics for content script reads without user activation.

The proportion of content script reads without user activation will
inform potential deprecation plan and messaging.

Bug: 1051198
Change-Id: Ie9c76a6d26ee78219729ef54da7237eb061c98f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440116Reviewed-by: default avatarWeilun Shi <sweilun@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813889}
parent bce662eb
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
#include "base/metrics/histogram_functions.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/permissions/api_permission.h" #include "extensions/common/permissions/api_permission.h"
...@@ -73,6 +74,16 @@ ChromeContentSettingsAgentDelegate::AllowReadFromClipboard() { ...@@ -73,6 +74,16 @@ ChromeContentSettingsAgentDelegate::AllowReadFromClipboard() {
extension_dispatcher_->script_context_set().GetCurrent(); extension_dispatcher_->script_context_set().GetCurrent();
if (current_context && current_context->HasAPIPermission( if (current_context && current_context->HasAPIPermission(
extensions::APIPermission::kClipboardRead)) { extensions::APIPermission::kClipboardRead)) {
if (current_context->context_type() ==
extensions::Feature::CONTENT_SCRIPT_CONTEXT) {
bool has_user_activation =
render_frame_->GetWebFrame()->HasTransientUserActivation();
// TODO(https://crbug.com/1051198): Evaluate and deprecate content script
// read without user activation after enough data is gathered.
base::UmaHistogramBoolean(
"Clipboard.ExtensionContentScriptReadHasUserActivation",
has_user_activation);
}
return true; return true;
} }
#endif #endif
......
...@@ -2245,6 +2245,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -2245,6 +2245,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Clipboard.ExtensionContentScriptReadHasUserActivation"
units="proportion" expires_after="2021-04-01">
<owner>huangdarwin@chromium.org</owner>
<owner>src/third_party/blink/renderer/modules/clipboard/OWNERS</owner>
<summary>
For calls to document.execCommand('paste') by extensions via content
scripts, record the proportion of calls with user activation.
</summary>
</histogram>
<histogram name="Clipboard.Read" enum="ClipboardFormatRead" <histogram name="Clipboard.Read" enum="ClipboardFormatRead"
expires_after="2021-03-07"> expires_after="2021-03-07">
<owner>huangdarwin@chromium.org</owner> <owner>huangdarwin@chromium.org</owner>
......
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