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