Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_THREAT_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ |
| 7 | 7 |
| 8 // A class that encapsulates the detailed threat reports sent when | 8 // A class that encapsulates the detailed threat reports sent when |
| 9 // users opt-in to do so from the safe browsing warning page. | 9 // users opt-in to do so from the safe browsing warning page. |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "chrome/browser/safe_browsing/ui_manager.h" | 23 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 24 #include "chrome/common/safe_browsing/csd.pb.h" | 24 #include "chrome/common/safe_browsing/csd.pb.h" |
| 25 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
| 26 #include "net/base/completion_callback.h" | 26 #include "net/base/completion_callback.h" |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 class URLRequestContextGetter; | 29 class URLRequestContextGetter; |
| 30 } | 30 } |
| 31 | 31 |
| 32 class ThreatDetailsCacheCollector; | |
| 33 class ThreatDetailsRedirectsCollector; | |
| 34 class ThreatDetailsFactory; | |
| 35 class Profile; | 32 class Profile; |
| 36 struct SafeBrowsingHostMsg_ThreatDOMDetails_Node; | 33 struct SafeBrowsingHostMsg_ThreatDOMDetails_Node; |
| 37 | 34 |
| 38 namespace safe_browsing { | 35 namespace safe_browsing { |
| 36 | |
| 39 // Maps a URL to its Resource. | 37 // Maps a URL to its Resource. |
| 38 class ThreatDetailsCacheCollector; | |
| 39 class ThreatDetailsRedirectsCollector; | |
| 40 class ThreatDetailsFactory; | |
| 41 | |
| 40 typedef base::hash_map< | 42 typedef base::hash_map< |
| 41 std::string, | 43 std::string, |
| 42 linked_ptr<safe_browsing::ClientSafeBrowsingReportRequest::Resource>> | 44 linked_ptr<ClientSafeBrowsingReportRequest::Resource>> |
| 43 ResourceMap; | 45 ResourceMap; |
| 44 } | |
| 45 | 46 |
| 46 class ThreatDetails : public base::RefCountedThreadSafe<ThreatDetails>, | 47 class ThreatDetails : public base::RefCountedThreadSafe<ThreatDetails>, |
| 47 public content::WebContentsObserver { | 48 public content::WebContentsObserver { |
| 48 public: | 49 public: |
| 49 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 50 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; |
| 50 | 51 |
| 51 // Constructs a new ThreatDetails instance, using the factory. | 52 // Constructs a new ThreatDetails instance, using the factory. |
| 52 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager, | 53 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager, |
| 53 content::WebContents* web_contents, | 54 content::WebContents* web_contents, |
| 54 const UnsafeResource& resource); | 55 const UnsafeResource& resource); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 83 | 84 |
| 84 ~ThreatDetails() override; | 85 ~ThreatDetails() override; |
| 85 | 86 |
| 86 // Called on the IO thread with the DOM details. | 87 // Called on the IO thread with the DOM details. |
| 87 virtual void AddDOMDetails( | 88 virtual void AddDOMDetails( |
| 88 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); | 89 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); |
| 89 | 90 |
| 90 Profile* profile_; | 91 Profile* profile_; |
| 91 | 92 |
| 92 // The report protocol buffer. | 93 // The report protocol buffer. |
| 93 scoped_ptr<safe_browsing::ClientSafeBrowsingReportRequest> report_; | 94 scoped_ptr<safe_browsing::ClientSafeBrowsingReportRequest> report_; |
|
mattm
2015/11/12 00:36:06
more safe_browsing:: that could be removed in this
vakh (old account. dont use)
2015/11/12 09:27:43
Done.
| |
| 94 | 95 |
| 95 // Used to get a pointer to the HTTP cache. | 96 // Used to get a pointer to the HTTP cache. |
| 96 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 97 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 friend class base::RefCountedThreadSafe<ThreatDetails>; | 100 friend class base::RefCountedThreadSafe<ThreatDetails>; |
| 100 | 101 |
| 101 // Starts the collection of the report. | 102 // Starts the collection of the report. |
| 102 void StartCollection(); | 103 void StartCollection(); |
| 103 | 104 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 122 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); | 123 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); |
| 123 | 124 |
| 124 void AddRedirectUrlList(const std::vector<GURL>& urls); | 125 void AddRedirectUrlList(const std::vector<GURL>& urls); |
| 125 | 126 |
| 126 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 127 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 127 | 128 |
| 128 const UnsafeResource resource_; | 129 const UnsafeResource resource_; |
| 129 | 130 |
| 130 // For every Url we collect we create a Resource message. We keep | 131 // For every Url we collect we create a Resource message. We keep |
| 131 // them in a map so we can avoid duplicates. | 132 // them in a map so we can avoid duplicates. |
| 132 safe_browsing::ResourceMap resources_; | 133 ResourceMap resources_; |
| 133 | 134 |
| 134 // Result from the cache extractor. | 135 // Result from the cache extractor. |
| 135 bool cache_result_; | 136 bool cache_result_; |
| 136 | 137 |
| 137 // Whether user did proceed with the safe browsing blocking page or | 138 // Whether user did proceed with the safe browsing blocking page or |
| 138 // not. | 139 // not. |
| 139 bool did_proceed_; | 140 bool did_proceed_; |
| 140 | 141 |
| 141 // How many times this user has visited this page before. | 142 // How many times this user has visited this page before. |
| 142 int num_visits_; | 143 int num_visits_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 164 class ThreatDetailsFactory { | 165 class ThreatDetailsFactory { |
| 165 public: | 166 public: |
| 166 virtual ~ThreatDetailsFactory() {} | 167 virtual ~ThreatDetailsFactory() {} |
| 167 | 168 |
| 168 virtual ThreatDetails* CreateThreatDetails( | 169 virtual ThreatDetails* CreateThreatDetails( |
| 169 SafeBrowsingUIManager* ui_manager, | 170 SafeBrowsingUIManager* ui_manager, |
| 170 content::WebContents* web_contents, | 171 content::WebContents* web_contents, |
| 171 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; | 172 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; |
| 172 }; | 173 }; |
| 173 | 174 |
| 175 } // namespace safe_browsing | |
| 176 | |
| 174 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 177 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ |
| OLD | NEW |