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

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

Issue 2821163002: Clean up DownloadAttribution Finch experiments (Closed)
Patch Set: nits Created 3 years, 8 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"
11 #include "components/safe_browsing/csd.pb.h" 11 #include "components/safe_browsing/csd.pb.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" 13 #include "third_party/protobuf/src/google/protobuf/repeated_field.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 class Profile;
17
18 namespace safe_browsing { 16 namespace safe_browsing {
19 17
20 class SafeBrowsingNavigationObserver; 18 class SafeBrowsingNavigationObserver;
21 struct NavigationEvent; 19 struct NavigationEvent;
22 struct ResolvedIPAddress; 20 struct ResolvedIPAddress;
23 21
24 typedef google::protobuf::RepeatedPtrField<safe_browsing::ReferrerChainEntry> 22 typedef google::protobuf::RepeatedPtrField<safe_browsing::ReferrerChainEntry>
25 ReferrerChain; 23 ReferrerChain;
26 24
27 // User data stored in DownloadItem for referrer chain information. 25 // User data stored in DownloadItem for referrer chain information.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_; 86 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_;
89 const std::size_t size_limit_; 87 const std::size_t size_limit_;
90 }; 88 };
91 89
92 // Manager class for SafeBrowsingNavigationObserver, which is in charge of 90 // Manager class for SafeBrowsingNavigationObserver, which is in charge of
93 // cleaning up stale navigation events, and identifying landing page/landing 91 // cleaning up stale navigation events, and identifying landing page/landing
94 // referrer for a specific Safe Browsing event. 92 // referrer for a specific Safe Browsing event.
95 class SafeBrowsingNavigationObserverManager 93 class SafeBrowsingNavigationObserverManager
96 : public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> { 94 : public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> {
97 public: 95 public:
98 static const base::Feature kDownloadAttribution;
99
100 // For UMA histogram counting. Do NOT change order. 96 // For UMA histogram counting. Do NOT change order.
101 enum AttributionResult { 97 enum AttributionResult {
102 SUCCESS = 1, // Identified referrer chain is not empty. 98 SUCCESS = 1, // Identified referrer chain is not empty.
103 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page. 99 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page.
104 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer. 100 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer.
105 INVALID_URL = 4, 101 INVALID_URL = 4,
106 NAVIGATION_EVENT_NOT_FOUND = 5, 102 NAVIGATION_EVENT_NOT_FOUND = 5,
107 103
108 // Always at the end. 104 // Always at the end.
109 ATTRIBUTION_FAILURE_TYPE_MAX 105 ATTRIBUTION_FAILURE_TYPE_MAX
110 }; 106 };
111 107
112 // Helper function to check if user gesture is older than 108 // Helper function to check if user gesture is older than
113 // kUserGestureTTLInSecond. 109 // kUserGestureTTLInSecond.
114 static bool IsUserGestureExpired(const base::Time& timestamp); 110 static bool IsUserGestureExpired(const base::Time& timestamp);
115 111
116 // Helper function to strip empty ref fragment from a URL. Many pages 112 // 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 113 // 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 114 // href="#" and javascript onclick function. We don't want to have separate
119 // entries for these cases in the maps. 115 // entries for these cases in the maps.
120 static GURL ClearEmptyRef(const GURL& url); 116 static GURL ClearEmptyRef(const GURL& url);
121 117
122 // Checks if we should enable observing navigations for safe browsing purpose. 118 // Checks if we should enable observing navigations for safe browsing purpose.
123 // Return true if the safe browsing service and the |kDownloadAttribution| 119 // Return true if the safe browsing safe browsing service is enabled and
124 // feature are both enabled, and safe browsing service is initialized. 120 // initialized.
125 static bool IsEnabledAndReady(Profile* profile); 121 static bool IsEnabledAndReady(content::WebContents* web_contents);
126 122
127 SafeBrowsingNavigationObserverManager(); 123 SafeBrowsingNavigationObserverManager();
128 124
129 // Adds |nav_event| to |navigation_event_list_|. Object pointed to by 125 // Adds |nav_event| to |navigation_event_list_|. Object pointed to by
130 // |nav_event| will be no longer accessible after this function. 126 // |nav_event| will be no longer accessible after this function.
131 void RecordNavigationEvent(std::unique_ptr<NavigationEvent> nav_event); 127 void RecordNavigationEvent(std::unique_ptr<NavigationEvent> nav_event);
132 void RecordUserGestureForWebContents(content::WebContents* web_contents, 128 void RecordUserGestureForWebContents(content::WebContents* web_contents,
133 const base::Time& timestamp); 129 const base::Time& timestamp);
134 void OnUserGestureConsumed(content::WebContents* web_contents, 130 void OnUserGestureConsumed(content::WebContents* web_contents,
135 const base::Time& timestamp); 131 const base::Time& timestamp);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // vector of ResolvedIPAddresss. 261 // vector of ResolvedIPAddresss.
266 HostToIpMap host_to_ip_map_; 262 HostToIpMap host_to_ip_map_;
267 263
268 base::OneShotTimer cleanup_timer_; 264 base::OneShotTimer cleanup_timer_;
269 265
270 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); 266 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager);
271 }; 267 };
272 } // namespace safe_browsing 268 } // namespace safe_browsing
273 269
274 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_ 270 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698