Chromium Code Reviews| Index: components/app_modal/javascript_dialog_manager.cc |
| diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc |
| index f654f8bf3d01283202768bf81aebd77d655ae908..7c4db07af63ab2e967dcdb9e2dbb2dd659e6a4d5 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. |
|
Avi (use Gerrit)
2016/02/11 15:55:04
Wellll... not necessarily. Imagine a calendar tab
|
| + 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; |
| } |