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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 ResourceMap; | 46 ResourceMap; |
47 | 47 |
48 class ThreatDetails : public base::RefCountedThreadSafe< | 48 class ThreatDetails : public base::RefCountedThreadSafe< |
49 ThreatDetails, | 49 ThreatDetails, |
50 content::BrowserThread::DeleteOnUIThread>, | 50 content::BrowserThread::DeleteOnUIThread>, |
51 public content::WebContentsObserver { | 51 public content::WebContentsObserver { |
52 public: | 52 public: |
53 typedef security_interstitials::UnsafeResource UnsafeResource; | 53 typedef security_interstitials::UnsafeResource UnsafeResource; |
54 | 54 |
55 // Constructs a new ThreatDetails instance, using the factory. | 55 // Constructs a new ThreatDetails instance, using the factory. |
56 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager, | 56 static ThreatDetails* NewThreatDetails(BaseUIManager* ui_manager, |
57 content::WebContents* web_contents, | 57 content::WebContents* web_contents, |
58 const UnsafeResource& resource); | 58 const UnsafeResource& resource); |
59 | 59 |
60 // Makes the passed |factory| the factory used to instanciate | 60 // Makes the passed |factory| the factory used to instanciate |
61 // SafeBrowsingBlockingPage objects. Useful for tests. | 61 // SafeBrowsingBlockingPage objects. Useful for tests. |
62 static void RegisterFactory(ThreatDetailsFactory* factory) { | 62 static void RegisterFactory(ThreatDetailsFactory* factory) { |
63 factory_ = factory; | 63 factory_ = factory; |
64 } | 64 } |
65 | 65 |
66 // The SafeBrowsingBlockingPage calls this from the IO thread when | 66 // The SafeBrowsingBlockingPage calls this from the IO thread when |
67 // the user is leaving the blocking page and has opted-in to sending | 67 // the user is leaving the blocking page and has opted-in to sending |
68 // the report. We start the redirection urls collection from history service | 68 // the report. We start the redirection urls collection from history service |
69 // in UI thread; then do cache collection back in IO thread. We also record | 69 // in UI thread; then do cache collection back in IO thread. We also record |
70 // if the user did proceed with the warning page, and how many times user | 70 // if the user did proceed with the warning page, and how many times user |
71 // visited this page before. When we are done, we send the report. | 71 // visited this page before. When we are done, we send the report. |
72 void FinishCollection(bool did_proceed, int num_visits); | 72 void FinishCollection(bool did_proceed, int num_visits); |
73 | 73 |
74 void OnCacheCollectionReady(); | 74 void OnCacheCollectionReady(); |
75 | 75 |
76 void OnRedirectionCollectionReady(); | 76 void OnRedirectionCollectionReady(); |
77 | 77 |
78 // content::WebContentsObserver implementation. | 78 // content::WebContentsObserver implementation. |
79 bool OnMessageReceived(const IPC::Message& message, | 79 bool OnMessageReceived(const IPC::Message& message, |
80 content::RenderFrameHost* render_frame_host) override; | 80 content::RenderFrameHost* render_frame_host) override; |
81 | 81 |
82 protected: | 82 protected: |
83 friend class ThreatDetailsFactoryImpl; | 83 friend class ThreatDetailsFactoryImpl; |
84 friend class TestThreatDetailsFactory; | 84 friend class TestThreatDetailsFactory; |
85 | 85 |
86 ThreatDetails(SafeBrowsingUIManager* ui_manager, | 86 ThreatDetails(BaseUIManager* ui_manager, |
87 content::WebContents* web_contents, | 87 content::WebContents* web_contents, |
88 const UnsafeResource& resource); | 88 const UnsafeResource& resource); |
89 | 89 |
90 ~ThreatDetails() override; | 90 ~ThreatDetails() override; |
91 | 91 |
92 // Called on the IO thread with the DOM details. | 92 // Called on the IO thread with the DOM details. |
93 virtual void AddDOMDetails( | 93 virtual void AddDOMDetails( |
94 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); | 94 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); |
95 | 95 |
96 Profile* profile_; | 96 Profile* profile_; |
(...skipping 28 matching lines...) Expand all Loading... |
125 const GURL& parent, | 125 const GURL& parent, |
126 const std::string& tagname, | 126 const std::string& tagname, |
127 const std::vector<GURL>* children); | 127 const std::vector<GURL>* children); |
128 | 128 |
129 // Message handler. | 129 // Message handler. |
130 void OnReceivedThreatDOMDetails( | 130 void OnReceivedThreatDOMDetails( |
131 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); | 131 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); |
132 | 132 |
133 void AddRedirectUrlList(const std::vector<GURL>& urls); | 133 void AddRedirectUrlList(const std::vector<GURL>& urls); |
134 | 134 |
135 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 135 scoped_refptr<BaseUIManager> ui_manager_; |
136 | 136 |
137 const UnsafeResource resource_; | 137 const UnsafeResource resource_; |
138 | 138 |
139 // For every Url we collect we create a Resource message. We keep | 139 // For every Url we collect we create a Resource message. We keep |
140 // them in a map so we can avoid duplicates. | 140 // them in a map so we can avoid duplicates. |
141 ResourceMap resources_; | 141 ResourceMap resources_; |
142 | 142 |
143 // Result from the cache extractor. | 143 // Result from the cache extractor. |
144 bool cache_result_; | 144 bool cache_result_; |
145 | 145 |
(...skipping 23 matching lines...) Expand all Loading... |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(ThreatDetails); | 170 DISALLOW_COPY_AND_ASSIGN(ThreatDetails); |
171 }; | 171 }; |
172 | 172 |
173 // Factory for creating ThreatDetails. Useful for tests. | 173 // Factory for creating ThreatDetails. Useful for tests. |
174 class ThreatDetailsFactory { | 174 class ThreatDetailsFactory { |
175 public: | 175 public: |
176 virtual ~ThreatDetailsFactory() {} | 176 virtual ~ThreatDetailsFactory() {} |
177 | 177 |
178 virtual ThreatDetails* CreateThreatDetails( | 178 virtual ThreatDetails* CreateThreatDetails( |
179 SafeBrowsingUIManager* ui_manager, | 179 BaseUIManager* ui_manager, |
180 content::WebContents* web_contents, | 180 content::WebContents* web_contents, |
181 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; | 181 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; |
182 }; | 182 }; |
183 | 183 |
184 } // namespace safe_browsing | 184 } // namespace safe_browsing |
185 | 185 |
186 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 186 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ |
OLD | NEW |