| 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_MALWARE_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // A class that encapsulates the detailed malware reports sent when | 9 // A class that encapsulates the detailed malware reports sent when |
| 10 // users opt-in to do so from the malware warning page. | 10 // users opt-in to do so from the malware warning page. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 std::string, | 37 std::string, |
| 38 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap; | 38 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>, | 41 class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>, |
| 42 public content::WebContentsObserver { | 42 public content::WebContentsObserver { |
| 43 public: | 43 public: |
| 44 // Constructs a new MalwareDetails instance, using the factory. | 44 // Constructs a new MalwareDetails instance, using the factory. |
| 45 static MalwareDetails* NewMalwareDetails( | 45 static MalwareDetails* NewMalwareDetails( |
| 46 SafeBrowsingService* sb_service, | 46 SafeBrowsingService* sb_service, |
| 47 TabContents* tab_contents, | 47 content::WebContents* web_contents, |
| 48 const SafeBrowsingService::UnsafeResource& resource); | 48 const SafeBrowsingService::UnsafeResource& resource); |
| 49 | 49 |
| 50 // Makes the passed |factory| the factory used to instanciate | 50 // Makes the passed |factory| the factory used to instanciate |
| 51 // SafeBrowsingBlockingPage objects. Useful for tests. | 51 // SafeBrowsingBlockingPage objects. Useful for tests. |
| 52 static void RegisterFactory(MalwareDetailsFactory* factory) { | 52 static void RegisterFactory(MalwareDetailsFactory* factory) { |
| 53 factory_ = factory; | 53 factory_ = factory; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // The SafeBrowsingBlockingPage calls this from the IO thread when | 56 // The SafeBrowsingBlockingPage calls this from the IO thread when |
| 57 // the user is leaving the blocking page and has opted-in to sending | 57 // the user is leaving the blocking page and has opted-in to sending |
| 58 // the report. We start the redirection urls collection from history service | 58 // the report. We start the redirection urls collection from history service |
| 59 // in UI thread; then do cache collection back in IO thread. | 59 // in UI thread; then do cache collection back in IO thread. |
| 60 // When we are done, we send the report. | 60 // When we are done, we send the report. |
| 61 void FinishCollection(); | 61 void FinishCollection(); |
| 62 | 62 |
| 63 void OnCacheCollectionReady(); | 63 void OnCacheCollectionReady(); |
| 64 | 64 |
| 65 void OnRedirectionCollectionReady(); | 65 void OnRedirectionCollectionReady(); |
| 66 | 66 |
| 67 // content::WebContentsObserver implementation. | 67 // content::WebContentsObserver implementation. |
| 68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 friend class MalwareDetailsFactoryImpl; | 71 friend class MalwareDetailsFactoryImpl; |
| 72 | 72 |
| 73 MalwareDetails(SafeBrowsingService* sb_service, | 73 MalwareDetails(SafeBrowsingService* sb_service, |
| 74 TabContents* tab_contents, | 74 content::WebContents* web_contents, |
| 75 const SafeBrowsingService::UnsafeResource& resource); | 75 const SafeBrowsingService::UnsafeResource& resource); |
| 76 | 76 |
| 77 virtual ~MalwareDetails(); | 77 virtual ~MalwareDetails(); |
| 78 | 78 |
| 79 // Called on the IO thread with the DOM details. | 79 // Called on the IO thread with the DOM details. |
| 80 virtual void AddDOMDetails( | 80 virtual void AddDOMDetails( |
| 81 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params); | 81 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params); |
| 82 | 82 |
| 83 Profile* profile_; | 83 Profile* profile_; |
| 84 | 84 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 DISALLOW_COPY_AND_ASSIGN(MalwareDetails); | 146 DISALLOW_COPY_AND_ASSIGN(MalwareDetails); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // Factory for creating MalwareDetails. Useful for tests. | 149 // Factory for creating MalwareDetails. Useful for tests. |
| 150 class MalwareDetailsFactory { | 150 class MalwareDetailsFactory { |
| 151 public: | 151 public: |
| 152 virtual ~MalwareDetailsFactory() { } | 152 virtual ~MalwareDetailsFactory() { } |
| 153 | 153 |
| 154 virtual MalwareDetails* CreateMalwareDetails( | 154 virtual MalwareDetails* CreateMalwareDetails( |
| 155 SafeBrowsingService* sb_service, | 155 SafeBrowsingService* sb_service, |
| 156 TabContents* tab_contents, | 156 content::WebContents* web_contents, |
| 157 const SafeBrowsingService::UnsafeResource& unsafe_resource) = 0; | 157 const SafeBrowsingService::UnsafeResource& unsafe_resource) = 0; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ | 160 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| OLD | NEW |