Chromium Code Reviews| 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 // Helper class which handles communication with the SafeBrowsing backends for | 5 // Helper class which handles communication with the SafeBrowsing backends for |
| 6 // client-side phishing detection. This class can be used to get a file | 6 // client-side phishing detection. This class can be used to get a file |
| 7 // descriptor to the client-side phishing model and also to send a ping back to | 7 // descriptor to the client-side phishing model and also to send a ping back to |
| 8 // Google to verify if a particular site is really phishing or not. | 8 // Google to verify if a particular site is really phishing or not. |
| 9 // | 9 // |
| 10 // This class is not thread-safe and expects all calls to GetModelFile() and | 10 // This class is not thread-safe and expects all calls to GetModelFile() and |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 #include "base/callback.h" | 24 #include "base/callback.h" |
| 25 #include "base/file_path.h" | 25 #include "base/file_path.h" |
| 26 #include "base/gtest_prod_util.h" | 26 #include "base/gtest_prod_util.h" |
| 27 #include "base/platform_file.h" | 27 #include "base/platform_file.h" |
| 28 #include "base/ref_counted.h" | 28 #include "base/ref_counted.h" |
| 29 #include "base/scoped_callback_factory.h" | 29 #include "base/scoped_callback_factory.h" |
| 30 #include "base/scoped_ptr.h" | 30 #include "base/scoped_ptr.h" |
| 31 #include "base/task.h" | 31 #include "base/task.h" |
| 32 #include "chrome/common/render_messages_params.h" | |
| 32 #include "chrome/browser/safe_browsing/csd.pb.h" | 33 #include "chrome/browser/safe_browsing/csd.pb.h" |
| 34 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | |
| 35 #include "chrome/browser/tab_contents/navigation_controller.h" | |
| 36 #include "chrome/browser/tab_contents/web_navigation_observer.h" | |
| 33 #include "chrome/common/net/url_fetcher.h" | 37 #include "chrome/common/net/url_fetcher.h" |
| 34 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
| 35 | 39 |
| 36 class URLRequestContextGetter; | 40 class URLRequestContextGetter; |
| 37 | 41 |
| 38 namespace net { | 42 namespace net { |
| 39 class URLRequestStatus; | 43 class URLRequestStatus; |
| 40 } // namespace net | 44 } // namespace net |
| 41 | 45 |
| 42 namespace safe_browsing { | 46 namespace safe_browsing { |
| 43 | 47 |
| 48 // This class is used to display a phishing interstitial if the client-side | |
| 49 // phishing detection service classified a particular URL as phishing. | |
| 50 class CsdClient : public SafeBrowsingService::Client, | |
|
lzheng
2011/01/25 00:43:43
Can add comments regarding which thread will call
noelutz
2011/02/10 01:16:23
Done.
| |
| 51 public WebNavigationObserver { | |
| 52 public: | |
| 53 CsdClient(int render_process_id, int render_view_id); | |
| 54 | |
| 55 virtual void OnUrlCheckResult(const GURL& url, | |
|
Brian Ryner
2011/01/20 23:36:40
Comment that these methods are from SafeBrowsingSe
noelutz
2011/02/10 01:16:23
Done.
| |
| 56 SafeBrowsingService::UrlCheckResult result); | |
| 57 virtual void OnBlockingPageComplete(bool proceed); | |
| 58 virtual void MaybeShowPhishingInterstitial(GURL phishing_url, | |
| 59 bool is_phishing); | |
| 60 | |
| 61 // From WebNavigationObserver. We want to know if the user navigates away | |
| 62 // from the current page. That way when the server verdict comes back we | |
| 63 // will not show any interstitial. | |
| 64 virtual void DidNavigateMainFramePostCommit( | |
| 65 const NavigationController::LoadCommittedDetails& details, | |
| 66 const ViewHostMsg_FrameNavigate_Params& params); | |
| 67 | |
| 68 private: | |
| 69 // We're taking care of deleting this object. No-one else should delete | |
| 70 // this object. | |
| 71 ~CsdClient(); | |
| 72 | |
| 73 int render_process_id_; | |
| 74 int render_view_id_; | |
| 75 bool navigated_away_; | |
| 76 }; | |
|
Brian Ryner
2011/01/20 23:36:40
DISALLOW_COPY_AND_ASSIGN?
noelutz
2011/02/10 01:16:23
Done.
| |
| 77 | |
| 44 class ClientSideDetectionService : public URLFetcher::Delegate { | 78 class ClientSideDetectionService : public URLFetcher::Delegate { |
| 45 public: | 79 public: |
| 46 typedef Callback1<base::PlatformFile>::Type OpenModelDoneCallback; | 80 typedef Callback1<base::PlatformFile>::Type OpenModelDoneCallback; |
| 47 | 81 |
| 48 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type | 82 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type |
| 49 ClientReportPhishingRequestCallback; | 83 ClientReportPhishingRequestCallback; |
| 50 | 84 |
| 51 virtual ~ClientSideDetectionService(); | 85 virtual ~ClientSideDetectionService(); |
| 52 | 86 |
| 53 // Creates a client-side detection service and starts fetching the client-side | 87 // Creates a client-side detection service and starts fetching the client-side |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 | 220 |
| 187 // The context we use to issue network requests. | 221 // The context we use to issue network requests. |
| 188 scoped_refptr<URLRequestContextGetter> request_context_getter_; | 222 scoped_refptr<URLRequestContextGetter> request_context_getter_; |
| 189 | 223 |
| 190 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); | 224 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); |
| 191 }; | 225 }; |
| 192 | 226 |
| 193 } // namepsace safe_browsing | 227 } // namepsace safe_browsing |
| 194 | 228 |
| 195 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ | 229 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ |
| OLD | NEW |