Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: extensions/browser/extension_network_delegate.h

Issue 615583003: Introduce NetworkDelegate's implementation in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_NETNETWORK_DELEGATE_H_
6 #define CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_NETNETWORK_DELEGATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "content/shell/browser/shell_network_delegate.h"
9 #include "base/compiler_specific.h" 9 #include "extensions/browser/info_map.h"
10 #include "base/memory/ref_counted.h"
11 #include "net/base/network_delegate.h" 10 #include "net/base/network_delegate.h"
12 11
13 namespace extensions { 12 namespace extensions {
14 class EventRouterForwarder; 13
15 class InfoMap; 14 class InfoMap;
16 }
17 15
18 // ChromeExtensionsNetworkDelegate is the extensions-only portion of 16 class ExtensionNetworkDelegate : public content::ShellNetworkDelegate {
19 // ChromeNetworkDelegate. When extensions are disabled, do nothing.
20 class ChromeExtensionsNetworkDelegate : public net::NetworkDelegate {
21 public: 17 public:
22 static ChromeExtensionsNetworkDelegate* Create( 18 ExtensionNetworkDelegate();
23 extensions::EventRouterForwarder* event_router); 19 virtual ~ExtensionNetworkDelegate();
24 20
25 virtual ~ChromeExtensionsNetworkDelegate(); 21 void set_extension_info_map(extensions::InfoMap* extension_info_map) {
26 22 extension_info_map_ = extension_info_map;
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);
30
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;
35 } 23 }
36 24
37 // If the |request| failed due to problems with a proxy, forward the error to 25 // If |browser_context| is NULL or not set, events will be broadcast to all
38 // the proxy extension API. 26 // browser_contexts, otherwise they will only be sent to the specified
39 virtual void ForwardProxyErrors(net::URLRequest* request); 27 // browser_context.
28 void set_browser_context(void* browser_context) {
29 browser_context_ = browser_context;
30 }
40 31
41 // Notifies the extensions::ProcessManager for the associated RenderFrame, if 32 private:
42 // any, that a request has started or stopped. 33 // ShellNetworkDelegate implementation.
43 virtual void ForwardStartRequestStatus(net::URLRequest* request);
44 virtual void ForwardDoneRequestStatus(net::URLRequest* request);
45
46 // NetworkDelegate implementation.
47 virtual int OnBeforeURLRequest(net::URLRequest* request, 34 virtual int OnBeforeURLRequest(net::URLRequest* request,
48 const net::CompletionCallback& callback, 35 const net::CompletionCallback& callback,
49 GURL* new_url) OVERRIDE; 36 GURL* new_url) OVERRIDE;
50 virtual int OnBeforeSendHeaders(net::URLRequest* request, 37 virtual int OnBeforeSendHeaders(net::URLRequest* request,
51 const net::CompletionCallback& callback, 38 const net::CompletionCallback& callback,
52 net::HttpRequestHeaders* headers) OVERRIDE; 39 net::HttpRequestHeaders* headers) OVERRIDE;
53 virtual void OnSendHeaders(net::URLRequest* request, 40 virtual void OnSendHeaders(net::URLRequest* request,
54 const net::HttpRequestHeaders& headers) OVERRIDE; 41 const net::HttpRequestHeaders& headers) OVERRIDE;
55 virtual int OnHeadersReceived( 42 virtual int OnHeadersReceived(
56 net::URLRequest* request, 43 net::URLRequest* request,
57 const net::CompletionCallback& callback, 44 const net::CompletionCallback& callback,
58 const net::HttpResponseHeaders* original_response_headers, 45 const net::HttpResponseHeaders* original_response_headers,
59 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 46 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
60 GURL* allowed_unsafe_redirect_url) OVERRIDE; 47 GURL* allowed_unsafe_redirect_url) OVERRIDE;
61 virtual void OnBeforeRedirect(net::URLRequest* request, 48 virtual void OnBeforeRedirect(net::URLRequest* request,
62 const GURL& new_location) OVERRIDE; 49 const GURL& new_location) OVERRIDE;
63 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; 50 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
64 virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; 51 virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
65 virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; 52 virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
66 virtual void OnPACScriptError(int line_number, 53 virtual void OnPACScriptError(int line_number,
67 const base::string16& error) OVERRIDE; 54 const base::string16& error) OVERRIDE;
68 virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( 55 virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
69 net::URLRequest* request, 56 net::URLRequest* request,
70 const net::AuthChallengeInfo& auth_info, 57 const net::AuthChallengeInfo& auth_info,
71 const AuthCallback& callback, 58 const AuthCallback& callback,
72 net::AuthCredentials* credentials) OVERRIDE; 59 net::AuthCredentials* credentials) OVERRIDE;
73 60
74 protected: 61 void* browser_context_;
75 ChromeExtensionsNetworkDelegate(); 62 scoped_refptr<extensions::InfoMap> extension_info_map_;
76 63
77 void* profile_; 64 DISALLOW_COPY_AND_ASSIGN(ExtensionNetworkDelegate);
78
79 #if defined(ENABLE_EXTENSIONS)
80 scoped_refptr<extensions::InfoMap> extension_info_map_;
81 #endif
82
83 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegate);
84 }; 65 };
85 66
86 #endif // CHROME_BROWSER_NET_CHROME_EXTENSIONS_NETWORK_DELEGATE_H_ 67 } // namespace extensions
68
69 #endif // EXTENSIONS_BROWSER_EXTENSION_NETNETWORK_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698