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

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

Issue 2724433002: Remove the retargeting notification (Closed)
Patch Set: Remove comments in safe browsing tests Created 3 years, 9 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 "chrome/common/safe_browsing/csd.pb.h" 11 #include "chrome/common/safe_browsing/csd.pb.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
15 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" 13 #include "third_party/protobuf/src/google/protobuf/repeated_field.h"
16 #include "url/gurl.h" 14 #include "url/gurl.h"
17 15
18 class Profile; 16 class Profile;
19 17
20 namespace safe_browsing { 18 namespace safe_browsing {
21 19
22 class SafeBrowsingNavigationObserver; 20 class SafeBrowsingNavigationObserver;
23 struct NavigationEvent; 21 struct NavigationEvent;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 85 }
88 86
89 private: 87 private:
90 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_; 88 std::deque<std::unique_ptr<NavigationEvent>> navigation_events_;
91 const std::size_t size_limit_; 89 const std::size_t size_limit_;
92 }; 90 };
93 91
94 // Manager class for SafeBrowsingNavigationObserver, which is in charge of 92 // Manager class for SafeBrowsingNavigationObserver, which is in charge of
95 // cleaning up stale navigation events, and identifying landing page/landing 93 // cleaning up stale navigation events, and identifying landing page/landing
96 // referrer for a specific download. 94 // referrer for a specific download.
97 // TODO(jialiul): For now, SafeBrowsingNavigationObserverManager also listens to
98 // NOTIFICATION_RETARGETING as a way to detect cross frame/tab navigation.
99 // Remove base class content::NotificationObserver when
100 // WebContentsObserver::DidOpenRequestedURL() covers all retargeting cases.
101 class SafeBrowsingNavigationObserverManager 95 class SafeBrowsingNavigationObserverManager
102 : public content::NotificationObserver, 96 : public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> {
103 public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> {
104 public: 97 public:
105 static const base::Feature kDownloadAttribution; 98 static const base::Feature kDownloadAttribution;
106 99
107 // For UMA histogram counting. Do NOT change order. 100 // For UMA histogram counting. Do NOT change order.
108 enum AttributionResult { 101 enum AttributionResult {
109 SUCCESS = 1, // Identified referrer chain is not empty. 102 SUCCESS = 1, // Identified referrer chain is not empty.
110 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page. 103 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page.
111 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer. 104 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer.
112 INVALID_URL = 4, 105 INVALID_URL = 4,
113 NAVIGATION_EVENT_NOT_FOUND = 5, 106 NAVIGATION_EVENT_NOT_FOUND = 5,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // these identified NavigationEvents into ReferrerChainEntrys and append them 175 // these identified NavigationEvents into ReferrerChainEntrys and append them
183 // to |out_referrer_chain|. 176 // to |out_referrer_chain|.
184 AttributionResult IdentifyReferrerChainForDownloadHostingPage( 177 AttributionResult IdentifyReferrerChainForDownloadHostingPage(
185 const GURL& initiating_frame_url, 178 const GURL& initiating_frame_url,
186 const GURL& initiating_main_frame_url, 179 const GURL& initiating_main_frame_url,
187 int tab_id, 180 int tab_id,
188 bool has_user_gesture, 181 bool has_user_gesture,
189 int user_gesture_count_limit, 182 int user_gesture_count_limit,
190 ReferrerChain* out_referrer_chain); 183 ReferrerChain* out_referrer_chain);
191 184
185 // Record the creation of a new WebContents by |source_web_contents|. This is
186 // used to detect cross-frame and cross-tab navigations.
187 void RecordNewWebContents(content::WebContents* source_web_contents,
188 int source_render_process_id,
189 int source_render_frame_id,
190 GURL target_url,
191 content::WebContents* target_web_contents,
192 bool not_yet_in_tabstrip);
193
192 private: 194 private:
193 friend class base::RefCountedThreadSafe< 195 friend class base::RefCountedThreadSafe<
194 SafeBrowsingNavigationObserverManager>; 196 SafeBrowsingNavigationObserverManager>;
195 friend class TestNavigationObserverManager; 197 friend class TestNavigationObserverManager;
196 friend class SBNavigationObserverBrowserTest; 198 friend class SBNavigationObserverBrowserTest;
197 friend class SBNavigationObserverTest; 199 friend class SBNavigationObserverTest;
198 200
199 struct GurlHash { 201 struct GurlHash {
200 std::size_t operator()(const GURL& url) const { 202 std::size_t operator()(const GURL& url) const {
201 return std::hash<std::string>()(url.spec()); 203 return std::hash<std::string>()(url.spec());
202 } 204 }
203 }; 205 };
204 206
205 typedef std::unordered_map<content::WebContents*, base::Time> UserGestureMap; 207 typedef std::unordered_map<content::WebContents*, base::Time> UserGestureMap;
206 typedef std::unordered_map<std::string, std::vector<ResolvedIPAddress>> 208 typedef std::unordered_map<std::string, std::vector<ResolvedIPAddress>>
207 HostToIpMap; 209 HostToIpMap;
208 210
209 ~SafeBrowsingNavigationObserverManager() override; 211 virtual ~SafeBrowsingNavigationObserverManager();
210
211 // content::NotificationObserver:
212 void Observe(int type,
213 const content::NotificationSource& source,
214 const content::NotificationDetails& details) override;
215
216 void RecordRetargeting(const content::NotificationDetails& details);
217 212
218 NavigationEventList* navigation_event_list() { 213 NavigationEventList* navigation_event_list() {
219 return &navigation_event_list_; 214 return &navigation_event_list_;
220 } 215 }
221 216
222 HostToIpMap* host_to_ip_map() { return &host_to_ip_map_; } 217 HostToIpMap* host_to_ip_map() { return &host_to_ip_map_; }
223 218
224 // Remove stale entries from navigation_event_list_ if they are older than 219 // Remove stale entries from navigation_event_list_ if they are older than
225 // kNavigationFootprintTTLInSecond (2 minutes). 220 // kNavigationFootprintTTLInSecond (2 minutes).
226 void CleanUpNavigationEvents(); 221 void CleanUpNavigationEvents();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // shortly after a user gesture indicate this navigation is user initiated. 259 // shortly after a user gesture indicate this navigation is user initiated.
265 UserGestureMap user_gesture_map_; 260 UserGestureMap user_gesture_map_;
266 261
267 // Host to timestamped IP addresses map that covers all the main frame and 262 // Host to timestamped IP addresses map that covers all the main frame and
268 // subframe URLs' hosts. Since it is possible for a host to resolve to more 263 // subframe URLs' hosts. Since it is possible for a host to resolve to more
269 // than one IP in even a short period of time, we map a single host to a 264 // than one IP in even a short period of time, we map a single host to a
270 // vector of ResolvedIPAddresss. This map is used to fill in ip_address field 265 // vector of ResolvedIPAddresss. This map is used to fill in ip_address field
271 // in URLChainEntry in ClientDownloadRequest. 266 // in URLChainEntry in ClientDownloadRequest.
272 HostToIpMap host_to_ip_map_; 267 HostToIpMap host_to_ip_map_;
273 268
274 content::NotificationRegistrar registrar_;
275
276 base::OneShotTimer cleanup_timer_; 269 base::OneShotTimer cleanup_timer_;
277 270
278 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); 271 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager);
279 }; 272 };
280 } // namespace safe_browsing 273 } // namespace safe_browsing
281 274
282 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_ 275 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698