fix: make webRequest work with WebSocket (#22040)

* fix: web request support proxying websocket

* fix: make tests work

* chore: do not use api:: code outside api/ folder

* chore: do not create proxy when no listener

* test: use separate session to avoid conflicts

* chore: address review
This commit is contained in:
Cheng Zhao 2020-02-11 14:56:09 +09:00 committed by GitHub
parent 80dd16aa78
commit c608d6d7fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 897 additions and 59 deletions

View file

@ -173,6 +173,15 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
int render_process_id,
int render_frame_id,
NonNetworkURLLoaderFactoryMap* factories) override;
void CreateWebSocket(
content::RenderFrameHost* frame,
WebSocketFactory factory,
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const base::Optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) override;
bool WillInterceptWebSocket(content::RenderFrameHost*) override;
bool WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame,
@ -290,6 +299,10 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
bool disable_process_restart_tricks_ = false;
// Simple shared ID generator, used by ProxyingURLLoaderFactory and
// ProxyingWebSocket classes.
uint64_t next_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(ElectronBrowserClient);
};