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

Unified 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698