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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/javascript_dialogs/javascript_dialog_tab_helper.h" 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementLessThanOne", 69 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementLessThanOne",
70 message_length); 70 message_length);
71 } else if (engagement_score < 5) { 71 } else if (engagement_score < 5) {
72 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementOneToFive", 72 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementOneToFive",
73 message_length); 73 message_length);
74 } else { 74 } else {
75 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementHigher", 75 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementHigher",
76 message_length); 76 message_length);
77 } 77 }
78 78
79 content::WebContents* parent_web_contents =
80 WebContentsObserver::web_contents();
81 enum class Foremost {
82 FOREMOST = 0,
83 NOT_FOREMOST = 1,
84 MAX,
85 };
86 Foremost foremost = IsWebContentsForemost(parent_web_contents)
87 ? Foremost::FOREMOST
88 : Foremost::NOT_FOREMOST;
89 switch (message_type) {
90 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT:
91 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
92 static_cast<int>(foremost),
93 static_cast<int>(Foremost::MAX));
94 break;
95 case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM:
96 UMA_HISTOGRAM_ENUMERATION("JSDialogs.ForemostStatus.Confirm",
97 static_cast<int>(foremost),
98 static_cast<int>(Foremost::MAX));
99 break;
100 case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT:
101 UMA_HISTOGRAM_ENUMERATION("JSDialogs.ForemostStatus.Prompt",
102 static_cast<int>(foremost),
103 static_cast<int>(Foremost::MAX));
104 break;
105 }
106
79 if (IsEnabled()) { 107 if (IsEnabled()) {
80 content::WebContents* parent_web_contents =
81 WebContentsObserver::web_contents();
82
83 if (!IsWebContentsForemost(parent_web_contents) && 108 if (!IsWebContentsForemost(parent_web_contents) &&
84 message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) { 109 message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) {
85 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi): 110 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi):
86 // Eventually, for subsequent phases of http://bit.ly/project-oldspice, 111 // Eventually, for subsequent phases of http://bit.ly/project-oldspice,
87 // turn off focus stealing for other dialog types. 112 // turn off focus stealing for other dialog types.
88 *did_suppress_message = true; 113 *did_suppress_message = true;
89 return; 114 return;
90 } 115 }
91 116
92 if (dialog_) { 117 if (dialog_) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 DCHECK(dialog_); 233 DCHECK(dialog_);
209 234
210 dialog_->CloseDialogWithoutCallback(); 235 dialog_->CloseDialogWithoutCallback();
211 if (!suppress_callback) 236 if (!suppress_callback)
212 dialog_callback_.Run(success, user_input); 237 dialog_callback_.Run(success, user_input);
213 238
214 dialog_.reset(); 239 dialog_.reset();
215 dialog_callback_.Reset(); 240 dialog_callback_.Reset();
216 BrowserList::RemoveObserver(this); 241 BrowserList::RemoveObserver(this);
217 } 242 }
OLDNEW
« 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