[subresource_filter] Log histogram bucket for stronger popup blocker

This histogram is logged once every time the stronger popup blocker
blocks a popup.

A followup could aggregate this per page load if we're worried about
skew.

Bug: 756089
Change-Id: I1c2406a47fb48aeb91993ba24be485c3baf0f198
Reviewed-on: https://chromium-review.googlesource.com/633787
Reviewed-by: Shivani Sharma <shivanisha@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497416}
diff --git a/chrome/browser/subresource_filter/chrome_subresource_filter_client.h b/chrome/browser/subresource_filter/chrome_subresource_filter_client.h
index 30abc0e..821d4ca4 100644
--- a/chrome/browser/subresource_filter/chrome_subresource_filter_client.h
+++ b/chrome/browser/subresource_filter/chrome_subresource_filter_client.h
@@ -85,6 +85,9 @@
   // have been blocked. Note that in these cases the UI is suppressed.
   kActionForcedActivationNoUIResourceBlocked,
 
+  // Logged when a popup is blocked due to subresource filter logic.
+  kActionPopupBlocked,
+
   kActionLastEntry
 };
 
diff --git a/chrome/browser/subresource_filter/subresource_filter_popup_browsertest.cc b/chrome/browser/subresource_filter/subresource_filter_popup_browsertest.cc
index 7078828..4e02507 100644
--- a/chrome/browser/subresource_filter/subresource_filter_popup_browsertest.cc
+++ b/chrome/browser/subresource_filter/subresource_filter_popup_browsertest.cc
@@ -84,6 +84,8 @@
   EXPECT_TRUE(opened_window);
   EXPECT_FALSE(TabSpecificContentSettings::FromWebContents(web_contents)
                    ->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
+  tester.ExpectBucketCount(kSubresourceFilterActionsHistogram,
+                           kActionPopupBlocked, 0);
 }
 
 IN_PROC_BROWSER_TEST_F(SubresourceFilterPopupBrowserTest,
@@ -105,6 +107,8 @@
   EXPECT_FALSE(opened_window);
   tester.ExpectBucketCount(kSubresourceFilterActionsHistogram, kActionUIShown,
                            0);
+  tester.ExpectBucketCount(kSubresourceFilterActionsHistogram,
+                           kActionPopupBlocked, 1);
   // Make sure the popup UI was shown.
   EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)
                   ->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
@@ -188,6 +192,8 @@
   EXPECT_TRUE(content::ExecuteScript(web_contents, "openWindow()"));
   tester.ExpectBucketCount(kSubresourceFilterActionsHistogram, kActionUIShown,
                            0);
+  tester.ExpectBucketCount(kSubresourceFilterActionsHistogram,
+                           kActionPopupBlocked, 1);
 
   EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)
                   ->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
diff --git a/chrome/browser/ui/blocked_content/popup_blocker_tab_helper.cc b/chrome/browser/ui/blocked_content/popup_blocker_tab_helper.cc
index ac9553e..d514c71 100644
--- a/chrome/browser/ui/blocked_content/popup_blocker_tab_helper.cc
+++ b/chrome/browser/ui/blocked_content/popup_blocker_tab_helper.cc
@@ -9,6 +9,7 @@
 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h"
 #include "chrome/browser/ui/blocked_content/blocked_window_params.h"
 #include "chrome/browser/ui/browser_navigator.h"
 #include "chrome/browser/ui/browser_navigator_params.h"
@@ -137,6 +138,7 @@
         !driver_factory->ShouldDisallowNewWindow(open_url_params)) {
       return false;
     }
+    ChromeSubresourceFilterClient::LogAction(kActionPopupBlocked);
   }
 
   popup_blocker->AddBlockedPopup(params, window_features);
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 1d1840f..77a5719 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -36450,6 +36450,7 @@
   <int value="12" label="Forced filtering toggled on via devtools"/>
   <int value="13"
       label="UI suppressed and resources blocked (Forced Activation)"/>
+  <int value="14" label="Blocked popup (Strong Popup Blocker)"/>
 </enum>
 
 <enum name="SubresourceFilterActivationDecision">