Index: components/safe_browsing/renderer/websocket_sb_handshake_throttle.h |
diff --git a/components/safe_browsing/renderer/websocket_sb_handshake_throttle.h b/components/safe_browsing/renderer/websocket_sb_handshake_throttle.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9945343a08efb040e7ebfae4271d0bd37e9bb8ec |
--- /dev/null |
+++ b/components/safe_browsing/renderer/websocket_sb_handshake_throttle.h |
@@ -0,0 +1,49 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Implementation of SafeBrowsing for WebSockets. This code runs inside the |
+// render process, calling the interface defined in safe_browsing.mojom to |
+// communicate with the SafeBrowsing service. |
+ |
+#ifndef COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_ |
+#define COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_ |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "components/safe_browsing/common/safe_browsing.mojom.h" |
+#include "third_party/WebKit/public/platform/WebCallbacks.h" |
+#include "third_party/WebKit/public/platform/WebSocketHandshakeThrottle.h" |
+#include "url/gurl.h" |
+ |
+namespace safe_browsing { |
+ |
+class WebSocketSBHandshakeThrottle : public blink::WebSocketHandshakeThrottle { |
+ public: |
+ // Create a WebSocketSBHandshakeThrottle if the network service is enabled, |
+ // otherwise return null. |
+ static std::unique_ptr<WebSocketSBHandshakeThrottle> MaybeCreate(); |
+ |
+ explicit WebSocketSBHandshakeThrottle(mojom::SafeBrowsingPtr safe_browsing); |
+ ~WebSocketSBHandshakeThrottle() override; |
+ |
+ void ThrottleHandshake( |
+ const blink::WebURL& url, |
+ blink::WebLocalFrame* web_local_frame, |
+ blink::WebCallbacks<void, const blink::WebString&>* callbacks) override; |
+ |
+ private: |
+ void OnCheckResult(bool safe); |
+ |
+ GURL url_; |
+ blink::WebCallbacks<void, const blink::WebString&>* callbacks_; |
+ mojom::SafeBrowsingUrlCheckerPtr url_checker_; |
+ mojom::SafeBrowsingPtr safe_browsing_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebSocketSBHandshakeThrottle); |
+}; |
+ |
+} // namespace safe_browsing |
+ |
+#endif // COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_ |