| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/page_load_metrics/observers/ads_page_load_metrics_obser
ver.h" | 5 #include "chrome/browser/page_load_metrics/observers/ads_page_load_metrics_obser
ver.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 14 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
| 15 #include "content/public/browser/navigation_handle.h" | 15 #include "content/public/browser/navigation_handle.h" |
| 16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const base::Feature kAdsFeature{"AdsMetrics", base::FEATURE_ENABLED_BY_DEFAULT}; | 22 const base::Feature kAdsFeature{"AdsMetrics", |
| 23 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 23 | 24 |
| 24 bool FrameIsAd(content::NavigationHandle* navigation_handle) { | 25 bool FrameIsAd(content::NavigationHandle* navigation_handle) { |
| 25 // Because sub-resource filtering isn't always enabled, and doesn't work | 26 // Because sub-resource filtering isn't always enabled, and doesn't work |
| 26 // well in monitoring mode (no CSS enforcement), it's difficult to identify | 27 // well in monitoring mode (no CSS enforcement), it's difficult to identify |
| 27 // ads. Google ads are prevalent and easy to track, so we'll start by | 28 // ads. Google ads are prevalent and easy to track, so we'll start by |
| 28 // tracking those. Note that the frame name can be very large, so be careful | 29 // tracking those. Note that the frame name can be very large, so be careful |
| 29 // to avoid full string searches if possible. | 30 // to avoid full string searches if possible. |
| 30 // TODO(jkarlin): Track other ad networks that are easy to identify. | 31 // TODO(jkarlin): Track other ad networks that are easy to identify. |
| 31 | 32 |
| 32 // In case the navigation aborted, look up the RFH by the Frame Tree Node | 33 // In case the navigation aborted, look up the RFH by the Frame Tree Node |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 289 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
| 289 FrameTreeNodeId frame_tree_node_id) { | 290 FrameTreeNodeId frame_tree_node_id) { |
| 290 const auto& frame_id_and_request = | 291 const auto& frame_id_and_request = |
| 291 ongoing_navigation_resources_.find(frame_tree_node_id); | 292 ongoing_navigation_resources_.find(frame_tree_node_id); |
| 292 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 293 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
| 293 return; | 294 return; |
| 294 | 295 |
| 295 ProcessLoadedResource(frame_id_and_request->second); | 296 ProcessLoadedResource(frame_id_and_request->second); |
| 296 ongoing_navigation_resources_.erase(frame_id_and_request); | 297 ongoing_navigation_resources_.erase(frame_id_and_request); |
| 297 } | 298 } |
| OLD | NEW |