| 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 #include "components/web_restrictions/browser/web_restrictions_resource_throttle
.h" | 5 #include "components/web_restrictions/browser/web_restrictions_resource_throttle
.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "components/web_restrictions/browser/web_restrictions_client.h" | 8 #include "components/web_restrictions/browser/web_restrictions_client.h" |
| 9 #include "content/public/browser/resource_controller.h" | 9 #include "content/public/browser/resource_controller.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 const char* WebRestrictionsResourceThrottle::GetNameForLogging() const { | 37 const char* WebRestrictionsResourceThrottle::GetNameForLogging() const { |
| 38 return "WebRestrictionsResourceThrottle"; | 38 return "WebRestrictionsResourceThrottle"; |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool WebRestrictionsResourceThrottle::ShouldDefer(const GURL& url) { | 41 bool WebRestrictionsResourceThrottle::ShouldDefer(const GURL& url) { |
| 42 // For requests to function correctly, we need to allow subresources. | 42 // For requests to function correctly, we need to allow subresources. |
| 43 if (provider_->SupportsRequest() && !is_main_frame_) | 43 if (provider_->SupportsRequest() && !is_main_frame_) |
| 44 return false; | 44 return false; |
| 45 UrlAccess access = provider_->ShouldProceed( | 45 UrlAccess access = provider_->ShouldProceed( |
| 46 is_main_frame_, url, | 46 is_main_frame_, url.spec(), |
| 47 base::Bind(&WebRestrictionsResourceThrottle::OnCheckResult, | 47 base::Bind(&WebRestrictionsResourceThrottle::OnCheckResult, |
| 48 weak_ptr_factory_.GetWeakPtr())); | 48 weak_ptr_factory_.GetWeakPtr())); |
| 49 if (access == DISALLOW) | 49 if (access == DISALLOW) |
| 50 OnCheckResult(false); | 50 OnCheckResult(false); |
| 51 return access == PENDING; | 51 return access == PENDING; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void WebRestrictionsResourceThrottle::OnCheckResult(const bool should_proceed) { | 54 void WebRestrictionsResourceThrottle::OnCheckResult(const bool should_proceed) { |
| 55 if (should_proceed) { | 55 if (should_proceed) { |
| 56 controller()->Resume(); | 56 controller()->Resume(); |
| 57 } else { | 57 } else { |
| 58 controller()->CancelWithError(net::ERR_BLOCKED_BY_ADMINISTRATOR); | 58 controller()->CancelWithError(net::ERR_BLOCKED_BY_ADMINISTRATOR); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace web_restrictions | 62 } // namespace web_restrictions |
| OLD | NEW |