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

Side by Side 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: Use FOR_EACH_TDI_MODE(V) macro. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/page_load_metrics/observers/ads_detection.h"
6
7 #include "base/strings/string_util.h"
8 #include "url/gurl.h"
9
10 bool IsAdFrame(base::StringPiece frame_name, const GURL& frame_url) {
11 // Google ads are prevalent and easy to track, so we'll start by tracking
12 // those. Note that the frame name can be very large, so be careful to avoid
13 // full string searches if possible.
14 // TODO(jkarlin): Track other ad networks that are easy to identify.
15
16 if (base::StartsWith(frame_name, "google_ads_iframe",
Charlie Reis 2017/06/30 23:28:45 Sanity check: Any page can trigger TDI by naming i
Łukasz Anforowicz 2017/07/01 00:10:53 Correct. Thanks for raising this angle - I honest
17 base::CompareCase::SENSITIVE) ||
18 base::StartsWith(frame_name, "google_ads_frame",
19 base::CompareCase::SENSITIVE)) {
20 return true;
21 }
22
23 if (frame_url.host_piece() == "tpc.googlesyndication.com" &&
24 base::StartsWith(frame_url.path_piece(), "/safeframe",
25 base::CompareCase::SENSITIVE)) {
26 return true;
27 }
28
29 return false;
30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698