| 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_callback_factory.h" | 11 #include "base/memory/scoped_callback_factory.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 14 #include "content/browser/tab_contents/tab_contents_observer.h" | 14 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 | 16 |
| 17 class TabContents; | 17 class TabContents; |
| 18 | 18 |
| 19 namespace safe_browsing { | 19 namespace safe_browsing { |
| 20 | 20 class BrowserFeatureExtractor; |
| 21 class ClientPhishingRequest; |
| 21 class ClientSideDetectionService; | 22 class ClientSideDetectionService; |
| 22 | 23 |
| 23 // This class is used to receive the IPC from the renderer which | 24 // This class is used to receive the IPC from the renderer which |
| 24 // notifies the browser that a URL was classified as phishing. This | 25 // notifies the browser that a URL was classified as phishing. This |
| 25 // class relays this information to the client-side detection service | 26 // class relays this information to the client-side detection service |
| 26 // class which sends a ping to a server to validate the verdict. | 27 // class which sends a ping to a server to validate the verdict. |
| 27 // TODO(noelutz): move all client-side detection IPCs to this class. | 28 // TODO(noelutz): move all client-side detection IPCs to this class. |
| 28 class ClientSideDetectionHost : public TabContentsObserver { | 29 class ClientSideDetectionHost : public TabContentsObserver { |
| 29 public: | 30 public: |
| 30 // The caller keeps ownership of the tab object and is responsible for | 31 // The caller keeps ownership of the tab object and is responsible for |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 explicit ClientSideDetectionHost(TabContents* tab); | 51 explicit ClientSideDetectionHost(TabContents* tab); |
| 51 | 52 |
| 52 // Verdict is an encoded ClientPhishingRequest protocol message. | 53 // Verdict is an encoded ClientPhishingRequest protocol message. |
| 53 void OnDetectedPhishingSite(const std::string& verdict); | 54 void OnDetectedPhishingSite(const std::string& verdict); |
| 54 | 55 |
| 55 // Callback that is called when the server ping back is | 56 // Callback that is called when the server ping back is |
| 56 // done. Display an interstitial if |is_phishing| is true. | 57 // done. Display an interstitial if |is_phishing| is true. |
| 57 // Otherwise, we do nothing. Called in UI thread. | 58 // Otherwise, we do nothing. Called in UI thread. |
| 58 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); | 59 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); |
| 59 | 60 |
| 61 void FeatureExtractionDone(bool success, ClientPhishingRequest* request); |
| 62 |
| 60 // Used for testing. This function does not take ownership of the service | 63 // Used for testing. This function does not take ownership of the service |
| 61 // class. | 64 // class. |
| 62 void set_client_side_detection_service(ClientSideDetectionService* service); | 65 void set_client_side_detection_service(ClientSideDetectionService* service); |
| 63 | 66 |
| 64 // Used for testing. This function does not take ownership of the service | 67 // Used for testing. This function does not take ownership of the service |
| 65 // class. | 68 // class. |
| 66 void set_safe_browsing_service(SafeBrowsingService* service); | 69 void set_safe_browsing_service(SafeBrowsingService* service); |
| 67 | 70 |
| 68 // This pointer may be NULL if client-side phishing detection is disabled. | 71 // This pointer may be NULL if client-side phishing detection is disabled. |
| 69 ClientSideDetectionService* csd_service_; | 72 ClientSideDetectionService* csd_service_; |
| 70 // This pointer may be NULL if SafeBrowsing is disabled. | 73 // This pointer may be NULL if SafeBrowsing is disabled. |
| 71 scoped_refptr<SafeBrowsingService> sb_service_; | 74 scoped_refptr<SafeBrowsingService> sb_service_; |
| 72 // Keep a handle to the latest classification request so that we can cancel | 75 // Keep a handle to the latest classification request so that we can cancel |
| 73 // it if necessary. | 76 // it if necessary. |
| 74 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; | 77 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; |
| 78 // Browser-side feature extractor. |
| 79 scoped_ptr<BrowserFeatureExtractor> feature_extractor_; |
| 75 | 80 |
| 76 base::ScopedCallbackFactory<ClientSideDetectionHost> cb_factory_; | 81 base::ScopedCallbackFactory<ClientSideDetectionHost> cb_factory_; |
| 77 | 82 |
| 78 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); | 83 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 } // namespace safe_browsing | 86 } // namespace safe_browsing |
| 82 | 87 |
| 83 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 88 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
| OLD | NEW |