| 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 ExtensionResourcesJob(net::URLRequest* request, |
| 19 : net::URLRequestFileJob(request, FilePath()), | 19 net::NetworkDelegate* network_delegate) |
| 20 : net::URLRequestFileJob(request, network_delegate, FilePath()), |
| 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 25 matching lines...) Expand all Loading... |
| 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 ExtensionResourceProtocolHandler() {} |
| 62 virtual ~ExtensionResourceProtocolHandler() {} | 63 virtual ~ExtensionResourceProtocolHandler() {} |
| 63 | 64 |
| 64 virtual net::URLRequestJob* MaybeCreateJob( | 65 virtual net::URLRequestJob* MaybeCreateJob( |
| 65 net::URLRequest* request) const OVERRIDE; | 66 net::URLRequest* request, |
| 67 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); | 70 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 // Creates URLRequestJobs for chrome-extension-resource:// URLs. | 73 // Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| 72 net::URLRequestJob* | 74 net::URLRequestJob* |
| 73 ExtensionResourceProtocolHandler::MaybeCreateJob( | 75 ExtensionResourceProtocolHandler::MaybeCreateJob( |
| 74 net::URLRequest* request) const { | 76 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 75 return new ExtensionResourcesJob(request); | 77 return new ExtensionResourcesJob(request, network_delegate); |
| 76 } | 78 } |
| 77 | 79 |
| 78 } // namespace | 80 } // namespace |
| 79 | 81 |
| 80 net::URLRequestJobFactory::ProtocolHandler* | 82 net::URLRequestJobFactory::ProtocolHandler* |
| 81 CreateExtensionResourceProtocolHandler() { | 83 CreateExtensionResourceProtocolHandler() { |
| 82 return new ExtensionResourceProtocolHandler(); | 84 return new ExtensionResourceProtocolHandler(); |
| 83 } | 85 } |
| OLD | NEW |