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"
|
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"
|
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(
|
|
|
|
content::URLLoaderThrottleProviderType type)
|
|
|
|
: type_(type) {
|
|
|
|
DETACH_FROM_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::~CefURLLoaderThrottleProviderImpl() {
|
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
|
|
|
|
const CefURLLoaderThrottleProviderImpl& other)
|
|
|
|
: type_(other.type_) {
|
|
|
|
DETACH_FROM_THREAD(thread_checker_);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<content::URLLoaderThrottleProvider>
|
|
|
|
CefURLLoaderThrottleProviderImpl::Clone() {
|
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
|
|
return base::WrapUnique(new CefURLLoaderThrottleProviderImpl(*this));
|
|
|
|
}
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
std::vector<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_);
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
std::vector<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 ||
|
|
|
|
type_ == content::URLLoaderThrottleProviderType::kFrame);
|
|
|
|
|
2019-09-25 15:59:51 +02:00
|
|
|
throttles.push_back(std::make_unique<GoogleURLLoaderThrottle>(
|
2020-09-25 03:40:47 +02:00
|
|
|
AlloyRenderThreadObserver::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) {}
|