Popular sites on the NTP: re-download popular suggestions once per Chrome run
[chromium-blink-merge.git] / chrome / browser / net / chrome_extensions_network_delegate.h
blob0ab2dcebd7043754193f7e66b7dc045891fb3926
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 OnURLRequestJobOrphaned(net::URLRequest* request) override;
67 void OnPACScriptError(int line_number, const base::string16& error) override;
68 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
69 net::URLRequest* request,
70 const net::AuthChallengeInfo& auth_info,
71 const AuthCallback& callback,
72 net::AuthCredentials* credentials) override;
74 protected:
75 ChromeExtensionsNetworkDelegate();
77 void* profile_;
79 #if defined(ENABLE_EXTENSIONS)
80 scoped_refptr<extensions::InfoMap> extension_info_map_;
81 #endif
83 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegate);
86 #endif // CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_