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_CLIENT_SIDE_DETECTION_HOST_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 // This class is used to receive the IPC from the renderer which | 27 // This class is used to receive the IPC from the renderer which |
28 // notifies the browser that a URL was classified as phishing. This | 28 // notifies the browser that a URL was classified as phishing. This |
29 // class relays this information to the client-side detection service | 29 // class relays this information to the client-side detection service |
30 // class which sends a ping to a server to validate the verdict. | 30 // class which sends a ping to a server to validate the verdict. |
31 // TODO(noelutz): move all client-side detection IPCs to this class. | 31 // TODO(noelutz): move all client-side detection IPCs to this class. |
32 class ClientSideDetectionHost : public content::WebContentsObserver, | 32 class ClientSideDetectionHost : public content::WebContentsObserver, |
33 public content::NotificationObserver, | 33 public content::NotificationObserver, |
34 public SafeBrowsingService::Observer { | 34 public SafeBrowsingService::Observer { |
35 public: | 35 public: |
36 // The caller keeps ownership of the tab object and is responsible for | 36 // The caller keeps ownership of the tab object and is responsible for |
37 // ensuring that it stays valid until TabContentsDestroyed is called. | 37 // ensuring that it stays valid until WebContentsDestroyed is called. |
38 static ClientSideDetectionHost* Create(TabContents* tab); | 38 static ClientSideDetectionHost* Create(content::WebContents* tab); |
39 virtual ~ClientSideDetectionHost(); | 39 virtual ~ClientSideDetectionHost(); |
40 | 40 |
41 // From content::WebContentsObserver. | 41 // From content::WebContentsObserver. |
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
43 | 43 |
44 // From content::WebContentsObserver. If we navigate away we cancel all | 44 // From content::WebContentsObserver. If we navigate away we cancel all |
45 // pending callbacks that could show an interstitial, and check to see whether | 45 // pending callbacks that could show an interstitial, and check to see whether |
46 // we should classify the new URL. | 46 // we should classify the new URL. |
47 virtual void DidNavigateMainFrame( | 47 virtual void DidNavigateMainFrame( |
48 const content::LoadCommittedDetails& details, | 48 const content::LoadCommittedDetails& details, |
49 const content::FrameNavigateParams& params) OVERRIDE; | 49 const content::FrameNavigateParams& params) OVERRIDE; |
50 | 50 |
51 // Called when the SafeBrowsingService found a hit with one of the | 51 // Called when the SafeBrowsingService found a hit with one of the |
52 // SafeBrowsing lists. This method is called on the UI thread. | 52 // SafeBrowsing lists. This method is called on the UI thread. |
53 virtual void OnSafeBrowsingHit( | 53 virtual void OnSafeBrowsingHit( |
54 const SafeBrowsingService::UnsafeResource& resource) OVERRIDE; | 54 const SafeBrowsingService::UnsafeResource& resource) OVERRIDE; |
55 | 55 |
56 protected: | 56 protected: |
57 // From content::WebContentsObserver. | 57 // From content::WebContentsObserver. |
58 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | 58 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
59 | 59 |
60 private: | 60 private: |
61 friend class ClientSideDetectionHostTest; | 61 friend class ClientSideDetectionHostTest; |
62 class ShouldClassifyUrlRequest; | 62 class ShouldClassifyUrlRequest; |
63 friend class ShouldClassifyUrlRequest; | 63 friend class ShouldClassifyUrlRequest; |
64 | 64 |
65 explicit ClientSideDetectionHost(TabContents* tab); | 65 explicit ClientSideDetectionHost(content::WebContents* tab); |
66 | 66 |
67 // Verdict is an encoded ClientPhishingRequest protocol message. | 67 // Verdict is an encoded ClientPhishingRequest protocol message. |
68 void OnPhishingDetectionDone(const std::string& verdict); | 68 void OnPhishingDetectionDone(const std::string& verdict); |
69 | 69 |
70 // Callback that is called when the server ping back is | 70 // Callback that is called when the server ping back is |
71 // done. Display an interstitial if |is_phishing| is true. | 71 // done. Display an interstitial if |is_phishing| is true. |
72 // Otherwise, we do nothing. Called in UI thread. | 72 // Otherwise, we do nothing. Called in UI thread. |
73 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); | 73 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); |
74 | 74 |
75 // Callback that is called when the browser feature extractor is done. | 75 // Callback that is called when the browser feature extractor is done. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // as well as the UnsafeResource. | 125 // as well as the UnsafeResource. |
126 int unsafe_unique_page_id_; | 126 int unsafe_unique_page_id_; |
127 scoped_ptr<SafeBrowsingService::UnsafeResource> unsafe_resource_; | 127 scoped_ptr<SafeBrowsingService::UnsafeResource> unsafe_resource_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); | 129 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); |
130 }; | 130 }; |
131 | 131 |
132 } // namespace safe_browsing | 132 } // namespace safe_browsing |
133 | 133 |
134 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 134 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
OLD | NEW |