Chromium Code Reviews| Index: chrome/browser/page_load_metrics/observers/ads_detection.h |
| diff --git a/chrome/browser/page_load_metrics/observers/ads_detection.h b/chrome/browser/page_load_metrics/observers/ads_detection.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8441768fa1e06faf6852dda671814697c1827f53 |
| --- /dev/null |
| +++ b/chrome/browser/page_load_metrics/observers/ads_detection.h |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
|
jkarlin
2017/07/18 17:34:44
I'm not sure that this utility file belongs in thi
Charlie Harrison
2017/07/18 18:11:30
I would slightly prefer it to be in chrome/browser
Łukasz Anforowicz
2017/07/18 19:06:11
sgtm - I've moved ads_detection.h/.cc to chrome/br
Charlie Harrison
2017/07/18 19:24:41
Yeah, it would take some maneuvering to put it in
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_DETECTION_H_ |
| +#define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_DETECTION_H_ |
| + |
| +#include <bitset> |
| +#include <string> |
| + |
| +#include "base/strings/string_piece_forward.h" |
| + |
| +namespace content { |
| +class NavigationHandle; |
| +} // namespace content |
| + |
| +// The types of ads that one can detect or filter on. |
| +enum AdType { |
| + AD_TYPE_GOOGLE = 0, |
| + AD_TYPE_SUBRESOURCE_FILTER = 1, |
| + AD_TYPE_ALL = 2, |
| + AD_TYPE_MAX = AD_TYPE_ALL |
| +}; |
| +using AdTypes = std::bitset<AD_TYPE_MAX>; |
| + |
| +// Uses various heuristics to determine if a given navigation tries to load an |
| +// advertisment. For some ad types the results depend on |
| +// SetNavigationAdHeuristics, but some ad types can be detected based on the |
| +// basic navigation properties (like URL and/or name of the frame being |
| +// navigated). |
|
jkarlin
2017/07/18 17:34:44
Discussion about the SetNavigationAdHeuristics stu
Łukasz Anforowicz
2017/07/18 19:06:11
Done.
|
| +AdTypes GetAdDetectionHeuristics(content::NavigationHandle* navigation_handle); |
|
jkarlin
2017/07/18 17:34:44
GetAdDetectionHeuristics sounds like it's returnin
Łukasz Anforowicz
2017/07/18 19:06:11
Done.
|
| + |
| +// Marks the |navigation_handle| as loading an advertisment of a given |type|. |
| +void SetAdDetectionHeuristics(content::NavigationHandle* navigation_handle, |
|
jkarlin
2017/07/18 17:34:44
Likewise, I much prefer SetDetectedAdType.
Łukasz Anforowicz
2017/07/18 19:06:11
Done.
|
| + AdType type); |
| + |
| +#endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_DETECTION_H_ |