Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3392)

Unified Diff: chrome/browser/page_load_metrics/observers/ads_detection.cc

Issue 2946113002: Use FrameIsAd to decide whether to isolate a frame in TopDocumentIsolation mode. (Closed)
Patch Set: Rebasing... Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/page_load_metrics/observers/ads_detection.cc
diff --git a/chrome/browser/page_load_metrics/observers/ads_detection.cc b/chrome/browser/page_load_metrics/observers/ads_detection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7d16d492e22e46fe27c224a5b37e1c9ff4520988
--- /dev/null
+++ b/chrome/browser/page_load_metrics/observers/ads_detection.cc
@@ -0,0 +1,30 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/page_load_metrics/observers/ads_detection.h"
+
+#include "base/strings/string_util.h"
+#include "url/gurl.h"
+
+bool IsAdFrame(base::StringPiece frame_name, const GURL& frame_url) {
+ // Google ads are prevalent and easy to track, so we'll start by tracking
+ // those. Note that the frame name can be very large, so be careful to avoid
+ // full string searches if possible.
+ // TODO(jkarlin): Track other ad networks that are easy to identify.
+
+ if (base::StartsWith(frame_name, "google_ads_iframe",
+ base::CompareCase::SENSITIVE) ||
+ base::StartsWith(frame_name, "google_ads_frame",
+ base::CompareCase::SENSITIVE)) {
+ return true;
+ }
+
+ if (frame_url.host_piece() == "tpc.googlesyndication.com" &&
+ base::StartsWith(frame_url.path_piece(), "/safeframe",
+ base::CompareCase::SENSITIVE)) {
+ return true;
+ }
+
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698