Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_H_ | |
| 5 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_H_ | |
| 6 | |
| 7 #include "content/public/browser/navigation_handle.h" | |
| 8 #include "content/public/browser/notification_observer.h" | |
| 9 #include "content/public/browser/notification_registrar.h" | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 struct RetargetingDetails; | |
| 14 | |
| 15 namespace content { | |
| 16 class NavigationHandle; | |
| 17 class NotificationRegistrar; | |
| 18 class RenderFrameHost; | |
| 19 struct ResourceRedirectDetails; | |
| 20 } | |
| 21 | |
| 22 namespace safe_browsing { | |
| 23 | |
| 24 // Observes the navigation events that might lead to a download. | |
| 25 class SafeBrowsingNavigationObserver : public content::NotificationObserver, | |
| 26 public content::WebContentsObserver { | |
| 27 public: | |
| 28 struct NavigationEvent { | |
| 29 NavigationEvent(); | |
| 30 NavigationEvent(const GURL& source_url, | |
|
Nathan Parker
2016/09/03 00:21:35
Is there away to avoid the many-args-of-similar-ty
Jialiu Lin
2016/09/07 00:42:41
Agree. Removed this constructor.
| |
| 31 int source_tab_id, | |
| 32 const GURL& target_url, | |
| 33 int target_tab_id, | |
| 34 int frame_id, | |
| 35 const GURL& main_frame_url, | |
| 36 double timestamp, | |
| 37 bool has_user_gesture, | |
| 38 bool has_committed); | |
| 39 explicit NavigationEvent(const NavigationEvent& nav_event); | |
| 40 ~NavigationEvent(); | |
| 41 GURL source_url; | |
| 42 int source_tab_id; | |
| 43 | |
| 44 GURL target_url; | |
| 45 int target_tab_id; | |
| 46 | |
| 47 int frame_id; // Frame tree node id. | |
| 48 GURL main_frame_url; // Main frame url of the source. | |
| 49 | |
| 50 double timestamp; // Timestamp of last time this object is updated. | |
| 51 | |
| 52 bool is_user_initiated; | |
| 53 bool has_committed; | |
| 54 bool is_server_redirect; | |
|
Nathan Parker
2016/09/03 00:21:35
It's is possible for is_user_initiated and is_serv
Jialiu Lin
2016/09/07 00:42:41
Yes, it's possible. User clicks on a link (url_a),
| |
| 55 bool is_finished; | |
| 56 GURL server_redirect_url; | |
| 57 }; | |
| 58 | |
| 59 // NavigationMap keyed on target url. | |
| 60 typedef std::map<GURL, std::vector<NavigationEvent>> NavigationMap; | |
| 61 typedef std::map<content::NavigationHandle*, NavigationEvent> | |
|
Nathan Parker
2016/09/03 00:21:35
Who owns these pointers? Add a comment, or down be
Jialiu Lin
2016/09/07 00:42:41
done.
| |
| 62 NavigationHandleMap; | |
| 63 | |
| 64 SafeBrowsingNavigationObserver(); | |
| 65 | |
| 66 ~SafeBrowsingNavigationObserver() override; | |
| 67 | |
| 68 NavigationMap* navigation_map(); | |
| 69 | |
| 70 void ClearNavigationMap(); | |
| 71 | |
| 72 // TODO(jialiul): more functions coming for managing navigation_map_. | |
| 73 | |
| 74 protected: | |
| 75 void RecordNavigationPendingEntry( | |
| 76 const content::NotificationSource& source, | |
| 77 const content::NotificationDetails& details); | |
| 78 | |
| 79 void RecordRetargeting(const content::NotificationDetails& details); | |
|
Nathan Parker
2016/09/03 00:21:35
What does retargeting mean?
Jialiu Lin
2016/09/07 00:42:41
Retargeting means navigation triggered in one tab
| |
| 80 | |
| 81 // content::NotificationObserver: | |
| 82 void Observe(int type, | |
| 83 const content::NotificationSource& source, | |
| 84 const content::NotificationDetails& details) override; | |
| 85 | |
| 86 // content::WebContentsObserver: | |
| 87 void DidStartNavigation( | |
| 88 content::NavigationHandle* navigation_handle) override; | |
| 89 | |
| 90 void DidRedirectNavigation( | |
| 91 content::NavigationHandle* navigation_handle) override; | |
| 92 | |
| 93 void DidFinishNavigation( | |
| 94 content::NavigationHandle* navigation_handle) override; | |
| 95 | |
| 96 NavigationHandleMap navigation_handle_map_; | |
|
Nathan Parker
2016/09/03 00:21:35
Add some comments on what these are used for, or h
Jialiu Lin
2016/09/07 00:42:41
done.
| |
| 97 content::NotificationRegistrar registrar_; | |
| 98 NavigationMap navigation_map_; | |
| 99 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserver); | |
| 100 }; | |
| 101 | |
| 102 } // namespace safe_browsing | |
| 103 | |
| 104 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_H_ | |
| OLD | NEW |