OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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/extensions/extension_resource_protocols.h" |
| 6 |
| 7 #include "base/file_path.h" |
| 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension_file_util.h" |
| 11 #include "net/url_request/url_request_file_job.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 class ExtensionResourceProtocolHandler |
| 16 : public net::URLRequestJobFactory::ProtocolHandler { |
| 17 public: |
| 18 ExtensionResourceProtocolHandler() {} |
| 19 virtual ~ExtensionResourceProtocolHandler() {} |
| 20 |
| 21 virtual net::URLRequestJob* MaybeCreateJob( |
| 22 net::URLRequest* request) const OVERRIDE; |
| 23 |
| 24 private: |
| 25 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| 26 }; |
| 27 |
| 28 class ExtensionResourcesJob : public net::URLRequestFileJob { |
| 29 }; |
| 30 |
| 31 // Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| 32 net::URLRequestJob* |
| 33 ExtensionResourceProtocolHandler::MaybeCreateJob( |
| 34 net::URLRequest* request) const { |
| 35 FilePath root_path; |
| 36 PathService::Get(chrome::DIR_RESOURCES_EXTENSION, &root_path); |
| 37 FilePath path = |
| 38 extension_file_util::ExtensionResourceURLToFilePath( |
| 39 request->url(), root_path); |
| 40 return new net::URLRequestFileJob(request, path); |
| 41 } |
| 42 |
| 43 } // namespace |
| 44 |
| 45 net::URLRequestJobFactory::ProtocolHandler* |
| 46 CreateExtensionResourceProtocolHandler() { |
| 47 return new ExtensionResourceProtocolHandler(); |
| 48 } |
OLD | NEW |