Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc

Issue 2578363002: Wire up download attribution enable finch experiment (Closed)
Patch Set: Remove unnecessary includes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
index 989f7d61eeea3d07bb96d6bae1f4048edbd7b7b8..0d14f782777934a9c1bd803b3106d17f4901fd4d 100644
--- a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
@@ -9,10 +9,15 @@
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h"
+#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/tab_contents/retargeting_details.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
@@ -47,10 +52,13 @@ static const double kUserGestureTTLInSecond = 1.0;
// navigation related records that happened 2 minutes ago are considered as
// expired. So we clean up these navigation footprints every 2 minutes.
static const double kNavigationFootprintTTLInSecond = 120.0;
-// The number of user gestures we trace back for download attribution.
-static const int kDownloadAttributionUserGestureLimit = 2;
// static
+const base::Feature
+SafeBrowsingNavigationObserverManager::kDownloadAttribution {
+ "DownloadAttribution", base::FEATURE_DISABLED_BY_DEFAULT
+};
+// static
bool SafeBrowsingNavigationObserverManager::IsUserGestureExpired(
const base::Time& timestamp) {
return IsEventExpired(timestamp, kUserGestureTTLInSecond);
@@ -66,12 +74,23 @@ GURL SafeBrowsingNavigationObserverManager::ClearEmptyRef(const GURL& url) {
return url;
}
+// static
+bool SafeBrowsingNavigationObserverManager::IsEnabledAndReady(
+ Profile* profile) {
+ return base::FeatureList::IsEnabled(
+ SafeBrowsingNavigationObserverManager::kDownloadAttribution) &&
+ profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) &&
+ g_browser_process->safe_browsing_service() &&
+ g_browser_process->safe_browsing_service()->navigation_observer_manager();
+}
+
SafeBrowsingNavigationObserverManager::SafeBrowsingNavigationObserverManager() {
registrar_.Add(this, chrome::NOTIFICATION_RETARGETING,
content::NotificationService::AllSources());
- // TODO(jialiul): call ScheduleNextCleanUpAfterInterval() when this class is
- // ready to be hooked into SafeBrowsingService.
+ // Schedule clean up in 2 minutes.
+ ScheduleNextCleanUpAfterInterval(
+ base::TimeDelta::FromSecondsD(kNavigationFootprintTTLInSecond));
}
void SafeBrowsingNavigationObserverManager::RecordNavigationEvent(
@@ -208,29 +227,6 @@ SafeBrowsingNavigationObserverManager::IdentifyReferrerChain(
return result;
}
-void SafeBrowsingNavigationObserverManager::
- AddReferrerChainToClientDownloadRequest(
- const GURL& download_url,
- content::WebContents* source_contents,
- ClientDownloadRequest* out_request) {
- int download_tab_id = SessionTabHelper::IdForTab(source_contents);
- UMA_HISTOGRAM_BOOLEAN(
- "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
- download_tab_id == -1);
- std::vector<ReferrerChainEntry> attribution_chain;
- AttributionResult result = IdentifyReferrerChain(
- download_url, download_tab_id, kDownloadAttributionUserGestureLimit,
- &attribution_chain);
- UMA_HISTOGRAM_COUNTS_100(
- "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution",
- attribution_chain.size());
- UMA_HISTOGRAM_ENUMERATION(
- "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result,
- SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
- for (auto entry : attribution_chain)
- *out_request->add_referrer_chain() = entry;
-}
-
SafeBrowsingNavigationObserverManager::
~SafeBrowsingNavigationObserverManager() {}

Powered by Google App Engine
This is Rietveld 408576698