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 // 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 // Create a WebSocketSBHandshakeThrottle if the network service is enabled, |
| 25 // otherwise return null. |
| 26 static std::unique_ptr<WebSocketSBHandshakeThrottle> MaybeCreate(); |
| 27 |
| 28 explicit WebSocketSBHandshakeThrottle(mojom::SafeBrowsingPtr safe_browsing); |
| 29 ~WebSocketSBHandshakeThrottle() override; |
| 30 |
| 31 void ThrottleHandshake( |
| 32 const blink::WebURL& url, |
| 33 blink::WebLocalFrame* web_local_frame, |
| 34 blink::WebCallbacks<void, const blink::WebString&>* callbacks) override; |
| 35 |
| 36 private: |
| 37 void OnCheckResult(bool safe); |
| 38 |
| 39 GURL url_; |
| 40 blink::WebCallbacks<void, const blink::WebString&>* callbacks_; |
| 41 mojom::SafeBrowsingUrlCheckerPtr url_checker_; |
| 42 mojom::SafeBrowsingPtr safe_browsing_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(WebSocketSBHandshakeThrottle); |
| 45 }; |
| 46 |
| 47 } // namespace safe_browsing |
| 48 |
| 49 #endif // COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_ |
OLD | NEW |