blob: 0c9272148c20c888c9b767246b50207a0db3a2e5 [file] [log] [blame]
[email protected]ac039522010-06-15 16:39:441// Copyright (c) 2010 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 "chrome/browser/net/chrome_network_delegate.h"
6
7#include "base/logging.h"
[email protected]d05ef99c2011-02-01 21:38:168#include "chrome/browser/extensions/extension_webrequest_api.h"
9#include "chrome/browser/net/chrome_url_request_context.h"
[email protected]ac039522010-06-15 16:39:4410#include "net/http/http_request_headers.h"
[email protected]d05ef99c2011-02-01 21:38:1611#include "net/url_request/url_request.h"
12
13namespace {
14
15// Get the event router from the request context. Currently only
16// ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to
17// work.
18const ExtensionIOEventRouter* GetIOEventRouter(
19 net::URLRequestContext* context) {
20 return static_cast<ChromeURLRequestContext*>(context)->
21 extension_io_event_router();
22}
23
24} // namespace
[email protected]ac039522010-06-15 16:39:4425
26ChromeNetworkDelegate::ChromeNetworkDelegate() {}
27ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
28
[email protected]d05ef99c2011-02-01 21:38:1629void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
30 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
31 GetIOEventRouter(request->context()), request->url(), request->method());
32}
33
[email protected]ac039522010-06-15 16:39:4434void ChromeNetworkDelegate::OnSendHttpRequest(
35 net::HttpRequestHeaders* headers) {
36 DCHECK(headers);
[email protected]a39eabd2010-08-10 03:59:2437
[email protected]ac039522010-06-15 16:39:4438 // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here.
39}