Chromium Code Reviews| Index: chrome/browser/extensions/extension_protocols.cc |
| diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc |
| index 4b551533b00188845870845d9d44b1bd55a41d48..3e3b5e535f42a59710728ace7b87b622b1b28f27 100644 |
| --- a/chrome/browser/extensions/extension_protocols.cc |
| +++ b/chrome/browser/extensions/extension_protocols.cc |
| @@ -240,7 +240,7 @@ class ExtensionProtocolHandler |
| DISALLOW_COPY_AND_ASSIGN(ExtensionProtocolHandler); |
| }; |
| -// Creates URLRequestJobs for extension:// URLs. |
| +// Creates URLRequestJobs for chrome-extension:// URLs. |
| net::URLRequestJob* |
| ExtensionProtocolHandler::MaybeCreateJob(net::URLRequest* request) const { |
| // TODO(mpcomplete): better error code. |
| @@ -322,6 +322,33 @@ ExtensionProtocolHandler::MaybeCreateJob(net::URLRequest* request) const { |
| content_security_policy, send_cors_header); |
| } |
| +class ExtensionResourceProtocolHandler |
| + : public net::URLRequestJobFactory::ProtocolHandler { |
| + public: |
| + ExtensionResourceProtocolHandler() {} |
| + virtual ~ExtensionResourceProtocolHandler() {} |
| + |
| + virtual net::URLRequestJob* MaybeCreateJob( |
| + net::URLRequest* request) const OVERRIDE; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| +}; |
| + |
| +// Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| +net::URLRequestJob* |
| +ExtensionResourceProtocolHandler::MaybeCreateJob( |
| + net::URLRequest* request) const { |
| + if (!request->url().has_host() || !request->url().has_path()) |
| + return NULL; |
| + |
| + FilePath path; |
| + PathService::Get(chrome::DIR_RESOURCES_EXTENSION, &path); |
|
miket_OOO
2012/04/12 18:38:39
Is this the EXT from the other CL? Did you want it
Peng
2012/04/12 20:13:22
I renamed it from EXT to extension. Because it is
|
| + path = path.Append(request->url().host()).Append(request->url().path()); |
|
miket_OOO
2012/04/12 18:38:39
I'm not sure whether request has already been sani
Peng
2012/04/12 20:13:22
Done
|
| + |
| + return new net::URLRequestFileJob(request, path); |
| +} |
| + |
| } // namespace |
| net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| @@ -329,3 +356,10 @@ net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| ExtensionInfoMap* extension_info_map) { |
| return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| } |
| + |
| +net::URLRequestJobFactory::ProtocolHandler* |
| +CreateExtensionResourceProtocolHandler( |
| + bool is_incognito, |
| + ExtensionInfoMap* extension_info_map) { |
| + return new ExtensionResourceProtocolHandler(); |
|
miket_OOO
2012/04/12 18:38:39
Is there a reason these arguments need to be in th
Peng
2012/04/12 20:13:22
I copied & pasted it. I think it may be useful in
|
| +} |