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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( | 277 void AdsPageLoadMetricsObserver::ProcessOngoingNavigationResource( |
277 FrameTreeNodeId frame_tree_node_id) { | 278 FrameTreeNodeId frame_tree_node_id) { |
278 const auto& frame_id_and_request = | 279 const auto& frame_id_and_request = |
279 ongoing_navigation_resources_.find(frame_tree_node_id); | 280 ongoing_navigation_resources_.find(frame_tree_node_id); |
280 if (frame_id_and_request == ongoing_navigation_resources_.end()) | 281 if (frame_id_and_request == ongoing_navigation_resources_.end()) |
281 return; | 282 return; |
282 | 283 |
283 ProcessLoadedResource(frame_id_and_request->second); | 284 ProcessLoadedResource(frame_id_and_request->second); |
284 ongoing_navigation_resources_.erase(frame_id_and_request); | 285 ongoing_navigation_resources_.erase(frame_id_and_request); |
285 } | 286 } |
OLD | NEW |