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

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

Issue 2612663002: Use main frame URL to identify referrer if sub-frame url is not available (Closed)
Patch Set: address comments from nparker@ Created 3 years, 11 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 "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "chrome/common/safe_browsing/csd.pb.h" 9 #include "chrome/common/safe_browsing/csd.pb.h"
10 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void CleanUpUserGestures(); 132 void CleanUpUserGestures();
133 133
134 // Remove stale entries from host_to_ip_map_ if they are older than 134 // Remove stale entries from host_to_ip_map_ if they are older than
135 // kNavigationFootprintTTLInSecond (2 minutes). 135 // kNavigationFootprintTTLInSecond (2 minutes).
136 void CleanUpIpAddresses(); 136 void CleanUpIpAddresses();
137 137
138 bool IsCleanUpScheduled() const; 138 bool IsCleanUpScheduled() const;
139 139
140 void ScheduleNextCleanUpAfterInterval(base::TimeDelta interval); 140 void ScheduleNextCleanUpAfterInterval(base::TimeDelta interval);
141 141
142 // Find the most recent navigation event that navigated to |target_url| in the 142 // Find the most recent navigation event that navigated to |target_url| and
143 // tab with ID |target_tab_id|. If |target_tab_id| is not available (-1), we 143 // its associated |target_main_frame_url| in the tab with ID |target_tab_id|.
144 // look for all tabs for the most recent navigation to |target_url|. 144 // If navigation happened in the main frame, |target_url| and |target_main_
145 // frame_url| are the same.
146 // If |target_url| is empty, we use its main frame url (a.k.a.
147 // |target_main_frame_url|) to search for navigation events.
148 // If |target_tab_id| is not available (-1), we look for all tabs for the most
149 // recent navigation to |target_url| or |target_main_frame_url|.
145 // For some cases, the most recent navigation to |target_url| may not be 150 // For some cases, the most recent navigation to |target_url| may not be
146 // relevant. 151 // relevant.
147 // For example, url1 in window A opens url2 in window B, url1 then opens an 152 // For example, url1 in window A opens url2 in window B, url1 then opens an
148 // about:blank page window C and injects script code in it to trigger a 153 // about:blank page window C and injects script code in it to trigger a
149 // delayed download in Window D. Before the download occurs, url2 in window B 154 // delayed download in Window D. Before the download occurs, url2 in window B
150 // opens a different about:blank page in window C. 155 // opens a different about:blank page in window C.
151 // A ---- C - D 156 // A ---- C - D
152 // \ / 157 // \ /
153 // B 158 // B
154 // In this case, FindNavigationEvent() will think url2 in Window B is the 159 // In this case, FindNavigationEvent() will think url2 in Window B is the
155 // referrer of about::blank in Window C since this navigation is more recent. 160 // referrer of about::blank in Window C since this navigation is more recent.
156 // However, it does not prevent us to attribute url1 in Window A as the cause 161 // However, it does not prevent us to attribute url1 in Window A as the cause
157 // of all these navigations. 162 // of all these navigations.
158 NavigationEvent* FindNavigationEvent(const GURL& target_url, 163 NavigationEvent* FindNavigationEvent(const GURL& target_url,
164 const GURL& target_main_frame_url,
159 int target_tab_id); 165 int target_tab_id);
160 166
161 void AddToReferrerChain(std::vector<ReferrerChainEntry>* referrer_chain, 167 void AddToReferrerChain(std::vector<ReferrerChainEntry>* referrer_chain,
162 NavigationEvent* nav_event, 168 NavigationEvent* nav_event,
163 ReferrerChainEntry::URLType type); 169 ReferrerChainEntry::URLType type);
164 170
165 // navigation_map_ keeps track of all the observed navigations. This map is 171 // navigation_map_ keeps track of all the observed navigations. This map is
166 // keyed on the resolved request url. In other words, in case of server 172 // keyed on the resolved request url. In other words, in case of server
167 // redirects, its key is the last server redirect url, otherwise, it is the 173 // redirects, its key is the last server redirect url, otherwise, it is the
168 // original target url. Since the same url can be requested multiple times 174 // original target url. Since the same url can be requested multiple times
169 // across different tabs and frames, the value of this map is a vector of 175 // across different tabs and frames, the value of this map is a vector of
170 // NavigationEvent ordered by navigation finish time. 176 // NavigationEvent ordered by navigation finish time.
171 // TODO(jialiul): Entries in navigation_map_ will be removed if they are older 177 // Entries in navigation_map_ will be removed if they are older than 2 minutes
172 // than 2 minutes since their corresponding navigations finish. 178 // since their corresponding navigations finish.
173 NavigationMap navigation_map_; 179 NavigationMap navigation_map_;
174 180
175 // user_gesture_map_ keeps track of the timestamp of last user gesture in 181 // user_gesture_map_ keeps track of the timestamp of last user gesture in
176 // in each WebContents. We assume for majority of cases, a navigation 182 // in each WebContents. We assume for majority of cases, a navigation
177 // shortly after a user gesture indicate this navigation is user initiated. 183 // shortly after a user gesture indicate this navigation is user initiated.
178 UserGestureMap user_gesture_map_; 184 UserGestureMap user_gesture_map_;
179 185
180 // Host to timestamped IP addresses map that covers all the main frame and 186 // Host to timestamped IP addresses map that covers all the main frame and
181 // subframe URLs' hosts. Since it is possible for a host to resolve to more 187 // subframe URLs' hosts. Since it is possible for a host to resolve to more
182 // than one IP in even a short period of time, we map a single host to a 188 // than one IP in even a short period of time, we map a single host to a
183 // vector of ResolvedIPAddresss. This map is used to fill in ip_address field 189 // vector of ResolvedIPAddresss. This map is used to fill in ip_address field
184 // in URLChainEntry in ClientDownloadRequest. 190 // in URLChainEntry in ClientDownloadRequest.
185 HostToIpMap host_to_ip_map_; 191 HostToIpMap host_to_ip_map_;
186 192
187 content::NotificationRegistrar registrar_; 193 content::NotificationRegistrar registrar_;
188 194
189 base::OneShotTimer cleanup_timer_; 195 base::OneShotTimer cleanup_timer_;
190 196
191 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); 197 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager);
192 }; 198 };
193 } // namespace safe_browsing 199 } // namespace safe_browsing
194 200
195 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_ 201 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698