| 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 // MalwareDOMDetails iterates over a document's frames and gathers | 5 // MalwareDOMDetails iterates over a document's frames and gathers |
| 6 // interesting URLs such as those of scripts and frames. When done, it sends | 6 // interesting URLs such as those of scripts and frames. When done, it sends |
| 7 // them to the MalwareDetails that requested them. | 7 // them to the MalwareDetails that requested them. |
| 8 | 8 |
| 9 #ifndef CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ | 9 #ifndef CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ |
| 10 #define CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ | 10 #define CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
| 18 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "content/renderer/render_view_observer.h" | 19 #include "content/renderer/render_view_observer.h" |
| 20 | 20 |
| 21 class GURL; | 21 class GURL; |
| 22 class RenderView; | 22 class RenderView; |
| 23 | 23 |
| 24 namespace WebKit { | 24 namespace WebKit { |
| 25 class WebElement; | 25 class WebElement; |
| 26 class WebFrame; | 26 class WebFrame; |
| 27 } | 27 } |
| 28 | 28 |
| 29 struct ViewHostMsg_MalwareDOMDetails_Params; | 29 struct SafeBrowsingHostMsg_MalwareDOMDetails_Node; |
| 30 struct ViewHostMsg_MalwareDOMDetails_Node; | |
| 31 | 30 |
| 32 namespace safe_browsing { | 31 namespace safe_browsing { |
| 33 | 32 |
| 34 // There is one MalwareDOMDetails per RenderView. | 33 // There is one MalwareDOMDetails per RenderView. |
| 35 class MalwareDOMDetails : public RenderViewObserver { | 34 class MalwareDOMDetails : public RenderViewObserver { |
| 36 public: | 35 public: |
| 37 // An upper limit on the number of nodes we collect. Not const for the test. | 36 // An upper limit on the number of nodes we collect. Not const for the test. |
| 38 static uint32 kMaxNodes; | 37 static uint32 kMaxNodes; |
| 39 | 38 |
| 40 // Creates a MalwareDOMDetails for the specified RenderView. | 39 // Creates a MalwareDOMDetails for the specified RenderView. |
| 41 // The MalwareDOMDetails should be destroyed prior to destroying | 40 // The MalwareDOMDetails should be destroyed prior to destroying |
| 42 // the RenderView. | 41 // the RenderView. |
| 43 explicit MalwareDOMDetails(RenderView* render_view); | 42 explicit MalwareDOMDetails(RenderView* render_view); |
| 44 ~MalwareDOMDetails(); | 43 ~MalwareDOMDetails(); |
| 45 | 44 |
| 46 // Begins extracting resource urls for the page currently loaded in | 45 // Begins extracting resource urls for the page currently loaded in |
| 47 // this object's RenderView. | 46 // this object's RenderView. |
| 48 void ExtractResources(ViewHostMsg_MalwareDOMDetails_Params* resources); | 47 void ExtractResources( |
| 48 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>* resources); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // RenderViewObserver implementation. | 51 // RenderViewObserver implementation. |
| 52 virtual bool OnMessageReceived(const IPC::Message& message); | 52 virtual bool OnMessageReceived(const IPC::Message& message); |
| 53 | 53 |
| 54 void OnGetMalwareDOMDetails(); | 54 void OnGetMalwareDOMDetails(); |
| 55 | 55 |
| 56 // Handler for the various HTML elements that we extract URLs from. | 56 // Handler for the various HTML elements that we extract URLs from. |
| 57 void HandleElement(const WebKit::WebElement& element, | 57 void HandleElement( |
| 58 ViewHostMsg_MalwareDOMDetails_Node* parent_node, | 58 const WebKit::WebElement& element, |
| 59 ViewHostMsg_MalwareDOMDetails_Params* resources); | 59 SafeBrowsingHostMsg_MalwareDOMDetails_Node* parent_node, |
| 60 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>* resources); |
| 60 | 61 |
| 61 // Non-owned pointer to the view that we will extract features from. | 62 // Non-owned pointer to the view that we will extract features from. |
| 62 RenderView* render_view_; | 63 RenderView* render_view_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(MalwareDOMDetails); | 65 DISALLOW_COPY_AND_ASSIGN(MalwareDOMDetails); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace safe_browsing | 68 } // namespace safe_browsing |
| 68 | 69 |
| 69 #endif // CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ | 70 #endif // CHROME_RENDERER_SAFE_BROWSING_MALWARE_DOM_DETAILS_H_ |
| OLD | NEW |