| 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", | 22 const base::Feature kAdsFeature{"AdsMetrics", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 23 base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 24 | 23 |
| 25 bool FrameIsAd(content::NavigationHandle* navigation_handle) { | 24 bool FrameIsAd(content::NavigationHandle* navigation_handle) { |
| 26 // Because sub-resource filtering isn't always enabled, and doesn't work | 25 // Because sub-resource filtering isn't always enabled, and doesn't work |
| 27 // well in monitoring mode (no CSS enforcement), it's difficult to identify | 26 // well in monitoring mode (no CSS enforcement), it's difficult to identify |
| 28 // ads. Google ads are prevalent and easy to track, so we'll start by | 27 // ads. Google ads are prevalent and easy to track, so we'll start by |
| 29 // tracking those. Note that the frame name can be very large, so be careful | 28 // tracking those. Note that the frame name can be very large, so be careful |
| 30 // to avoid full string searches if possible. | 29 // to avoid full string searches if possible. |
| 31 // TODO(jkarlin): Track other ad networks that are easy to identify. | 30 // TODO(jkarlin): Track other ad networks that are easy to identify. |
| 32 | 31 |
| 33 // In case the navigation aborted, look up the RFH by the Frame Tree Node | 32 // In case the navigation aborted, look up the RFH by the Frame Tree Node |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 303 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
| 305 FrameTreeNodeId frame_tree_node_id) { | 304 FrameTreeNodeId frame_tree_node_id) { |
| 306 const auto& frame_id_and_request = | 305 const auto& frame_id_and_request = |
| 307 ongoing_navigation_resources_.find(frame_tree_node_id); | 306 ongoing_navigation_resources_.find(frame_tree_node_id); |
| 308 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 307 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
| 309 return; | 308 return; |
| 310 | 309 |
| 311 ProcessLoadedResource(frame_id_and_request->second); | 310 ProcessLoadedResource(frame_id_and_request->second); |
| 312 ongoing_navigation_resources_.erase(frame_id_and_request); | 311 ongoing_navigation_resources_.erase(frame_id_and_request); |
| 313 } | 312 } |
| OLD | NEW |