[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 1 | // 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] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame^] | 8 | #include "chrome/browser/extensions/extension_webrequest_api.h" |
| 9 | #include "chrome/browser/net/chrome_url_request_context.h" |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 10 | #include "net/http/http_request_headers.h" |
[email protected] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame^] | 11 | #include "net/url_request/url_request.h" |
| 12 | |
| 13 | namespace { |
| 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. |
| 18 | const ExtensionIOEventRouter* GetIOEventRouter( |
| 19 | net::URLRequestContext* context) { |
| 20 | return static_cast<ChromeURLRequestContext*>(context)-> |
| 21 | extension_io_event_router(); |
| 22 | } |
| 23 | |
| 24 | } // namespace |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 25 | |
| 26 | ChromeNetworkDelegate::ChromeNetworkDelegate() {} |
| 27 | ChromeNetworkDelegate::~ChromeNetworkDelegate() {} |
| 28 | |
[email protected] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame^] | 29 | void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) { |
| 30 | ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( |
| 31 | GetIOEventRouter(request->context()), request->url(), request->method()); |
| 32 | } |
| 33 | |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 34 | void ChromeNetworkDelegate::OnSendHttpRequest( |
| 35 | net::HttpRequestHeaders* headers) { |
| 36 | DCHECK(headers); |
[email protected] | a39eabd | 2010-08-10 03:59:24 | [diff] [blame] | 37 | |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 38 | // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here. |
| 39 | } |