diff options
| author | joenotcharles <joenotcharles@chromium.org> | 2016-02-11 11:28:53 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-02-11 19:30:19 +0000 |
| commit | 505f421d0a73adae4f74924b3022996c731de40e (patch) | |
| tree | e7fa3276c6809302d9ce720528f58907e38ee681 | |
| parent | 36ceb3208ad8e20193e7f2f1780abcaf398e650f (diff) | |
| download | chromium_src-505f421d0a73adae4f74924b3022996c731de40e.zip chromium_src-505f421d0a73adae4f74924b3022996c731de40e.tar.gz chromium_src-505f421d0a73adae4f74924b3022996c731de40e.tar.bz2 | |
Include suppressed dialogs in the FineTiming histogram
Review URL: https://codereview.chromium.org/1688183002
Cr-Commit-Position: refs/heads/master@{#374920}
| -rw-r--r-- | components/app_modal/javascript_app_modal_dialog.cc | 3 | ||||
| -rw-r--r-- | components/app_modal/javascript_app_modal_dialog.h | 3 | ||||
| -rw-r--r-- | components/app_modal/javascript_dialog_manager.cc | 15 |
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; } |
