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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/timer.h" | 13 #include "base/timer.h" |
14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | |
15 #include "chrome/browser/renderer_host/resource_handler.h" | 14 #include "chrome/browser/renderer_host/resource_handler.h" |
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
17 #include "chrome/common/notification_observer.h" | 16 #include "chrome/common/notification_observer.h" |
18 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
19 | 18 |
| 19 class ResourceDispatcherHost; |
| 20 class ResourceMessageFilter; |
| 21 |
20 // SafeBrowsingResourceHandler checks that URLs are "safe" before navigating | 22 // SafeBrowsingResourceHandler checks that URLs are "safe" before navigating |
21 // to them. To be considered "safe", a URL must not appear in the | 23 // to them. To be considered "safe", a URL must not appear in the |
22 // malware/phishing blacklists (see SafeBrowsingService for details). | 24 // malware/phishing blacklists (see SafeBrowsingService for details). |
23 // | 25 // |
24 // This check is done before requesting the original URL, and additionally | 26 // This check is done before requesting the original URL, and additionally |
25 // before following any subsequent redirect. | 27 // before following any subsequent redirect. |
26 // | 28 // |
27 // In the common case, the check completes synchronously (no match in the bloom | 29 // In the common case, the check completes synchronously (no match in the bloom |
28 // filter), so the request's flow is un-interrupted. | 30 // filter), so the request's flow is un-interrupted. |
29 // | 31 // |
30 // However if the URL fails this quick check, it has the possibility of being | 32 // However if the URL fails this quick check, it has the possibility of being |
31 // on the blacklist. Now the request is suspended (prevented from starting), | 33 // on the blacklist. Now the request is suspended (prevented from starting), |
32 // and a more expensive safe browsing check is begun (fetches the full hashes). | 34 // and a more expensive safe browsing check is begun (fetches the full hashes). |
33 // | 35 // |
34 // Note that the safe browsing check takes at most kCheckUrlTimeoutMs | 36 // Note that the safe browsing check takes at most kCheckUrlTimeoutMs |
35 // milliseconds. If it takes longer than this, then the system defaults to | 37 // milliseconds. If it takes longer than this, then the system defaults to |
36 // treating the URL as safe. | 38 // treating the URL as safe. |
37 // | 39 // |
38 // Once the safe browsing check has completed, if the URL was decided to be | 40 // Once the safe browsing check has completed, if the URL was decided to be |
39 // dangerous, a warning page is thrown up and the request remains suspended. | 41 // dangerous, a warning page is thrown up and the request remains suspended. |
40 // If on the other hand the URL was decided to be safe, the request is | 42 // If on the other hand the URL was decided to be safe, the request is |
41 // resumed. | 43 // resumed. |
42 class SafeBrowsingResourceHandler : public ResourceHandler, | 44 class SafeBrowsingResourceHandler : public ResourceHandler, |
43 public SafeBrowsingService::Client, | 45 public SafeBrowsingService::Client, |
44 public NotificationObserver { | 46 public NotificationObserver { |
45 public: | 47 public: |
46 SafeBrowsingResourceHandler(ResourceHandler* handler, | 48 SafeBrowsingResourceHandler(ResourceHandler* handler, |
47 int render_process_host_id, | |
48 int render_view_id, | 49 int render_view_id, |
49 ResourceType::Type resource_type, | 50 ResourceType::Type resource_type, |
50 SafeBrowsingService* safe_browsing, | 51 SafeBrowsingService* safe_browsing, |
51 ResourceDispatcherHost* resource_dispatcher_host, | 52 ResourceDispatcherHost* resource_dispatcher_host, |
52 ResourceDispatcherHost::Receiver* receiver); | 53 ResourceMessageFilter* filter); |
53 | 54 |
54 // ResourceHandler implementation: | 55 // ResourceHandler implementation: |
55 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 56 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); |
56 virtual bool OnRequestRedirected(int request_id, const GURL& new_url, | 57 virtual bool OnRequestRedirected(int request_id, const GURL& new_url, |
57 ResourceResponse* response, bool* defer); | 58 ResourceResponse* response, bool* defer); |
58 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); | 59 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); |
59 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); | 60 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); |
60 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 61 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
61 int min_size); | 62 int min_size); |
62 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 63 virtual bool OnReadCompleted(int request_id, int* bytes_read); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 int render_view_id_; | 152 int render_view_id_; |
152 scoped_refptr<SafeBrowsingService> safe_browsing_; | 153 scoped_refptr<SafeBrowsingService> safe_browsing_; |
153 ResourceDispatcherHost* rdh_; | 154 ResourceDispatcherHost* rdh_; |
154 ResourceType::Type resource_type_; | 155 ResourceType::Type resource_type_; |
155 | 156 |
156 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler); | 157 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler); |
157 }; | 158 }; |
158 | 159 |
159 | 160 |
160 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ | 161 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_HANDLER_H_ |
OLD | NEW |