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) {
|
2019-07-24 23:12:00 +02:00
|
|
|
DETACH_FROM_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::~CefURLLoaderThrottleProviderImpl() {
|
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_) {
|
2019-07-24 23:12:00 +02:00
|
|
|
DETACH_FROM_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
std::unique_ptr<blink::URLLoaderThrottleProvider>
|
2019-07-24 23:12:00 +02:00
|
|
|
CefURLLoaderThrottleProviderImpl::Clone() {
|
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
|
|
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(
|
|
|
|
int render_frame_id,
|
2020-03-30 22:13:42 +02:00
|
|
|
const blink::WebURLRequest& request) {
|
2019-07-24 23:12:00 +02:00
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>> throttles;
|
2019-07-24 23:12:00 +02:00
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
const network::mojom::RequestDestination request_destination =
|
|
|
|
request.GetRequestDestination();
|
|
|
|
|
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 =
|
|
|
|
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) {}
|