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

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

Issue 2601303002: Wireup SafeBrowsingNavigationObserverManager to help PPAPI download attribution (Closed)
Patch Set: nit 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Remove all the observed NavigationEvents, user gestures, and resolved IP 78 // Remove all the observed NavigationEvents, user gestures, and resolved IP
79 // addresses that are older than kNavigationFootprintTTLInSecond. 79 // addresses that are older than kNavigationFootprintTTLInSecond.
80 void CleanUpStaleNavigationFootprints(); 80 void CleanUpStaleNavigationFootprints();
81 81
82 // Based on the |target_url| and |target_tab_id|, trace back the observed 82 // Based on the |target_url| and |target_tab_id|, trace back the observed
83 // NavigationEvents in navigation_map_ to identify the sequence of navigations 83 // NavigationEvents in navigation_map_ to identify the sequence of navigations
84 // leading to the target, with the coverage limited to 84 // leading to the target, with the coverage limited to
85 // |user_gesture_count_limit| number of user gestures. Then convert these 85 // |user_gesture_count_limit| number of user gestures. Then convert these
86 // identified NavigationEvents into ReferrerChainEntrys and append them to 86 // identified NavigationEvents into ReferrerChainEntrys and append them to
87 // |out_referrer_chain|. 87 // |out_referrer_chain|.
88 AttributionResult IdentifyReferrerChain( 88 AttributionResult IdentifyReferrerChainForDownload(
89 const GURL& target_url, 89 const GURL& target_url,
90 int target_tab_id, // -1 if tab id is not valid 90 int target_tab_id, // -1 if tab id is not valid
91 int user_gesture_count_limit, 91 int user_gesture_count_limit,
92 std::vector<ReferrerChainEntry>* out_referrer_chain); 92 std::vector<ReferrerChainEntry>* out_referrer_chain);
93 93
94 // Based on the |initiating_frame_url| and its associated |web_contents|,
95 // trace back the observed NavigationEvents in navigation_map_ to identify the
96 // sequence of navigations leading to this |initiating_frame_url|. If this
97 // initiating frame has a user gesture, we trace back with the coverage
98 // limited to |user_gesture_count_limit|-1 number of user gestures, otherwise
99 // we trace back |user_gesture_count_limit| number of user gestures. We then
100 // convert these identified NavigationEvents into ReferrerChainEntrys and
101 // append them to |out_referrer_chain|.
102 AttributionResult IdentifyReferrerChainForPPAPIDownload(
103 const GURL& initiating_frame_url,
104 content::WebContents* web_contents,
105 int user_gesture_count_limit,
106 std::vector<ReferrerChainEntry>* out_referrer_chain);
107
94 private: 108 private:
95 friend class base::RefCountedThreadSafe< 109 friend class base::RefCountedThreadSafe<
96 SafeBrowsingNavigationObserverManager>; 110 SafeBrowsingNavigationObserverManager>;
97 friend class TestNavigationObserverManager; 111 friend class TestNavigationObserverManager;
98 friend class SBNavigationObserverBrowserTest; 112 friend class SBNavigationObserverBrowserTest;
99 friend class SBNavigationObserverTest; 113 friend class SBNavigationObserverTest;
100 114
101 struct GurlHash { 115 struct GurlHash {
102 std::size_t operator()(const GURL& url) const { 116 std::size_t operator()(const GURL& url) const {
103 return std::hash<std::string>()(url.spec()); 117 return std::hash<std::string>()(url.spec());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // referrer of about::blank in Window C since this navigation is more recent. 169 // 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 170 // However, it does not prevent us to attribute url1 in Window A as the cause
157 // of all these navigations. 171 // of all these navigations.
158 NavigationEvent* FindNavigationEvent(const GURL& target_url, 172 NavigationEvent* FindNavigationEvent(const GURL& target_url,
159 int target_tab_id); 173 int target_tab_id);
160 174
161 void AddToReferrerChain(std::vector<ReferrerChainEntry>* referrer_chain, 175 void AddToReferrerChain(std::vector<ReferrerChainEntry>* referrer_chain,
162 NavigationEvent* nav_event, 176 NavigationEvent* nav_event,
163 ReferrerChainEntry::URLType type); 177 ReferrerChainEntry::URLType type);
164 178
179 // Helper function to get the remaining referrer chain when we've already
180 // traced back |current_user_gesture_count| number of user gestures.
181 // This function modifies the |out_referrer_chain| and |out_result|.
182 void GetRemainingReferrerChain(
183 NavigationEvent* last_nav_event_traced,
184 int current_user_gesture_count,
185 int user_gesture_count_limit,
186 std::vector<ReferrerChainEntry>* out_referrer_chain,
187 AttributionResult* out_result);
188
165 // navigation_map_ keeps track of all the observed navigations. This map is 189 // 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 190 // 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 191 // 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 192 // 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 193 // across different tabs and frames, the value of this map is a vector of
170 // NavigationEvent ordered by navigation finish time. 194 // NavigationEvent ordered by navigation finish time.
171 // TODO(jialiul): Entries in navigation_map_ will be removed if they are older 195 // TODO(jialiul): Entries in navigation_map_ will be removed if they are older
172 // than 2 minutes since their corresponding navigations finish. 196 // than 2 minutes since their corresponding navigations finish.
173 NavigationMap navigation_map_; 197 NavigationMap navigation_map_;
174 198
(...skipping 11 matching lines...) Expand all
186 210
187 content::NotificationRegistrar registrar_; 211 content::NotificationRegistrar registrar_;
188 212
189 base::OneShotTimer cleanup_timer_; 213 base::OneShotTimer cleanup_timer_;
190 214
191 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); 215 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager);
192 }; 216 };
193 } // namespace safe_browsing 217 } // namespace safe_browsing
194 218
195 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_ 219 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698