forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension_url_loader_throttle.cc
55 lines (42 loc) · 1.78 KB
/
extension_url_loader_throttle.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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.
#include "extensions/renderer/extension_url_loader_throttle.h"
#include "extensions/renderer/extension_throttle_manager.h"
namespace extensions {
namespace {
const char kCancelReason[] = "ExtensionURLLoaderThrottle";
} // anonymous namespace
ExtensionURLLoaderThrottle::ExtensionURLLoaderThrottle(
ExtensionThrottleManager* manager)
: manager_(manager) {
DCHECK(manager_);
}
ExtensionURLLoaderThrottle::~ExtensionURLLoaderThrottle() = default;
void ExtensionURLLoaderThrottle::WillStartRequest(
network::ResourceRequest* request,
bool* defer) {
start_request_url_ = request->url;
request_load_flags_ = request->load_flags;
if (manager_->ShouldRejectRequest(start_request_url_, request_load_flags_))
delegate_->CancelWithError(net::ERR_TEMPORARILY_THROTTLED, kCancelReason);
}
void ExtensionURLLoaderThrottle::WillRedirectRequest(
const net::RedirectInfo& redirect_info,
const network::ResourceResponseHead& /* response_head */,
bool* /* defer */,
std::vector<std::string>* /* to_be_removed_request_headers */,
net::HttpRequestHeaders* /* modified_request_headers */) {
if (manager_->ShouldRejectRedirect(start_request_url_, request_load_flags_,
redirect_info)) {
delegate_->CancelWithError(net::ERR_TEMPORARILY_THROTTLED, kCancelReason);
}
}
void ExtensionURLLoaderThrottle::WillProcessResponse(
const GURL& response_url,
network::ResourceResponseHead* response_head,
bool* defer) {
manager_->WillProcessResponse(response_url, *response_head);
}
void ExtensionURLLoaderThrottle::DetachFromCurrentSequence() {}
} // namespace extensions