| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2017 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_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ | 
|  | 6 #define CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ | 
|  | 7 | 
|  | 8 #include "base/memory/weak_ptr.h" | 
|  | 9 #include "chrome/common/safe_browsing.mojom.h" | 
|  | 10 #include "content/public/child/url_loader_throttle.h" | 
|  | 11 | 
|  | 12 namespace chrome { | 
|  | 13 namespace mojom { | 
|  | 14 class SafeBrowsing; | 
|  | 15 } | 
|  | 16 } | 
|  | 17 | 
|  | 18 namespace safe_browsing { | 
|  | 19 | 
|  | 20 // SafeBrowsingURLLoaderThrottle queries SafeBrowsing to determine whether the | 
|  | 21 // URL and also redirect URLs are safe to load. It defers response processing | 
|  | 22 // until all URL checks are completed; cancels the load if any URLs turn out to | 
|  | 23 // be bad. | 
|  | 24 class SafeBrowsingURLLoaderThrottle : public content::URLLoaderThrottle { | 
|  | 25  public: | 
|  | 26   // |safe_browsing| must stay alive until WillStartRequest() (if it is called) | 
|  | 27   // or the end of this object. | 
|  | 28   // |render_frame_id| is used for displaying SafeBrowsing UI when necessary. | 
|  | 29   SafeBrowsingURLLoaderThrottle(chrome::mojom::SafeBrowsing* safe_browsing, | 
|  | 30                                 int render_frame_id); | 
|  | 31   ~SafeBrowsingURLLoaderThrottle() override; | 
|  | 32 | 
|  | 33   // content::URLLoaderThrottle implementation. | 
|  | 34   void WillStartRequest(const GURL& url, | 
|  | 35                         int load_flags, | 
|  | 36                         content::ResourceType resource_type, | 
|  | 37                         bool* defer) override; | 
|  | 38   void WillRedirectRequest(const net::RedirectInfo& redirect_info, | 
|  | 39                            bool* defer) override; | 
|  | 40   void WillProcessResponse(bool* defer) override; | 
|  | 41 | 
|  | 42  private: | 
|  | 43   void OnCheckUrlResult(bool safe); | 
|  | 44 | 
|  | 45   void OnConnectionError(); | 
|  | 46 | 
|  | 47   chrome::mojom::SafeBrowsing* safe_browsing_; | 
|  | 48   const int render_frame_id_; | 
|  | 49 | 
|  | 50   chrome::mojom::SafeBrowsingUrlCheckerPtr url_checker_; | 
|  | 51 | 
|  | 52   size_t pending_checks_ = 0; | 
|  | 53   bool blocked_ = false; | 
|  | 54 | 
|  | 55   base::WeakPtrFactory<SafeBrowsingURLLoaderThrottle> weak_factory_; | 
|  | 56 }; | 
|  | 57 | 
|  | 58 }  // namespace safe_browsing | 
|  | 59 | 
|  | 60 #endif  // CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ | 
| OLD | NEW | 
|---|