Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / net / chrome_extensions_network_delegate.h
blob156094cd30bc2aaedebcd78ae7a5460f40af82dc
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_
6 #define CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "net/base/network_delegate_impl.h"
13 namespace extensions {
14 class EventRouterForwarder;
15 class InfoMap;
18 // ChromeExtensionsNetworkDelegate is the extensions-only portion of
19 // ChromeNetworkDelegate. When extensions are disabled, do nothing.
20 class ChromeExtensionsNetworkDelegate : public net::NetworkDelegateImpl {
21 public:
22 static ChromeExtensionsNetworkDelegate* Create(
23 extensions::EventRouterForwarder* event_router);
25 ~ChromeExtensionsNetworkDelegate() override;
27 // Not inlined because we assign a scoped_refptr, which requires us to include
28 // the header file.
29 void set_extension_info_map(extensions::InfoMap* extension_info_map);
31 // If |profile| is NULL or not set, events will be broadcast to all profiles,
32 // otherwise they will only be sent to the specified profile.
33 void set_profile(void* profile) {
34 profile_ = profile;
37 // If the |request| failed due to problems with a proxy, forward the error to
38 // the proxy extension API.
39 virtual void ForwardProxyErrors(net::URLRequest* request);
41 // Notifies the extensions::ProcessManager for the associated RenderFrame, if
42 // any, that a request has started or stopped.
43 virtual void ForwardStartRequestStatus(net::URLRequest* request);
44 virtual void ForwardDoneRequestStatus(net::URLRequest* request);
46 // NetworkDelegate implementation.
47 int OnBeforeURLRequest(net::URLRequest* request,
48 const net::CompletionCallback& callback,
49 GURL* new_url) override;
50 int OnBeforeSendHeaders(net::URLRequest* request,
51 const net::CompletionCallback& callback,
52 net::HttpRequestHeaders* headers) override;
53 void OnSendHeaders(net::URLRequest* request,
54 const net::HttpRequestHeaders& headers) override;
55 int OnHeadersReceived(
56 net::URLRequest* request,
57 const net::CompletionCallback& callback,
58 const net::HttpResponseHeaders* original_response_headers,
59 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
60 GURL* allowed_unsafe_redirect_url) override;
61 void OnBeforeRedirect(net::URLRequest* request,
62 const GURL& new_location) override;
63 void OnResponseStarted(net::URLRequest* request) override;
64 void OnCompleted(net::URLRequest* request, bool started) override;
65 void OnURLRequestDestroyed(net::URLRequest* request) override;
66 void OnPACScriptError(int line_number, const base::string16& error) override;
67 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
68 net::URLRequest* request,
69 const net::AuthChallengeInfo& auth_info,
70 const AuthCallback& callback,
71 net::AuthCredentials* credentials) override;
73 protected:
74 ChromeExtensionsNetworkDelegate();
76 void* profile_;
78 #if defined(ENABLE_EXTENSIONS)
79 scoped_refptr<extensions::InfoMap> extension_info_map_;
80 #endif
82 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegate);
85 #endif // CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_