* chore: bump chromium in DEPS to 92.0.4512.6
* 2887336: [CaptureHandle][#2] Propagate CaptureHandleConfig in browser process
https://chromium-review.googlesource.com/c/chromium/src/+/2887336
* refactor: base::Optional -> absl::optional
* chore: fixup patch indices
* chore: bump chromium in DEPS to 92.0.4514.0
* 2899417: Make build work when enable_pdf is set to false.
https://chromium-review.googlesource.com/c/chromium/src/+/2899417
* 2904731: use BrowserContext instead of Profile in PreconnectManager
https://chromium-review.googlesource.com/c/chromium/src/+/2904731
* 2295749: fix: check IsSecureEventInputEnabled in constructor before setting SetPasswordInputEnabled to true
https://chromium-review.googlesource.com/c/chromium/src/+/2295749
* 2893803: Add a GetWebView to RenderFrame.
https://chromium-review.googlesource.com/c/chromium/src/+/2893803
* 2892345: Implement WebContents::ForEachRenderFrameHost
https://chromium-review.googlesource.com/c/chromium/src/+/2892345
* chore: fixup patch indices
* 2892048: Real instance methods for BrowserContext: remaining 5 methods.
https://chromium-review.googlesource.com/c/chromium/src/+/2892048
* 2902821: [mojo] Don't require full header includes for referenced interfaces
https://chromium-review.googlesource.com/c/chromium/src/+/2902821
* 2496500: Remove last deprecated extension Event ctor.
https://chromium-review.googlesource.com/c/chromium/src/+/2496500
* chore: fixup malformed pepper support patch
* chore: bump chromium in DEPS to 92.0.4515.0
* 2908461: Add CreateEmptyPrintPagesParamsPtr() inside print_view_manager_base.cc.
https://chromium-review.googlesource.com/c/chromium/src/+/2908461
* 2880838: viz: add optional HDRMetadata to TransferableResource
https://chromium-review.googlesource.com/c/chromium/src/+/2880838
* chore: fixup patch indices
* chore: bump chromium in DEPS to 92.0.4515.5
* chore: update patches
* chore: bump chromium in DEPS to 92.0.4515.7
* chore: bump chromium in DEPS to 92.0.4515.9
* chore: bump chromium in DEPS to 93.0.4522.0
* chore: bump chromium in DEPS to 93.0.4523.0
* chore: bump chromium in DEPS to 93.0.4524.0
* chore: update patches
* chore: enable_pak_file_integrity_checks was reverted
* chore: update patches
* refactor: base/optional was replaced with absl::optional
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202
* refactor: replace all usages of base::nullopt with absl::nullopt
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202
* chore: add missing base::Contains include
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202
* refactor: replace all usages of base::make_optional with
absl::make_optional
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202
* refactor: replace WorldScriptContext() with GetScriptContextFromWorldId
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893213
* chore: clean up left over opening namespace
Refs: 95bfe6d08f
* chore: add missing base::Contains include
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202
* refactor: replace GetCurrentDisplayIterator with the hard checker
GetCurrentDisplay
This code looks suspicious but if the iterator was invalid before it
will also be invalid now.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893191
* refactor: headers are now passed directly in extensions client
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2918906
* refactor: base::DictionaryValue::empty() has been removed
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2912424
* chore: add missing includes for network URLLoaderFactory
Refs: unknown, probably a side effect of header changes
* refactor: make convenience wrapper around AppendArg
There is no converter FromV8 for base::StringPiece (apparently its not
possible).  So we now take in an std::string and use the construct for
StringPiece to do implicit conversion.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2905544
* chore: add patch
* chore: bump chromium in DEPS to 93.0.4525.0
* chore: update patches
* refactor: CanResize has been de-virtualized
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2485774
* chore: update resource integrity patch
* chore: add character encoding idl patch
* chore: bump chromium in DEPS to 93.0.4526.0
* chore: update patches
* chore: bump chromium in DEPS to 93.0.4527.0
* chore: bump chromium in DEPS to 93.0.4528.0
* chore: update patches
* chore: update idl encoding patch
* chore: bump chromium in DEPS to 93.0.4529.0
* chore: update patches
* chore: bump chromium in DEPS to 93.0.4530.0
* chore: update patches
* fix: only SetCanResize after the widget has been initialized
* chore: add patch for vr on windows gn gen
* spec: fix focus related tests on linux due to delay in focus swap
* chore: remove new usages of base::Optional from main
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
		
	
			
		
			
				
	
	
		
			178 lines
		
	
	
	
		
			7 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			178 lines
		
	
	
	
		
			7 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
// Copyright 2020 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.
 | 
						|
 | 
						|
#ifndef SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_
 | 
						|
#define SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_
 | 
						|
 | 
						|
#include <set>
 | 
						|
#include <string>
 | 
						|
#include <vector>
 | 
						|
 | 
						|
#include "content/public/browser/content_browser_client.h"
 | 
						|
#include "extensions/browser/api/web_request/web_request_info.h"
 | 
						|
#include "mojo/public/cpp/bindings/pending_receiver.h"
 | 
						|
#include "mojo/public/cpp/bindings/receiver.h"
 | 
						|
#include "mojo/public/cpp/bindings/remote.h"
 | 
						|
#include "services/network/public/cpp/resource_request.h"
 | 
						|
#include "services/network/public/mojom/network_context.mojom.h"
 | 
						|
#include "services/network/public/mojom/websocket.mojom.h"
 | 
						|
#include "shell/browser/net/web_request_api_interface.h"
 | 
						|
#include "third_party/abseil-cpp/absl/types/optional.h"
 | 
						|
#include "url/gurl.h"
 | 
						|
#include "url/origin.h"
 | 
						|
 | 
						|
namespace electron {
 | 
						|
 | 
						|
// A ProxyingWebSocket proxies a WebSocket connection and dispatches
 | 
						|
// WebRequest API events.
 | 
						|
//
 | 
						|
// The code is referenced from the
 | 
						|
// extensions::WebRequestProxyingWebSocket class.
 | 
						|
class ProxyingWebSocket : public network::mojom::WebSocketHandshakeClient,
 | 
						|
                          public network::mojom::WebSocketAuthenticationHandler,
 | 
						|
                          public network::mojom::TrustedHeaderClient {
 | 
						|
 public:
 | 
						|
  using WebSocketFactory = content::ContentBrowserClient::WebSocketFactory;
 | 
						|
 | 
						|
  // AuthRequiredResponse indicates how an OnAuthRequired call is handled.
 | 
						|
  enum class AuthRequiredResponse {
 | 
						|
    // No credentials were provided.
 | 
						|
    kNoAction,
 | 
						|
    // AuthCredentials is filled in with a username and password, which should
 | 
						|
    // be used in a response to the provided auth challenge.
 | 
						|
    kSetAuth,
 | 
						|
    // The request should be canceled.
 | 
						|
    kCancelAuth,
 | 
						|
    // The action will be decided asynchronously. |callback| will be invoked
 | 
						|
    // when the decision is made, and one of the other AuthRequiredResponse
 | 
						|
    // values will be passed in with the same semantics as described above.
 | 
						|
    kIoPending,
 | 
						|
  };
 | 
						|
 | 
						|
  ProxyingWebSocket(
 | 
						|
      WebRequestAPI* web_request_api,
 | 
						|
      WebSocketFactory factory,
 | 
						|
      const network::ResourceRequest& request,
 | 
						|
      mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
 | 
						|
          handshake_client,
 | 
						|
      bool has_extra_headers,
 | 
						|
      int process_id,
 | 
						|
      int render_frame_id,
 | 
						|
      content::BrowserContext* browser_context,
 | 
						|
      uint64_t* request_id_generator);
 | 
						|
  ~ProxyingWebSocket() override;
 | 
						|
 | 
						|
  void Start();
 | 
						|
 | 
						|
  // network::mojom::WebSocketHandshakeClient methods:
 | 
						|
  void OnOpeningHandshakeStarted(
 | 
						|
      network::mojom::WebSocketHandshakeRequestPtr request) override;
 | 
						|
  void OnFailure(const std::string& message,
 | 
						|
                 int32_t net_error,
 | 
						|
                 int32_t response_code) override;
 | 
						|
  void OnConnectionEstablished(
 | 
						|
      mojo::PendingRemote<network::mojom::WebSocket> websocket,
 | 
						|
      mojo::PendingReceiver<network::mojom::WebSocketClient> client_receiver,
 | 
						|
      network::mojom::WebSocketHandshakeResponsePtr response,
 | 
						|
      mojo::ScopedDataPipeConsumerHandle readable,
 | 
						|
      mojo::ScopedDataPipeProducerHandle writable) override;
 | 
						|
 | 
						|
  // network::mojom::WebSocketAuthenticationHandler method:
 | 
						|
  void OnAuthRequired(const net::AuthChallengeInfo& auth_info,
 | 
						|
                      const scoped_refptr<net::HttpResponseHeaders>& headers,
 | 
						|
                      const net::IPEndPoint& remote_endpoint,
 | 
						|
                      OnAuthRequiredCallback callback) override;
 | 
						|
 | 
						|
  // network::mojom::TrustedHeaderClient methods:
 | 
						|
  void OnBeforeSendHeaders(const net::HttpRequestHeaders& headers,
 | 
						|
                           OnBeforeSendHeadersCallback callback) override;
 | 
						|
  void OnHeadersReceived(const std::string& headers,
 | 
						|
                         const net::IPEndPoint& endpoint,
 | 
						|
                         OnHeadersReceivedCallback callback) override;
 | 
						|
 | 
						|
  static void StartProxying(
 | 
						|
      WebRequestAPI* web_request_api,
 | 
						|
      WebSocketFactory factory,
 | 
						|
      const GURL& url,
 | 
						|
      const GURL& site_for_cookies,
 | 
						|
      const absl::optional<std::string>& user_agent,
 | 
						|
      mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
 | 
						|
          handshake_client,
 | 
						|
      bool has_extra_headers,
 | 
						|
      int process_id,
 | 
						|
      int render_frame_id,
 | 
						|
      const url::Origin& origin,
 | 
						|
      content::BrowserContext* browser_context,
 | 
						|
      uint64_t* request_id_generator);
 | 
						|
 | 
						|
  WebRequestAPI* web_request_api() { return web_request_api_; }
 | 
						|
 | 
						|
 private:
 | 
						|
  void OnBeforeRequestComplete(int error_code);
 | 
						|
  void OnBeforeSendHeadersComplete(const std::set<std::string>& removed_headers,
 | 
						|
                                   const std::set<std::string>& set_headers,
 | 
						|
                                   int error_code);
 | 
						|
  void ContinueToStartRequest(int error_code);
 | 
						|
  void OnHeadersReceivedComplete(int error_code);
 | 
						|
  void ContinueToHeadersReceived();
 | 
						|
  void OnAuthRequiredComplete(AuthRequiredResponse rv);
 | 
						|
  void OnHeadersReceivedCompleteForAuth(const net::AuthChallengeInfo& auth_info,
 | 
						|
                                        int rv);
 | 
						|
  void ContinueToCompleted();
 | 
						|
 | 
						|
  void PauseIncomingMethodCallProcessing();
 | 
						|
  void ResumeIncomingMethodCallProcessing();
 | 
						|
  void OnError(int error_code);
 | 
						|
  // This is used for detecting errors on mojo connection with the network
 | 
						|
  // service.
 | 
						|
  void OnMojoConnectionErrorWithCustomReason(uint32_t custom_reason,
 | 
						|
                                             const std::string& description);
 | 
						|
  // This is used for detecting errors on mojo connection with original client
 | 
						|
  // (i.e., renderer).
 | 
						|
  void OnMojoConnectionError();
 | 
						|
 | 
						|
  // Passed from api::WebRequest.
 | 
						|
  WebRequestAPI* web_request_api_;
 | 
						|
 | 
						|
  // Saved to feed the api::WebRequest.
 | 
						|
  network::ResourceRequest request_;
 | 
						|
 | 
						|
  WebSocketFactory factory_;
 | 
						|
  mojo::Remote<network::mojom::WebSocketHandshakeClient>
 | 
						|
      forwarding_handshake_client_;
 | 
						|
  mojo::Receiver<network::mojom::WebSocketHandshakeClient>
 | 
						|
      receiver_as_handshake_client_{this};
 | 
						|
  mojo::Receiver<network::mojom::WebSocketAuthenticationHandler>
 | 
						|
      receiver_as_auth_handler_{this};
 | 
						|
  mojo::Receiver<network::mojom::TrustedHeaderClient>
 | 
						|
      receiver_as_header_client_{this};
 | 
						|
 | 
						|
  net::HttpRequestHeaders request_headers_;
 | 
						|
  network::mojom::URLResponseHeadPtr response_;
 | 
						|
  net::AuthCredentials auth_credentials_;
 | 
						|
  OnAuthRequiredCallback auth_required_callback_;
 | 
						|
  scoped_refptr<net::HttpResponseHeaders> override_headers_;
 | 
						|
  std::vector<network::mojom::HttpHeaderPtr> additional_headers_;
 | 
						|
 | 
						|
  OnBeforeSendHeadersCallback on_before_send_headers_callback_;
 | 
						|
  OnHeadersReceivedCallback on_headers_received_callback_;
 | 
						|
 | 
						|
  GURL redirect_url_;
 | 
						|
  bool is_done_ = false;
 | 
						|
  bool has_extra_headers_;
 | 
						|
  mojo::PendingRemote<network::mojom::WebSocket> websocket_;
 | 
						|
  mojo::PendingReceiver<network::mojom::WebSocketClient> client_receiver_;
 | 
						|
  network::mojom::WebSocketHandshakeResponsePtr handshake_response_ = nullptr;
 | 
						|
  mojo::ScopedDataPipeConsumerHandle readable_;
 | 
						|
  mojo::ScopedDataPipeProducerHandle writable_;
 | 
						|
 | 
						|
  extensions::WebRequestInfo info_;
 | 
						|
 | 
						|
  base::WeakPtrFactory<ProxyingWebSocket> weak_factory_{this};
 | 
						|
  DISALLOW_COPY_AND_ASSIGN(ProxyingWebSocket);
 | 
						|
};
 | 
						|
 | 
						|
}  // namespace electron
 | 
						|
 | 
						|
#endif  // SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_
 |