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

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: boolean 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 bool foremost = IsWebContentsForemost(parent_web_contents);
82 switch (message_type) {
83 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT:
84 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Alert", foremost);
85 break;
86 case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM:
87 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Confirm", foremost);
88 break;
89 case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT:
90 UMA_HISTOGRAM_BOOLEAN("JSDialogs.IsForemost.Prompt", foremost);
91 break;
92 }
93
79 if (IsEnabled()) { 94 if (IsEnabled()) {
80 content::WebContents* parent_web_contents =
81 WebContentsObserver::web_contents();
82
83 if (!IsWebContentsForemost(parent_web_contents) && 95 if (!IsWebContentsForemost(parent_web_contents) &&
84 message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) { 96 message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) {
85 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi): 97 // Don't allow "prompt" dialogs to steal the user's focus. TODO(avi):
86 // Eventually, for subsequent phases of http://bit.ly/project-oldspice, 98 // Eventually, for subsequent phases of http://bit.ly/project-oldspice,
87 // turn off focus stealing for other dialog types. 99 // turn off focus stealing for other dialog types.
88 *did_suppress_message = true; 100 *did_suppress_message = true;
89 return; 101 return;
90 } 102 }
91 103
92 if (dialog_) { 104 if (dialog_) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 DCHECK(dialog_); 220 DCHECK(dialog_);
209 221
210 dialog_->CloseDialogWithoutCallback(); 222 dialog_->CloseDialogWithoutCallback();
211 if (!suppress_callback) 223 if (!suppress_callback)
212 dialog_callback_.Run(success, user_input); 224 dialog_callback_.Run(success, user_input);
213 225
214 dialog_.reset(); 226 dialog_.reset();
215 dialog_callback_.Reset(); 227 dialog_callback_.Reset();
216 BrowserList::RemoveObserver(this); 228 BrowserList::RemoveObserver(this);
217 } 229 }
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