electron/shell/browser/net/url_loader_network_observer.cc
electron-roller[bot] 7d05b78479
chore: bump chromium to 133.0.6920.0 (main) (#45055)
* chore: bump chromium in DEPS to 133.0.6902.0

* chore: bump chromium in DEPS to 133.0.6903.0

* chore: update patches

* Update PdfViewer Save File Picker to use showSaveFilePicker.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6074308

* Code Health: Clean up stale MacWebContentsOcclusion

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6078344

* Change RenderProcessHost::GetID to RenderProcessHost::GetDeprecatedID

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6065543

* [WebRTC] Make WebRTC IP Handling policy a mojo enum

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6063620

* chore: gen filenames.libcxx.gni

* Remove allow_unsafe_buffers pragma in //printing

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6092280

* refactor: to use ChildProcessId where possible

Refs https://issues.chromium.org/issues/379869738

* [Win] Update TabletMode detection code

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6003486

* chore: bump chromium in DEPS to 133.0.6905.0

* chore: update patches

* Reland "Move global shortcut listener to //ui/base"

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6099035

* [shared storage] Implement the batch `with_lock` option for response header

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6072742

* chore: bump chromium in DEPS to 133.0.6907.0

* chore: bump chromium in DEPS to 133.0.6909.0

* chore: bump chromium in DEPS to 133.0.6911.0

* chore: bump chromium in DEPS to 133.0.6912.0

* chore: update patches

* WebUI: Reveal hidden deps to ui/webui/resources.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6096291

* chore: bump chromium in DEPS to 133.0.6913.0

* chore: bump chromium in DEPS to 133.0.6915.0

* Code Health: Clean up stale base::Feature "AccessibilityTreeForViews"

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6104174

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* fix: remove fastapitypedarray usage

* chore: update patches

* chore: script/gen-libc++-filenames.js

* Code Health: Clean up stale base::Feature "WinRetrieveSuggestionsOnlyOnDemand"

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6109477

* fix: empty suggestions with windows platform checker

Amends the fix from https://github.com/electron/electron/pull/29690
since the feature flag is no longer available. We follow the
same pattern as //chrome/browser/renderer_context_menu/spelling_menu_observer.cc
to generate the suggestion list on demand when context menu action
is invoked.

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* fixup! fix: empty suggestions with windows platform checker

* fixup! fix: empty suggestions with windows platform checker

* revert: 6078344: Code Health: Clean up stale MacWebContentsOcclusion | https://chromium-review.googlesource.com/c/chromium/src/+/6078344

* Revert "revert: 6078344: Code Health: Clean up stale MacWebContentsOcclusion | https://chromium-review.googlesource.com/c/chromium/src/+/6078344"

This reverts commit 9cacda452ed5a072351e8f5a35b009d91843a08c.

* chore: bump to 133.0.6920.0, update patches

* Revert "6078344: Code Health: Clean up stale MacWebContentsOcclusion"

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/6078344

* fixup! Update PdfViewer Save File Picker to use showSaveFilePicker.

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
2025-01-10 10:52:34 -06:00

125 lines
4.1 KiB
C++

// Copyright (c) 2024 Microsoft, GmbH
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/net/url_loader_network_observer.h"
#include "base/functional/bind.h"
#include "content/public/browser/browser_thread.h"
#include "services/network/public/mojom/shared_storage.mojom.h"
#include "shell/browser/login_handler.h"
namespace electron {
namespace {
class LoginHandlerDelegate {
public:
LoginHandlerDelegate(
mojo::PendingRemote<network::mojom::AuthChallengeResponder>
auth_challenge_responder,
const net::AuthChallengeInfo& auth_info,
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
base::ProcessId process_id,
bool first_auth_attempt)
: auth_challenge_responder_(std::move(auth_challenge_responder)) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auth_challenge_responder_.set_disconnect_handler(base::BindOnce(
&LoginHandlerDelegate::OnRequestCancelled, base::Unretained(this)));
login_handler_ = std::make_unique<LoginHandler>(
auth_info, nullptr /*web_contents*/,
false /*is_request_for_primary_main_frame*/,
false /*bool is_request_for_navigation*/, process_id, url,
response_headers, first_auth_attempt,
base::BindOnce(&LoginHandlerDelegate::OnAuthCredentials,
weak_factory_.GetWeakPtr()));
}
private:
void OnRequestCancelled() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
delete this;
}
void OnAuthCredentials(
const std::optional<net::AuthCredentials>& auth_credentials) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auth_challenge_responder_->OnAuthCredentials(auth_credentials);
delete this;
}
mojo::Remote<network::mojom::AuthChallengeResponder>
auth_challenge_responder_;
std::unique_ptr<LoginHandler> login_handler_;
base::WeakPtrFactory<LoginHandlerDelegate> weak_factory_{this};
};
} // namespace
URLLoaderNetworkObserver::URLLoaderNetworkObserver() = default;
URLLoaderNetworkObserver::~URLLoaderNetworkObserver() = default;
mojo::PendingRemote<network::mojom::URLLoaderNetworkServiceObserver>
URLLoaderNetworkObserver::Bind() {
mojo::PendingRemote<network::mojom::URLLoaderNetworkServiceObserver>
pending_remote;
receivers_.Add(this, pending_remote.InitWithNewPipeAndPassReceiver());
return pending_remote;
}
void URLLoaderNetworkObserver::OnAuthRequired(
const std::optional<base::UnguessableToken>& window_id,
int32_t request_id,
const GURL& url,
bool first_auth_attempt,
const net::AuthChallengeInfo& auth_info,
const scoped_refptr<net::HttpResponseHeaders>& head_headers,
mojo::PendingRemote<network::mojom::AuthChallengeResponder>
auth_challenge_responder) {
new LoginHandlerDelegate(std::move(auth_challenge_responder), auth_info, url,
head_headers, process_id_, first_auth_attempt);
}
void URLLoaderNetworkObserver::OnSSLCertificateError(
const GURL& url,
int net_error,
const net::SSLInfo& ssl_info,
bool fatal,
OnSSLCertificateErrorCallback response) {
std::move(response).Run(net_error);
}
void URLLoaderNetworkObserver::OnClearSiteData(
const GURL& url,
const std::string& header_value,
int32_t load_flags,
const std::optional<net::CookiePartitionKey>& cookie_partition_key,
bool partitioned_state_allowed_only,
OnClearSiteDataCallback callback) {
std::move(callback).Run();
}
void URLLoaderNetworkObserver::OnLoadingStateUpdate(
network::mojom::LoadInfoPtr info,
OnLoadingStateUpdateCallback callback) {
std::move(callback).Run();
}
void URLLoaderNetworkObserver::OnSharedStorageHeaderReceived(
const url::Origin& request_origin,
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods,
const std::optional<std::string>& with_lock,
OnSharedStorageHeaderReceivedCallback callback) {
std::move(callback).Run();
}
void URLLoaderNetworkObserver::Clone(
mojo::PendingReceiver<network::mojom::URLLoaderNetworkServiceObserver>
observer) {
receivers_.Add(this, std::move(observer));
}
} // namespace electron