Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/renderer/safe_browsing/safe_browsing_renderer_throttle.h

Issue 2924723002: Network service: SafeBrowsing check for frame-resources from browser. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ 5 #ifndef CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_RENDERER_THROTTLE_H_
6 #define CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ 6 #define CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_RENDERER_THROTTLE_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "chrome/common/safe_browsing.mojom.h" 9 #include "chrome/common/safe_browsing.mojom.h"
10 #include "content/public/common/url_loader_throttle.h" 10 #include "content/public/common/url_loader_throttle.h"
11 11
12 namespace chrome { 12 namespace chrome {
13 namespace mojom { 13 namespace mojom {
14 class SafeBrowsing; 14 class SafeBrowsing;
15 } 15 }
16 } 16 }
17 17
18 namespace safe_browsing { 18 namespace safe_browsing {
19 19
20 // SafeBrowsingURLLoaderThrottle queries SafeBrowsing to determine whether the 20 // SafeBrowsingRendererThrottle is used in renderer processes to query
21 // URL and also redirect URLs are safe to load. It defers response processing 21 // SafeBrowsing and determine whether a URL and its redirect URLs are safe to
22 // until all URL checks are completed; cancels the load if any URLs turn out to 22 // load. It defers response processing until all URL checks are completed;
23 // be bad. 23 // cancels the load if any URLs turn out to be bad.
24 class SafeBrowsingURLLoaderThrottle : public content::URLLoaderThrottle { 24 class SafeBrowsingRendererThrottle : public content::URLLoaderThrottle {
25 public: 25 public:
26 // |safe_browsing| must stay alive until WillStartRequest() (if it is called) 26 // |safe_browsing| must stay alive until WillStartRequest() (if it is called)
27 // or the end of this object. 27 // or the end of this object.
28 // |render_frame_id| is used for displaying SafeBrowsing UI when necessary. 28 // |render_frame_id| is used for displaying SafeBrowsing UI when necessary.
29 SafeBrowsingURLLoaderThrottle(chrome::mojom::SafeBrowsing* safe_browsing, 29 SafeBrowsingRendererThrottle(chrome::mojom::SafeBrowsing* safe_browsing,
30 int render_frame_id); 30 int render_frame_id);
31 ~SafeBrowsingURLLoaderThrottle() override; 31 ~SafeBrowsingRendererThrottle() override;
32 32
33 // content::URLLoaderThrottle implementation. 33 // content::URLLoaderThrottle implementation.
34 void WillStartRequest(const GURL& url, 34 void WillStartRequest(const GURL& url,
35 int load_flags, 35 int load_flags,
36 content::ResourceType resource_type, 36 content::ResourceType resource_type,
37 bool* defer) override; 37 bool* defer) override;
38 void WillRedirectRequest(const net::RedirectInfo& redirect_info, 38 void WillRedirectRequest(const net::RedirectInfo& redirect_info,
39 bool* defer) override; 39 bool* defer) override;
40 void WillProcessResponse(bool* defer) override; 40 void WillProcessResponse(bool* defer) override;
41 41
42 private: 42 private:
43 void OnCheckUrlResult(bool safe); 43 void OnCheckUrlResult(bool safe);
44 44
45 void OnConnectionError(); 45 void OnConnectionError();
46 46
47 chrome::mojom::SafeBrowsing* safe_browsing_; 47 chrome::mojom::SafeBrowsing* safe_browsing_;
48 const int render_frame_id_; 48 const int render_frame_id_;
49 49
50 chrome::mojom::SafeBrowsingUrlCheckerPtr url_checker_; 50 chrome::mojom::SafeBrowsingUrlCheckerPtr url_checker_;
51 51
52 size_t pending_checks_ = 0; 52 size_t pending_checks_ = 0;
53 bool blocked_ = false; 53 bool blocked_ = false;
54 54
55 base::WeakPtrFactory<SafeBrowsingURLLoaderThrottle> weak_factory_; 55 base::WeakPtrFactory<SafeBrowsingRendererThrottle> weak_factory_;
56 }; 56 };
57 57
58 } // namespace safe_browsing 58 } // namespace safe_browsing
59 59
60 #endif // CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_URL_LOADER_THROTTLE_H_ 60 #endif // CHROME_RENDERER_SAFE_BROWSING_SAFE_BROWSING_RENDERER_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698