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

Unified Diff: chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc

Issue 2502493002: Add UMA metrics to see the proportions of dialogs spawned by foremost pages. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
diff --git a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
index dd52e788c6c634380fed2c5ca9a9966a4076e6e1..5d69513500f18b3ac35565dc606ee2a86e1f069d 100644
--- a/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
+++ b/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
@@ -76,10 +76,35 @@ void JavaScriptDialogTabHelper::RunJavaScriptDialog(
message_length);
}
- if (IsEnabled()) {
- content::WebContents* parent_web_contents =
- WebContentsObserver::web_contents();
+ content::WebContents* parent_web_contents =
+ WebContentsObserver::web_contents();
+ enum class Foremost {
+ FOREMOST = 0,
+ NOT_FOREMOST = 1,
+ MAX,
+ };
+ Foremost foremost = IsWebContentsForemost(parent_web_contents)
+ ? Foremost::FOREMOST
+ : Foremost::NOT_FOREMOST;
+ switch (message_type) {
+ case content::JAVASCRIPT_MESSAGE_TYPE_ALERT:
+ UMA_HISTOGRAM_ENUMERATION("JSDialogs.ForemostStatus.Alert",
Rick Byers 2016/11/13 23:36:27 nit: I'd find this simpler to read if you had only
Rick Byers 2016/11/13 23:36:27 Note that you could use UMA_HISTOGRAM_BOOLEAN for
Avi (use Gerrit) 2016/11/13 23:52:56 Right.... Every time I do histograms I learn some
+ static_cast<int>(foremost),
+ static_cast<int>(Foremost::MAX));
+ break;
+ case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM:
+ UMA_HISTOGRAM_ENUMERATION("JSDialogs.ForemostStatus.Confirm",
+ static_cast<int>(foremost),
+ static_cast<int>(Foremost::MAX));
+ break;
+ case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT:
+ UMA_HISTOGRAM_ENUMERATION("JSDialogs.ForemostStatus.Prompt",
+ static_cast<int>(foremost),
+ static_cast<int>(Foremost::MAX));
+ break;
+ }
+ if (IsEnabled()) {
if (!IsWebContentsForemost(parent_web_contents) &&
message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) {
// Don't allow "prompt" dialogs to steal the user's focus. TODO(avi):
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698