| 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; | 
| +} | 
|  |