| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/time.h" | 10 #include "base/time.h" |
| 9 #include "chrome/browser/renderer_host/resource_handler.h" | 11 #include "chrome/browser/renderer_host/resource_handler.h" |
| 10 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 11 | 13 |
| 12 class ResourceDispatcherHost; | 14 class ResourceDispatcherHost; |
| 13 | 15 |
| 14 // Checks that a url is safe. | 16 // Checks that a url is safe. |
| 15 class SafeBrowsingResourceHandler : public ResourceHandler, | 17 class SafeBrowsingResourceHandler : public ResourceHandler, |
| 16 public SafeBrowsingService::Client { | 18 public SafeBrowsingService::Client { |
| 17 public: | 19 public: |
| 18 SafeBrowsingResourceHandler(ResourceHandler* handler, | 20 SafeBrowsingResourceHandler(ResourceHandler* handler, |
| 19 int render_process_host_id, | 21 int render_process_host_id, |
| 20 int render_view_id, | 22 int render_view_id, |
| 21 const GURL& url, | 23 const GURL& url, |
| 22 ResourceType::Type resource_type, | 24 ResourceType::Type resource_type, |
| 23 SafeBrowsingService* safe_browsing, | 25 SafeBrowsingService* safe_browsing, |
| 24 ResourceDispatcherHost* resource_dispatcher_host); | 26 ResourceDispatcherHost* resource_dispatcher_host); |
| 25 | 27 |
| 26 // ResourceHandler implementation: | 28 // ResourceHandler implementation: |
| 27 bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 29 bool OnUploadProgress(int request_id, uint64 position, uint64 size); |
| 28 bool OnRequestRedirected(int request_id, const GURL& new_url); | 30 bool OnRequestRedirected(int request_id, const GURL& new_url); |
| 29 bool OnResponseStarted(int request_id, ResourceResponse* response); | 31 bool OnResponseStarted(int request_id, ResourceResponse* response); |
| 30 void OnGetHashTimeout(); | 32 void OnGetHashTimeout(); |
| 31 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 33 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 32 int min_size); | 34 int min_size); |
| 33 bool OnReadCompleted(int request_id, int* bytes_read); | 35 bool OnReadCompleted(int request_id, int* bytes_read); |
| 34 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 36 bool OnResponseCompleted(int request_id, |
| 37 const URLRequestStatus& status, |
| 38 const std::string& security_info); |
| 35 | 39 |
| 36 // SafeBrowsingService::Client implementation, called on the IO thread once | 40 // SafeBrowsingService::Client implementation, called on the IO thread once |
| 37 // the URL has been classified. | 41 // the URL has been classified. |
| 38 void OnUrlCheckResult(const GURL& url, | 42 void OnUrlCheckResult(const GURL& url, |
| 39 SafeBrowsingService::UrlCheckResult result); | 43 SafeBrowsingService::UrlCheckResult result); |
| 40 | 44 |
| 41 // SafeBrowsingService::Client implementation, called on the IO thread when | 45 // SafeBrowsingService::Client implementation, called on the IO thread when |
| 42 // the user has decided to proceed with the current request, or go back. | 46 // the user has decided to proceed with the current request, or go back. |
| 43 void OnBlockingPageComplete(bool proceed); | 47 void OnBlockingPageComplete(bool proceed); |
| 44 | 48 |
| 45 private: | 49 private: |
| 46 scoped_refptr<ResourceHandler> next_handler_; | 50 scoped_refptr<ResourceHandler> next_handler_; |
| 47 int render_process_host_id_; | 51 int render_process_host_id_; |
| 48 int render_view_id_; | 52 int render_view_id_; |
| 49 int paused_request_id_; // -1 if not paused | 53 int paused_request_id_; // -1 if not paused |
| 50 bool in_safe_browsing_check_; | 54 bool in_safe_browsing_check_; |
| 51 bool displaying_blocking_page_; | 55 bool displaying_blocking_page_; |
| 52 SafeBrowsingService::UrlCheckResult safe_browsing_result_; | 56 SafeBrowsingService::UrlCheckResult safe_browsing_result_; |
| 53 scoped_refptr<SafeBrowsingService> safe_browsing_; | 57 scoped_refptr<SafeBrowsingService> safe_browsing_; |
| 54 scoped_ptr<URLRequestStatus> queued_error_; | 58 scoped_ptr<URLRequestStatus> queued_error_; |
| 59 std::string queued_security_info_; |
| 55 int queued_error_request_id_; | 60 int queued_error_request_id_; |
| 56 ResourceDispatcherHost* rdh_; | 61 ResourceDispatcherHost* rdh_; |
| 57 base::Time pause_time_; | 62 base::Time pause_time_; |
| 58 ResourceType::Type resource_type_; | 63 ResourceType::Type resource_type_; |
| 59 | 64 |
| 60 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler); | 65 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler); |
| 61 }; | 66 }; |
| 62 | 67 |
| 63 | 68 |
| 64 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ | 69 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ |
| OLD | NEW |