1 // Copyright 2019 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 "fuchsia/engine/renderer/web_engine_url_loader_throttle_provider.h"
6 
7 #include "content/public/renderer/render_frame.h"
8 #include "fuchsia/engine/common/web_engine_url_loader_throttle.h"
9 #include "fuchsia/engine/renderer/web_engine_content_renderer_client.h"
10 
WebEngineURLLoaderThrottleProvider(WebEngineContentRendererClient * content_renderer_client)11 WebEngineURLLoaderThrottleProvider::WebEngineURLLoaderThrottleProvider(
12     WebEngineContentRendererClient* content_renderer_client)
13     : content_renderer_client_(content_renderer_client) {
14   DETACH_FROM_SEQUENCE(sequence_checker_);
15 }
16 
~WebEngineURLLoaderThrottleProvider()17 WebEngineURLLoaderThrottleProvider::~WebEngineURLLoaderThrottleProvider() {
18   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
19 }
20 
21 std::unique_ptr<content::URLLoaderThrottleProvider>
Clone()22 WebEngineURLLoaderThrottleProvider::Clone() {
23   // This should only happen for service workers, which we do not support here.
24   NOTREACHED();
25   return nullptr;
26 }
27 
28 std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateThrottles(int render_frame_id,const blink::WebURLRequest & request)29 WebEngineURLLoaderThrottleProvider::CreateThrottles(
30     int render_frame_id,
31     const blink::WebURLRequest& request) {
32   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
33 
34   std::vector<std::unique_ptr<blink::URLLoaderThrottle>> throttles;
35   throttles.emplace_back(std::make_unique<WebEngineURLLoaderThrottle>(
36       content_renderer_client_->GetUrlRequestRulesReceiverForRenderFrameId(
37           render_frame_id)));
38   return throttles;
39 }
40 
SetOnline(bool is_online)41 void WebEngineURLLoaderThrottleProvider::SetOnline(bool is_online) {}
42