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

Side by Side Diff: components/safe_browsing/renderer/websocket_sb_handshake_throttle.h

Issue 2952583002: SafeBrowsing support for WebSocket (post-network-servicification) (Closed)
Patch Set: Share SafeBrowsing interface pointer, and misc fixes 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
(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 // Implementation of SafeBrowsing for WebSockets. This code runs inside the
6 // render process, calling the interface defined in safe_browsing.mojom to
7 // communicate with the SafeBrowsing service.
8
9 #ifndef COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_
10 #define COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_
11
12 #include <memory>
13
14 #include "base/macros.h"
15 #include "components/safe_browsing/common/safe_browsing.mojom.h"
16 #include "third_party/WebKit/public/platform/WebCallbacks.h"
17 #include "third_party/WebKit/public/platform/WebSocketHandshakeThrottle.h"
18 #include "url/gurl.h"
19
20 namespace safe_browsing {
21
22 class WebSocketSBHandshakeThrottle : public blink::WebSocketHandshakeThrottle {
23 public:
24 // Returns nullptr if the network service is not enabled.
25 // Otherwise returns a WebSocketSBHandshakeThrottle after lazily initialising
26 // |*safe_browsing_service|. |*safe_browsing_service| is required to out-live
27 // this object.
28 static std::unique_ptr<WebSocketSBHandshakeThrottle> MaybeCreate(
29 mojom::SafeBrowsingPtr* save_browsing_service);
30
31 explicit WebSocketSBHandshakeThrottle(mojom::SafeBrowsing* safe_browsing);
32 ~WebSocketSBHandshakeThrottle() override;
33
34 void ThrottleHandshake(
35 const blink::WebURL& url,
36 blink::WebLocalFrame* web_local_frame,
37 blink::WebCallbacks<void, const blink::WebString&>* callbacks) override;
38
39 private:
40 void OnCheckResult(bool safe);
41
42 GURL url_;
43 blink::WebCallbacks<void, const blink::WebString&>* callbacks_;
44 mojom::SafeBrowsingUrlCheckerPtr url_checker_;
45 mojom::SafeBrowsing* safe_browsing_;
46
47 base::WeakPtrFactory<WebSocketSBHandshakeThrottle> weak_factory_;
48
49 DISALLOW_COPY_AND_ASSIGN(WebSocketSBHandshakeThrottle);
50 };
51
52 } // namespace safe_browsing
53
54 #endif // COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698