| 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_file_job.h" | 12 #include "net/url_request/url_request_file_job.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class ExtensionResourcesJob : public net::URLRequestFileJob { | 16 class ExtensionResourcesJob : public net::URLRequestFileJob { |
| 17 public: | 17 public: |
| 18 explicit ExtensionResourcesJob(net::URLRequest* request) | 18 explicit ExtensionResourcesJob(net::URLRequest* request, |
| 19 : net::URLRequestFileJob(request, FilePath()), | 19 net::NetworkDelegate* network_delegate) |
| 20 : net::URLRequestFileJob(request, FilePath(), network_delegate), |
| 20 thread_id_(content::BrowserThread::UI) { | 21 thread_id_(content::BrowserThread::UI) { |
| 21 } | 22 } |
| 22 | 23 |
| 23 virtual void Start() OVERRIDE; | 24 virtual void Start() OVERRIDE; |
| 24 | 25 |
| 25 protected: | 26 protected: |
| 26 ~ExtensionResourcesJob() {} | 27 ~ExtensionResourcesJob() {} |
| 27 | 28 |
| 28 void ResolvePath(); | 29 void ResolvePath(); |
| 29 void ResolvePathDone(); | 30 void ResolvePathDone(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 base::Bind(&ExtensionResourcesJob::ResolvePathDone, this)); | 52 base::Bind(&ExtensionResourcesJob::ResolvePathDone, this)); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void ExtensionResourcesJob::ResolvePathDone() { | 55 void ExtensionResourcesJob::ResolvePathDone() { |
| 55 net::URLRequestFileJob::Start(); | 56 net::URLRequestFileJob::Start(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 class ExtensionResourceProtocolHandler | 59 class ExtensionResourceProtocolHandler |
| 59 : public net::URLRequestJobFactory::ProtocolHandler { | 60 : public net::URLRequestJobFactory::ProtocolHandler { |
| 60 public: | 61 public: |
| 61 ExtensionResourceProtocolHandler() {} | 62 explicit ExtensionResourceProtocolHandler( |
| 63 net::NetworkDelegate* network_delegate) |
| 64 : network_delegate_(network_delegate) { |
| 65 } |
| 62 virtual ~ExtensionResourceProtocolHandler() {} | 66 virtual ~ExtensionResourceProtocolHandler() {} |
| 63 | 67 |
| 64 virtual net::URLRequestJob* MaybeCreateJob( | 68 virtual net::URLRequestJob* MaybeCreateJob( |
| 65 net::URLRequest* request) const OVERRIDE; | 69 net::URLRequest* request) const OVERRIDE; |
| 66 | 70 |
| 67 private: | 71 private: |
| 72 net::NetworkDelegate* network_delegate_; |
| 73 |
| 68 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); | 74 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 // Creates URLRequestJobs for chrome-extension-resource:// URLs. | 77 // Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| 72 net::URLRequestJob* | 78 net::URLRequestJob* |
| 73 ExtensionResourceProtocolHandler::MaybeCreateJob( | 79 ExtensionResourceProtocolHandler::MaybeCreateJob( |
| 74 net::URLRequest* request) const { | 80 net::URLRequest* request) const { |
| 75 return new ExtensionResourcesJob(request); | 81 return new ExtensionResourcesJob(request, network_delegate_); |
| 76 } | 82 } |
| 77 | 83 |
| 78 } // namespace | 84 } // namespace |
| 79 | 85 |
| 80 net::URLRequestJobFactory::ProtocolHandler* | 86 net::URLRequestJobFactory::ProtocolHandler* |
| 81 CreateExtensionResourceProtocolHandler() { | 87 CreateExtensionResourceProtocolHandler(net::NetworkDelegate* network_delegate) { |
| 82 return new ExtensionResourceProtocolHandler(); | 88 return new ExtensionResourceProtocolHandler(network_delegate); |
| 83 } | 89 } |
| OLD | NEW |