• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "libcef/renderer/alloy/url_loader_throttle_provider_impl.h"
6 
7 #include "libcef/common/extensions/extensions_util.h"
8 #include "libcef/renderer/alloy/alloy_render_thread_observer.h"
9 
10 #include <utility>
11 
12 #include "base/feature_list.h"
13 #include "chrome/common/google_url_loader_throttle.h"
14 #include "content/public/common/content_features.h"
15 #include "content/public/renderer/render_frame.h"
16 #include "services/network/public/cpp/features.h"
17 #include "third_party/blink/public/common/loader/resource_type_util.h"
18 #include "third_party/blink/public/platform/web_url.h"
19 
CefURLLoaderThrottleProviderImpl(blink::URLLoaderThrottleProviderType type)20 CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
21     blink::URLLoaderThrottleProviderType type)
22     : type_(type) {
23   DETACH_FROM_THREAD(thread_checker_);
24 }
25 
~CefURLLoaderThrottleProviderImpl()26 CefURLLoaderThrottleProviderImpl::~CefURLLoaderThrottleProviderImpl() {
27   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
28 }
29 
CefURLLoaderThrottleProviderImpl(const CefURLLoaderThrottleProviderImpl & other)30 CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
31     const CefURLLoaderThrottleProviderImpl& other)
32     : type_(other.type_) {
33   DETACH_FROM_THREAD(thread_checker_);
34 }
35 
36 std::unique_ptr<blink::URLLoaderThrottleProvider>
Clone()37 CefURLLoaderThrottleProviderImpl::Clone() {
38   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
39   return base::WrapUnique(new CefURLLoaderThrottleProviderImpl(*this));
40 }
41 
42 blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateThrottles(int render_frame_id,const blink::WebURLRequest & request)43 CefURLLoaderThrottleProviderImpl::CreateThrottles(
44     int render_frame_id,
45     const blink::WebURLRequest& request) {
46   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
47 
48   blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>> throttles;
49 
50   const network::mojom::RequestDestination request_destination =
51       request.GetRequestDestination();
52 
53   // Some throttles have already been added in the browser for frame resources.
54   // Don't add them for frame requests.
55   bool is_frame_resource =
56       blink::IsRequestDestinationFrame(request_destination);
57 
58   DCHECK(!is_frame_resource ||
59          type_ == blink::URLLoaderThrottleProviderType::kFrame);
60 
61   throttles.emplace_back(std::make_unique<GoogleURLLoaderThrottle>(
62       AlloyRenderThreadObserver::GetDynamicParams()));
63 
64   return throttles;
65 }
66 
SetOnline(bool is_online)67 void CefURLLoaderThrottleProviderImpl::SetOnline(bool is_online) {}
68