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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h

Issue 2821163002: Clean up DownloadAttribution Finch experiments (Closed)
Patch Set: revert partial change is InEnabledAndReady() Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGER_H _ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGER_H _
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGER_H _ 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGER_H _
7 7
8 #include <deque> 8 #include <deque>
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_; 88 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_;
89 const std::size_t size_limit_; 89 const std::size_t size_limit_;
90 }; 90 };
91 91
92 // Manager class for SafeBrowsingNavigationObserver, which is in charge of 92 // Manager class for SafeBrowsingNavigationObserver, which is in charge of
93 // cleaning up stale navigation events, and identifying landing page/landing 93 // cleaning up stale navigation events, and identifying landing page/landing
94 // referrer for a specific Safe Browsing event. 94 // referrer for a specific Safe Browsing event.
95 class SafeBrowsingNavigationObserverManager 95 class SafeBrowsingNavigationObserverManager
96 : public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> { 96 : public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> {
97 public: 97 public:
98 static const base::Feature kDownloadAttribution;
99
100 // For UMA histogram counting. Do NOT change order. 98 // For UMA histogram counting. Do NOT change order.
101 enum AttributionResult { 99 enum AttributionResult {
102 SUCCESS = 1, // Identified referrer chain is not empty. 100 SUCCESS = 1, // Identified referrer chain is not empty.
103 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page. 101 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page.
104 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer. 102 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer.
105 INVALID_URL = 4, 103 INVALID_URL = 4,
106 NAVIGATION_EVENT_NOT_FOUND = 5, 104 NAVIGATION_EVENT_NOT_FOUND = 5,
107 105
108 // Always at the end. 106 // Always at the end.
109 ATTRIBUTION_FAILURE_TYPE_MAX 107 ATTRIBUTION_FAILURE_TYPE_MAX
110 }; 108 };
111 109
112 // Helper function to check if user gesture is older than 110 // Helper function to check if user gesture is older than
113 // kUserGestureTTLInSecond. 111 // kUserGestureTTLInSecond.
114 static bool IsUserGestureExpired(const base::Time& timestamp); 112 static bool IsUserGestureExpired(const base::Time& timestamp);
115 113
116 // Helper function to strip empty ref fragment from a URL. Many pages 114 // Helper function to strip empty ref fragment from a URL. Many pages
117 // end up with a "#" at the end of their URLs due to navigation triggered by 115 // end up with a "#" at the end of their URLs due to navigation triggered by
118 // href="#" and javascript onclick function. We don't want to have separate 116 // href="#" and javascript onclick function. We don't want to have separate
119 // entries for these cases in the maps. 117 // entries for these cases in the maps.
120 static GURL ClearEmptyRef(const GURL& url); 118 static GURL ClearEmptyRef(const GURL& url);
121 119
122 // Checks if we should enable observing navigations for safe browsing purpose. 120 // Checks if we should enable observing navigations for safe browsing purpose.
123 // Return true if the safe browsing service and the |kDownloadAttribution| 121 // Return true if the safe browsing safe browsing service is enabled and
124 // feature are both enabled, and safe browsing service is initialized. 122 // initialized.
125 static bool IsEnabledAndReady(Profile* profile); 123 static bool IsEnabledAndReady(Profile* profile);
126 124
127 SafeBrowsingNavigationObserverManager(); 125 SafeBrowsingNavigationObserverManager();
128 126
129 // Adds |nav_event| to |navigation_event_list_|. Object pointed to by 127 // Adds |nav_event| to |navigation_event_list_|. Object pointed to by
130 // |nav_event| will be no longer accessible after this function. 128 // |nav_event| will be no longer accessible after this function.
131 void RecordNavigationEvent(std::unique_ptr<NavigationEvent> nav_event); 129 void RecordNavigationEvent(std::unique_ptr<NavigationEvent> nav_event);
132 void RecordUserGestureForWebContents(content::WebContents* web_contents, 130 void RecordUserGestureForWebContents(content::WebContents* web_contents,
133 const base::Time& timestamp); 131 const base::Time& timestamp);
134 void OnUserGestureConsumed(content::WebContents* web_contents, 132 void OnUserGestureConsumed(content::WebContents* web_contents,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // vector of ResolvedIPAddresss. 263 // vector of ResolvedIPAddresss.
266 HostToIpMap host_to_ip_map_; 264 HostToIpMap host_to_ip_map_;
267 265
268 base::OneShotTimer cleanup_timer_; 266 base::OneShotTimer cleanup_timer_;
269 267
270 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); 268 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager);
271 }; 269 };
272 } // namespace safe_browsing 270 } // namespace safe_browsing
273 271
274 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_ 272 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698