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