2019-07-24 23:12:00 +02:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "libcef/renderer/alloy/url_loader_throttle_provider_impl.h"
|
2019-07-24 23:12:00 +02:00
|
|
|
|
|
|
|
#include "libcef/common/extensions/extensions_util.h"
|
2023-04-26 21:55:59 +02:00
|
|
|
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "libcef/renderer/alloy/alloy_render_thread_observer.h"
|
2019-07-24 23:12:00 +02:00
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "base/feature_list.h"
|
2019-09-25 15:59:51 +02:00
|
|
|
#include "chrome/common/google_url_loader_throttle.h"
|
2023-04-26 21:55:59 +02:00
|
|
|
#include "components/signin/public/base/signin_buildflags.h"
|
2019-07-24 23:12:00 +02:00
|
|
|
#include "content/public/common/content_features.h"
|
|
|
|
#include "content/public/renderer/render_frame.h"
|
|
|
|
#include "services/network/public/cpp/features.h"
|
2020-03-30 22:13:42 +02:00
|
|
|
#include "third_party/blink/public/common/loader/resource_type_util.h"
|
2019-07-24 23:12:00 +02:00
|
|
|
#include "third_party/blink/public/platform/web_url.h"
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
|
2023-04-26 21:55:59 +02:00
|
|
|
blink::URLLoaderThrottleProviderType type,
|
|
|
|
AlloyContentRendererClient* alloy_content_renderer_client)
|
|
|
|
: type_(type),
|
|
|
|
alloy_content_renderer_client_(alloy_content_renderer_client) {
|
2024-03-19 22:11:42 +01:00
|
|
|
DETACH_FROM_SEQUENCE(sequence_checker_);
|
2019-07-24 23:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::~CefURLLoaderThrottleProviderImpl() {
|
2024-03-19 22:11:42 +01:00
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
2019-07-24 23:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
|
|
|
|
const CefURLLoaderThrottleProviderImpl& other)
|
2023-04-26 21:55:59 +02:00
|
|
|
: type_(other.type_),
|
|
|
|
alloy_content_renderer_client_(other.alloy_content_renderer_client_) {
|
2024-03-19 22:11:42 +01:00
|
|
|
DETACH_FROM_SEQUENCE(sequence_checker_);
|
2019-07-24 23:12:00 +02:00
|
|
|
}
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
std::unique_ptr<blink::URLLoaderThrottleProvider>
|
2019-07-24 23:12:00 +02:00
|
|
|
CefURLLoaderThrottleProviderImpl::Clone() {
|
2024-03-19 22:11:42 +01:00
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
2019-07-24 23:12:00 +02:00
|
|
|
return base::WrapUnique(new CefURLLoaderThrottleProviderImpl(*this));
|
|
|
|
}
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>>
|
2019-07-24 23:12:00 +02:00
|
|
|
CefURLLoaderThrottleProviderImpl::CreateThrottles(
|
2023-12-06 21:16:15 +01:00
|
|
|
base::optional_ref<const blink::LocalFrameToken> local_frame_token,
|
2024-01-26 03:12:43 +01:00
|
|
|
const network::ResourceRequest& request) {
|
2024-03-19 22:11:42 +01:00
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
2019-07-24 23:12:00 +02:00
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>> throttles;
|
2019-07-24 23:12:00 +02:00
|
|
|
|
|
|
|
// Some throttles have already been added in the browser for frame resources.
|
|
|
|
// Don't add them for frame requests.
|
2020-03-30 22:13:42 +02:00
|
|
|
bool is_frame_resource =
|
2024-01-26 03:12:43 +01:00
|
|
|
blink::IsRequestDestinationFrame(request.destination);
|
2019-07-24 23:12:00 +02:00
|
|
|
|
|
|
|
DCHECK(!is_frame_resource ||
|
2021-04-21 00:52:34 +02:00
|
|
|
type_ == blink::URLLoaderThrottleProviderType::kFrame);
|
2019-07-24 23:12:00 +02:00
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
throttles.emplace_back(std::make_unique<GoogleURLLoaderThrottle>(
|
2023-04-26 21:55:59 +02:00
|
|
|
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
|
|
|
|
/*bound_session_request_throttled_listener=*/nullptr,
|
|
|
|
#endif
|
|
|
|
alloy_content_renderer_client_->GetAlloyObserver()->GetDynamicParams()));
|
2019-09-25 15:59:51 +02:00
|
|
|
|
2019-07-24 23:12:00 +02:00
|
|
|
return throttles;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefURLLoaderThrottleProviderImpl::SetOnline(bool is_online) {}
|