blob: 0c9272148c20c888c9b767246b50207a0db3a2e5 (
plain)
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
|
// Copyright (c) 2010 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 "chrome/browser/net/chrome_network_delegate.h"
#include "base/logging.h"
#include "chrome/browser/extensions/extension_webrequest_api.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "net/http/http_request_headers.h"
#include "net/url_request/url_request.h"
namespace {
// Get the event router from the request context. Currently only
// ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to
// work.
const ExtensionIOEventRouter* GetIOEventRouter(
net::URLRequestContext* context) {
return static_cast<ChromeURLRequestContext*>(context)->
extension_io_event_router();
}
} // namespace
ChromeNetworkDelegate::ChromeNetworkDelegate() {}
ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
GetIOEventRouter(request->context()), request->url(), request->method());
}
void ChromeNetworkDelegate::OnSendHttpRequest(
net::HttpRequestHeaders* headers) {
DCHECK(headers);
// TODO(willchan): Add Chrome-side hooks to listen / mutate requests here.
}
|