| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/extensions/extension_resource_protocols.h" | 5 #include "chrome/browser/extensions/extension_resource_protocols.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension_file_util.h" | 10 #include "chrome/common/extensions/extension_file_util.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "net/url_request/url_request_context.h" | |
| 13 #include "net/url_request/url_request_file_job.h" | 12 #include "net/url_request/url_request_file_job.h" |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 class ExtensionResourcesJob : public net::URLRequestFileJob { | 16 class ExtensionResourcesJob : public net::URLRequestFileJob { |
| 18 public: | 17 public: |
| 19 explicit ExtensionResourcesJob(net::URLRequest* request) | 18 ExtensionResourcesJob(net::URLRequest* request, |
| 20 : net::URLRequestFileJob(request, | 19 net::NetworkDelegate* network_delegate) |
| 21 FilePath(), | 20 : net::URLRequestFileJob(request, network_delegate, FilePath()), |
| 22 request->context()->network_delegate()), | 21 thread_id_(content::BrowserThread::UI) { |
| 23 thread_id_(content::BrowserThread::UI) { | |
| 24 } | 22 } |
| 25 | 23 |
| 26 virtual void Start() OVERRIDE; | 24 virtual void Start() OVERRIDE; |
| 27 | 25 |
| 28 protected: | 26 protected: |
| 29 ~ExtensionResourcesJob() {} | 27 ~ExtensionResourcesJob() {} |
| 30 | 28 |
| 31 void ResolvePath(); | 29 void ResolvePath(); |
| 32 void ResolvePathDone(); | 30 void ResolvePathDone(); |
| 33 | 31 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 net::URLRequestFileJob::Start(); | 56 net::URLRequestFileJob::Start(); |
| 59 } | 57 } |
| 60 | 58 |
| 61 class ExtensionResourceProtocolHandler | 59 class ExtensionResourceProtocolHandler |
| 62 : public net::URLRequestJobFactory::ProtocolHandler { | 60 : public net::URLRequestJobFactory::ProtocolHandler { |
| 63 public: | 61 public: |
| 64 ExtensionResourceProtocolHandler() {} | 62 ExtensionResourceProtocolHandler() {} |
| 65 virtual ~ExtensionResourceProtocolHandler() {} | 63 virtual ~ExtensionResourceProtocolHandler() {} |
| 66 | 64 |
| 67 virtual net::URLRequestJob* MaybeCreateJob( | 65 virtual net::URLRequestJob* MaybeCreateJob( |
| 68 net::URLRequest* request) const OVERRIDE; | 66 net::URLRequest* request, |
| 67 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); | 70 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 // Creates URLRequestJobs for chrome-extension-resource:// URLs. | 73 // Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| 75 net::URLRequestJob* | 74 net::URLRequestJob* |
| 76 ExtensionResourceProtocolHandler::MaybeCreateJob( | 75 ExtensionResourceProtocolHandler::MaybeCreateJob( |
| 77 net::URLRequest* request) const { | 76 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 78 return new ExtensionResourcesJob(request); | 77 return new ExtensionResourcesJob(request, network_delegate); |
| 79 } | 78 } |
| 80 | 79 |
| 81 } // namespace | 80 } // namespace |
| 82 | 81 |
| 83 net::URLRequestJobFactory::ProtocolHandler* | 82 net::URLRequestJobFactory::ProtocolHandler* |
| 84 CreateExtensionResourceProtocolHandler() { | 83 CreateExtensionResourceProtocolHandler() { |
| 85 return new ExtensionResourceProtocolHandler(); | 84 return new ExtensionResourceProtocolHandler(); |
| 86 } | 85 } |
| OLD | NEW |