| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_ | |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | |
| 14 #include "chrome/browser/supervised_user/supervised_users.h" | |
| 15 #include "components/supervised_user_error_page/supervised_user_error_page.h" | |
| 16 #include "content/public/browser/resource_throttle.h" | |
| 17 #include "content/public/common/resource_type.h" | |
| 18 | |
| 19 namespace net { | |
| 20 class URLRequest; | |
| 21 } | |
| 22 | |
| 23 class SupervisedUserResourceThrottle : public content::ResourceThrottle { | |
| 24 public: | |
| 25 // Returns a new throttle for the given parameters, or nullptr if no | |
| 26 // throttling is required. | |
| 27 static std::unique_ptr<SupervisedUserResourceThrottle> MaybeCreate( | |
| 28 const net::URLRequest* request, | |
| 29 content::ResourceType resource_type, | |
| 30 const SupervisedUserURLFilter* url_filter); | |
| 31 | |
| 32 ~SupervisedUserResourceThrottle() override; | |
| 33 | |
| 34 // content::ResourceThrottle implementation: | |
| 35 void WillStartRequest(bool* defer) override; | |
| 36 | |
| 37 void WillRedirectRequest(const net::RedirectInfo& redirect_info, | |
| 38 bool* defer) override; | |
| 39 | |
| 40 const char* GetNameForLogging() const override; | |
| 41 | |
| 42 private: | |
| 43 SupervisedUserResourceThrottle(const net::URLRequest* request, | |
| 44 const SupervisedUserURLFilter* url_filter); | |
| 45 | |
| 46 void CheckURL(const GURL& url, bool* defer); | |
| 47 | |
| 48 void ShowInterstitial( | |
| 49 const GURL& url, | |
| 50 supervised_user_error_page::FilteringBehaviorReason reason); | |
| 51 | |
| 52 void OnCheckDone(const GURL& url, | |
| 53 SupervisedUserURLFilter::FilteringBehavior behavior, | |
| 54 supervised_user_error_page::FilteringBehaviorReason reason, | |
| 55 bool uncertain); | |
| 56 | |
| 57 void OnInterstitialResult(bool continue_request); | |
| 58 | |
| 59 const net::URLRequest* request_; | |
| 60 const SupervisedUserURLFilter* url_filter_; | |
| 61 bool deferred_; | |
| 62 SupervisedUserURLFilter::FilteringBehavior behavior_; | |
| 63 base::WeakPtrFactory<SupervisedUserResourceThrottle> weak_ptr_factory_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(SupervisedUserResourceThrottle); | |
| 66 }; | |
| 67 | |
| 68 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_ | |
| OLD | NEW |