Chromium Code Reviews| 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): |