| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_ANDR
OID_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_ANDR
OID_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_ANDR
OID_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_ANDR
OID_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class DataReductionProxyResourceThrottle | 45 class DataReductionProxyResourceThrottle |
| 46 : public content::ResourceThrottle, | 46 : public content::ResourceThrottle, |
| 47 public base::SupportsWeakPtr<DataReductionProxyResourceThrottle> { | 47 public base::SupportsWeakPtr<DataReductionProxyResourceThrottle> { |
| 48 public: | 48 public: |
| 49 // Create a DataReductionProxyResourceThrottle. If it's not enabled | 49 // Create a DataReductionProxyResourceThrottle. If it's not enabled |
| 50 // or we can't process this request, will return NULL. | 50 // or we can't process this request, will return NULL. |
| 51 static DataReductionProxyResourceThrottle* MaybeCreate( | 51 static DataReductionProxyResourceThrottle* MaybeCreate( |
| 52 net::URLRequest* request, | 52 net::URLRequest* request, |
| 53 content::ResourceContext* resource_context, | 53 content::ResourceContext* resource_context, |
| 54 content::ResourceType resource_type, | 54 content::ResourceType resource_type, |
| 55 SafeBrowsingService* sb_service); | 55 safe_browsing::SafeBrowsingService* sb_service); |
| 56 | 56 |
| 57 DataReductionProxyResourceThrottle(net::URLRequest* request, | 57 DataReductionProxyResourceThrottle(net::URLRequest* request, |
| 58 content::ResourceType resource_type, | 58 content::ResourceType resource_type, |
| 59 SafeBrowsingService* safe_browsing); | 59 safe_browsing::SafeBrowsingService* safe_browsing); |
| 60 | 60 |
| 61 // content::ResourceThrottle implementation (called on IO thread). | 61 // content::ResourceThrottle implementation (called on IO thread). |
| 62 void WillRedirectRequest(const net::RedirectInfo& redirect_info, | 62 void WillRedirectRequest(const net::RedirectInfo& redirect_info, |
| 63 bool* defer) override; | 63 bool* defer) override; |
| 64 const char* GetNameForLogging() const override; | 64 const char* GetNameForLogging() const override; |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // Describes what phase of the check a throttle is in. | 67 // Describes what phase of the check a throttle is in. |
| 68 enum State { | 68 enum State { |
| 69 STATE_NONE, | 69 STATE_NONE, |
| 70 STATE_DISPLAYING_BLOCKING_PAGE, | 70 STATE_DISPLAYING_BLOCKING_PAGE, |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 static const char* kUnsafeUrlProceedHeader; | 73 static const char* kUnsafeUrlProceedHeader; |
| 74 | 74 |
| 75 ~DataReductionProxyResourceThrottle() override; | 75 ~DataReductionProxyResourceThrottle() override; |
| 76 | 76 |
| 77 // SafeBrowsingService::UrlCheckCallback implementation. | 77 // SafeBrowsingService::UrlCheckCallback implementation. |
| 78 void OnBlockingPageComplete(bool proceed); | 78 void OnBlockingPageComplete(bool proceed); |
| 79 | 79 |
| 80 // Returns the threat type. | 80 // Returns the threat type. |
| 81 SBThreatType CheckUrl(); | 81 safe_browsing::SBThreatType CheckUrl(); |
| 82 | 82 |
| 83 // Starts displaying the safe browsing interstitial page if it is not | 83 // Starts displaying the safe browsing interstitial page if it is not |
| 84 // prerendering. Called on the UI thread. | 84 // prerendering. Called on the UI thread. |
| 85 static void StartDisplayingBlockingPage( | 85 static void StartDisplayingBlockingPage( |
| 86 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, | 86 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, |
| 87 scoped_refptr<SafeBrowsingUIManager> ui_manager, | 87 scoped_refptr<safe_browsing::SafeBrowsingUIManager> ui_manager, |
| 88 const SafeBrowsingUIManager::UnsafeResource& resource); | 88 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource); |
| 89 | 89 |
| 90 // Resumes the request, by continuing the deferred action (either starting the | 90 // Resumes the request, by continuing the deferred action (either starting the |
| 91 // request, or following a redirect). | 91 // request, or following a redirect). |
| 92 void ResumeRequest(); | 92 void ResumeRequest(); |
| 93 | 93 |
| 94 State state_; | 94 State state_; |
| 95 | 95 |
| 96 // The redirect chain for this resource. | 96 // The redirect chain for this resource. |
| 97 std::vector<GURL> redirect_urls_; | 97 std::vector<GURL> redirect_urls_; |
| 98 | 98 |
| 99 scoped_refptr<SafeBrowsingService> safe_browsing_; | 99 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_; |
| 100 net::URLRequest* request_; | 100 net::URLRequest* request_; |
| 101 const bool is_subresource_; | 101 const bool is_subresource_; |
| 102 const bool is_subframe_; | 102 const bool is_subframe_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyResourceThrottle); | 104 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyResourceThrottle); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 #endif // CHROME_BROWSER_RENDERER_HOST_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_A
NDROID_H_ | 107 #endif // CHROME_BROWSER_RENDERER_HOST_DATA_REDUCTION_PROXY_RESOURCE_THROTTLE_A
NDROID_H_ |
| OLD | NEW |