summaryrefslogtreecommitdiffstats
path: root/components/app_modal/javascript_dialog_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'components/app_modal/javascript_dialog_manager.cc')
-rw-r--r--components/app_modal/javascript_dialog_manager.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc
index 43256fe..36153da 100644
--- a/components/app_modal/javascript_dialog_manager.cc
+++ b/components/app_modal/javascript_dialog_manager.cc
@@ -4,6 +4,7 @@
#include "components/app_modal/javascript_dialog_manager.h"
+#include <algorithm>
#include <utility>
#include "base/bind.h"
@@ -25,6 +26,7 @@
#include "ui/gfx/font_list.h"
namespace app_modal {
+
namespace {
#if !defined(OS_ANDROID)
@@ -56,6 +58,32 @@ bool ShouldDisplaySuppressCheckbox(
return extra_data->has_already_shown_a_dialog_;
}
+enum class DialogType {
+ JAVASCRIPT,
+ ON_BEFORE_UNLOAD,
+};
+
+void LogUMAMessageLengthStats(const base::string16& message, DialogType type) {
+ if (type == DialogType::JAVASCRIPT) {
+ UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageCharacters",
+ static_cast<int32_t>(message.length()));
+ } else {
+ UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfOnBeforeUnloadMessageCharacters",
+ static_cast<int32_t>(message.length()));
+ }
+
+ int32_t newline_count =
+ std::count_if(message.begin(), message.end(),
+ [](const base::char16& c) { return c == '\n'; });
+ if (type == DialogType::JAVASCRIPT) {
+ UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageNewlines",
+ newline_count);
+ } else {
+ UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfOnBeforeUnloadMessageNewlines",
+ newline_count);
+ }
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -145,6 +173,7 @@ void JavaScriptDialogManager::RunJavaScriptDialog(
extensions_client_->OnDialogOpened(web_contents);
+ LogUMAMessageLengthStats(message_text, DialogType::JAVASCRIPT);
AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog(
web_contents,
&javascript_dialog_extra_data_,
@@ -184,6 +213,7 @@ void JavaScriptDialogManager::RunBeforeUnloadDialog(
extensions_client_->OnDialogOpened(web_contents);
+ LogUMAMessageLengthStats(message_text, DialogType::ON_BEFORE_UNLOAD);
AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog(
web_contents,
&javascript_dialog_extra_data_,