blob: e36eaeb2138f1a1865e0ede42e4aabce0d75610f [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2019 The Chromium Authors
Yutaka Hirano8e0b4d432019-07-04 07:12:382// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_CONNECTOR_IMPL_H_
6#define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_CONNECTOR_IMPL_H_
7
Arthur Sonzognic686e8f2024-01-11 08:36:378#include <optional>
Yutaka Hirano8e0b4d432019-07-04 07:12:389#include <string>
10#include <vector>
Arthur Sonzognic686e8f2024-01-11 08:36:3711
Danil Somsikov4c7ee572021-07-01 12:02:0412#include "base/unguessable_token.h"
Yutaka Hirano8e0b4d432019-07-04 07:12:3813#include "content/public/browser/content_browser_client.h"
Matt Menke29a538d2020-04-29 16:12:1714#include "net/base/isolation_info.h"
Chris Fredrickson9ffdf5b2024-07-09 20:05:0915#include "net/storage_access_api/status.h"
Yutaka Hirano8e0b4d432019-07-04 07:12:3816#include "services/network/public/mojom/network_context.mojom.h"
17#include "services/network/public/mojom/websocket.mojom.h"
Yutaka Hirano8e0b4d432019-07-04 07:12:3818#include "third_party/blink/public/mojom/websockets/websocket_connector.mojom.h"
19#include "url/origin.h"
20
21class GURL;
22
23namespace content {
24
25class WebSocketConnectorImpl final : public blink::mojom::WebSocketConnector {
26 public:
27 using WebSocketFactory = ContentBrowserClient::WebSocketFactory;
28
29 // Called on the UI thread.
30 // - For frames, |frame_id| should be their own id.
31 // - For dedicated workers, |frame_id| should be its response document's
32 // frame's id.
33 // - For shared workers and service workers, |frame_id| should be
Tom Sepezcc69c442025-07-17 02:00:3034 // IPC::mojom::kRoutingIdNone because they do not have a frame.
Yutaka Hirano8e0b4d432019-07-04 07:12:3835 WebSocketConnectorImpl(int process_id,
36 int frame_id,
Ehimare Okoyomon4446d8c2019-10-23 12:47:3237 const url::Origin& origin,
Matt Menke29a538d2020-04-29 16:12:1738 const net::IsolationInfo& isolation_info);
Yutaka Hirano8e0b4d432019-07-04 07:12:3839 ~WebSocketConnectorImpl() override;
40
41 // WebSocketConnector implementation
Julie Jeongeun Kim3e973f92019-08-22 08:02:4042 void Connect(const GURL& url,
43 const std::vector<std::string>& requested_protocols,
Maks Orlovichab27e242020-01-07 18:10:3944 const net::SiteForCookies& site_for_cookies,
Arthur Sonzognic686e8f2024-01-11 08:36:3745 const std::optional<std::string>& user_agent,
Chris Fredrickson9ffdf5b2024-07-09 20:05:0946 net::StorageAccessApiStatus storage_access_api_status,
Julie Jeongeun Kim3e973f92019-08-22 08:02:4047 mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
Danil Somsikov4c7ee572021-07-01 12:02:0448 handshake_client,
Arthur Sonzognic686e8f2024-01-11 08:36:3749 const std::optional<base::UnguessableToken>&
Danil Somsikov4c7ee572021-07-01 12:02:0450 throttling_profile_id) override;
Yutaka Hirano8e0b4d432019-07-04 07:12:3851
52 private:
53 static void ConnectCalledByContentBrowserClient(
54 const std::vector<std::string>& requested_protocols,
Maks Orlovichab27e242020-01-07 18:10:3955 const net::SiteForCookies& site_for_cookies,
Chris Fredrickson9ffdf5b2024-07-09 20:05:0956 net::StorageAccessApiStatus storage_access_api_status,
Matt Menke29a538d2020-04-29 16:12:1757 const net::IsolationInfo& isolation_info,
Yutaka Hirano8e0b4d432019-07-04 07:12:3858 int process_id,
59 int frame_id,
60 const url::Origin& origin,
61 uint32_t options,
Arthur Sonzognic686e8f2024-01-11 08:36:3762 std::optional<base::UnguessableToken> throttling_profile_id,
Yutaka Hirano8e0b4d432019-07-04 07:12:3863 const GURL& url,
64 std::vector<network::mojom::HttpHeaderPtr> additional_headers,
Julie Jeongeun Kim3e973f92019-08-22 08:02:4065 mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
66 handshake_client,
Dave Tapuskacb5cbcb2021-02-09 19:10:4567 mojo::PendingRemote<network::mojom::WebSocketAuthenticationHandler>
68 auth_handler,
Julie Jeongeun Kim147816a2019-08-28 00:43:4769 mojo::PendingRemote<network::mojom::TrustedHeaderClient>
70 trusted_header_client);
Yutaka Hirano8e0b4d432019-07-04 07:12:3871
72 const int process_id_;
73 const int frame_id_;
74 const url::Origin origin_;
Matt Menke29a538d2020-04-29 16:12:1775 const net::IsolationInfo isolation_info_;
Yutaka Hirano8e0b4d432019-07-04 07:12:3876};
77
78} // namespace content
79
80#endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_CONNECTOR_IMPL_H_