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..ca922d1e7a22fdec1ef19625efc68a51e90c95de |
--- /dev/null |
+++ b/components/safe_browsing/renderer/websocket_sb_handshake_throttle.h |
@@ -0,0 +1,54 @@ |
+// 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: |
+ // Returns nullptr if the network service is not enabled. |
+ // Otherwise returns a WebSocketSBHandshakeThrottle after lazily initialising |
+ // |*safe_browsing_service|. |*safe_browsing_service| is required to out-live |
+ // this object. |
+ static std::unique_ptr<WebSocketSBHandshakeThrottle> MaybeCreate( |
+ mojom::SafeBrowsingPtr* save_browsing_service); |
+ |
+ explicit WebSocketSBHandshakeThrottle(mojom::SafeBrowsing* 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::SafeBrowsing* safe_browsing_; |
+ |
+ base::WeakPtrFactory<WebSocketSBHandshakeThrottle> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebSocketSBHandshakeThrottle); |
+}; |
+ |
+} // namespace safe_browsing |
+ |
+#endif // COMPONENTS_SAFE_BROWSING_RENDERER_WEBSOCKET_SB_HANDSHAKE_THROTTLE_H_ |