summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/app_modal/javascript_app_modal_dialog.cc3
-rw-r--r--components/app_modal/javascript_app_modal_dialog.h3
-rw-r--r--components/app_modal/javascript_dialog_manager.cc15
3 files changed, 20 insertions, 1 deletions
diff --git a/components/app_modal/javascript_app_modal_dialog.cc b/components/app_modal/javascript_app_modal_dialog.cc
index efce144..26d1b03 100644
--- a/components/app_modal/javascript_app_modal_dialog.cc
+++ b/components/app_modal/javascript_app_modal_dialog.cc
@@ -54,7 +54,8 @@ void EnforceMaxPromptSize(const base::string16& in_string,
ChromeJavaScriptDialogExtraData::ChromeJavaScriptDialogExtraData()
: has_already_shown_a_dialog_(false),
- suppress_javascript_messages_(false) {}
+ suppress_javascript_messages_(false),
+ suppressed_dialog_count_(0) {}
JavaScriptAppModalDialog::JavaScriptAppModalDialog(
content::WebContents* web_contents,
diff --git a/components/app_modal/javascript_app_modal_dialog.h b/components/app_modal/javascript_app_modal_dialog.h
index 111ba7d..76c09e3 100644
--- a/components/app_modal/javascript_app_modal_dialog.h
+++ b/components/app_modal/javascript_app_modal_dialog.h
@@ -26,6 +26,9 @@ class ChromeJavaScriptDialogExtraData {
// True if the user has decided to block future JavaScript dialogs.
bool suppress_javascript_messages_;
+
+ // Number of dialogs from the origin that were suppressed.
+ int suppressed_dialog_count_;
};
// A controller + model class for JavaScript alert, confirm, prompt, and
diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc
index f654f8bf3..7c4db07 100644
--- a/components/app_modal/javascript_dialog_manager.cc
+++ b/components/app_modal/javascript_dialog_manager.cc
@@ -104,6 +104,21 @@ void JavaScriptDialogManager::RunJavaScriptDialog(
web_contents)];
if (extra_data->suppress_javascript_messages_) {
+ // If a page tries to open dialogs in a tight loop, the number of
+ // suppressions logged can grow out of control. Arbitrarily cap the number
+ // logged at 100. That many suppressed dialogs is enough to indicate the
+ // page is doing something very hinky.
+ if (extra_data->suppressed_dialog_count_ < 100) {
+ // Log a suppressed dialog as one that opens and then closes immediately.
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "JSDialogs.FineTiming.TimeBetweenDialogCreatedAndSameDialogClosed",
+ base::TimeDelta());
+
+ // Only increment the count if it's not already at the limit, to prevent
+ // overflow.
+ extra_data->suppressed_dialog_count_++;
+ }
+
*did_suppress_message = true;
return;
}