| OLD | NEW |
| 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 "base/supports_user_data.h" |
| 9 #include "chrome/common/safe_browsing/csd.pb.h" | 10 #include "chrome/common/safe_browsing/csd.pb.h" |
| 10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 14 | 16 |
| 15 class Profile; | 17 class Profile; |
| 16 | 18 |
| 17 namespace safe_browsing { | 19 namespace safe_browsing { |
| 18 | 20 |
| 19 class SafeBrowsingNavigationObserver; | 21 class SafeBrowsingNavigationObserver; |
| 20 struct NavigationEvent; | 22 struct NavigationEvent; |
| 21 struct ResolvedIPAddress; | 23 struct ResolvedIPAddress; |
| 22 | 24 |
| 25 typedef google::protobuf::RepeatedPtrField<safe_browsing::ReferrerChainEntry> |
| 26 ReferrerChain; |
| 27 |
| 28 // User data stored in DownloadItem for referrer chain information. |
| 29 class ReferrerChainData : public base::SupportsUserData::Data { |
| 30 public: |
| 31 explicit ReferrerChainData(std::unique_ptr<ReferrerChain> referrer_chain); |
| 32 ~ReferrerChainData() override; |
| 33 ReferrerChain* GetReferrerChain(); |
| 34 |
| 35 private: |
| 36 std::unique_ptr<ReferrerChain> referrer_chain_; |
| 37 }; |
| 38 |
| 23 // Manager class for SafeBrowsingNavigationObserver, which is in charge of | 39 // Manager class for SafeBrowsingNavigationObserver, which is in charge of |
| 24 // cleaning up stale navigation events, and identifying landing page/landing | 40 // cleaning up stale navigation events, and identifying landing page/landing |
| 25 // referrer for a specific download. | 41 // referrer for a specific download. |
| 26 // TODO(jialiul): For now, SafeBrowsingNavigationObserverManager also listens to | 42 // TODO(jialiul): For now, SafeBrowsingNavigationObserverManager also listens to |
| 27 // NOTIFICATION_RETARGETING as a way to detect cross frame/tab navigation. | 43 // NOTIFICATION_RETARGETING as a way to detect cross frame/tab navigation. |
| 28 // Remove base class content::NotificationObserver when | 44 // Remove base class content::NotificationObserver when |
| 29 // WebContentsObserver::DidOpenRequestedURL() covers all retargeting cases. | 45 // WebContentsObserver::DidOpenRequestedURL() covers all retargeting cases. |
| 30 class SafeBrowsingNavigationObserverManager | 46 class SafeBrowsingNavigationObserverManager |
| 31 : public content::NotificationObserver, | 47 : public content::NotificationObserver, |
| 32 public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> { | 48 public base::RefCountedThreadSafe<SafeBrowsingNavigationObserverManager> { |
| 33 public: | 49 public: |
| 34 static const base::Feature kDownloadAttribution; | 50 static const base::Feature kDownloadAttribution; |
| 35 typedef std::vector<std::unique_ptr<ReferrerChainEntry>> ReferrerChain; | |
| 36 | 51 |
| 37 // For UMA histogram counting. Do NOT change order. | 52 // For UMA histogram counting. Do NOT change order. |
| 38 enum AttributionResult { | 53 enum AttributionResult { |
| 39 SUCCESS = 1, // Identified referrer chain is not empty. | 54 SUCCESS = 1, // Identified referrer chain is not empty. |
| 40 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page. | 55 SUCCESS_LANDING_PAGE = 2, // Successfully identified landing page. |
| 41 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer. | 56 SUCCESS_LANDING_REFERRER = 3, // Successfully identified landing referrer. |
| 42 INVALID_URL = 4, | 57 INVALID_URL = 4, |
| 43 NAVIGATION_EVENT_NOT_FOUND = 5, | 58 NAVIGATION_EVENT_NOT_FOUND = 5, |
| 44 | 59 |
| 45 // Always at the end. | 60 // Always at the end. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 233 |
| 219 content::NotificationRegistrar registrar_; | 234 content::NotificationRegistrar registrar_; |
| 220 | 235 |
| 221 base::OneShotTimer cleanup_timer_; | 236 base::OneShotTimer cleanup_timer_; |
| 222 | 237 |
| 223 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); | 238 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingNavigationObserverManager); |
| 224 }; | 239 }; |
| 225 } // namespace safe_browsing | 240 } // namespace safe_browsing |
| 226 | 241 |
| 227 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE
R_H_ | 242 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_NAVIGATION_OBSERVER_MANAGE
R_H_ |
| OLD | NEW |