Allow the subresource filter to untag frames as ads

Currently, once a frame is tagged as an ad, it will never be untagged as
one. However, in a future cl, we will change the tagging criteria to
ignore whether the frame was created by ad script when the frame's URL
matches certain conditions. This will help avoid known false positives.
Thus, if a frame was created by ad script and its URL changes, we may
want to untag it.

This cl adds support for doing that, but avoids making any actual change
in functionality. As part of enabling untagging, the FrameAdEvidence
struct is no longer "frozen" when a frame is tagged as an ad. To avoid
any functional change, however, we also store the most restrictive load
policy ever calculated for a frame instead of just the most recent. This
is then used in the tagging decision, ensuring ensure that any frame
tagged as an ad under the current rules will stay tagged, even though
untagging is now permitted.

Note that this cl is also dependent on crrev.com/c/2639098. See the
design doc linked in the crbug and crrev.com/c/2419372's commit
message for more detail on these changes and the rationale behind them.

Bug: 1164567
Change-Id: I9f88058ac370840e43f2b46832cc11e7760ccbbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642955
Commit-Queue: Alex Turner <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Reviewed-by: Nate Chapin <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: Charlie Harrison <[email protected]>
Reviewed-by: John Delaney <[email protected]>
Cr-Commit-Position: refs/heads/master@{#863819}
diff --git a/content/browser/renderer_host/frame_tree_node.cc b/content/browser/renderer_host/frame_tree_node.cc
index 3d1e37e9..0f296d0 100644
--- a/content/browser/renderer_host/frame_tree_node.cc
+++ b/content/browser/renderer_host/frame_tree_node.cc
@@ -792,13 +792,11 @@
 }
 
 void FrameTreeNode::SetAdFrameType(blink::mojom::AdFrameType ad_frame_type) {
-  DCHECK_NE(ad_frame_type, blink::mojom::AdFrameType::kNonAd);
-  if (replication_state_->ad_frame_type == blink::mojom::AdFrameType::kNonAd) {
-    replication_state_->ad_frame_type = ad_frame_type;
-    render_manager()->OnDidSetAdFrameType(ad_frame_type);
-  } else {
-    DCHECK_EQ(ad_frame_type, replication_state_->ad_frame_type);
-  }
+  if (ad_frame_type == replication_state_->ad_frame_type)
+    return;
+
+  replication_state_->ad_frame_type = ad_frame_type;
+  render_manager()->OnDidSetAdFrameType(ad_frame_type);
 }
 
 void FrameTreeNode::SetInitialPopupURL(const GURL& initial_popup_url) {