OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_protocols.h" | 5 #include "chrome/browser/extensions/extension_protocols.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Factory registered with net::URLRequest to create URLRequestJobs for | 145 // Factory registered with net::URLRequest to create URLRequestJobs for |
146 // extension:// URLs. | 146 // extension:// URLs. |
147 static net::URLRequestJob* CreateExtensionURLRequestJob( | 147 static net::URLRequestJob* CreateExtensionURLRequestJob( |
148 net::URLRequest* request, | 148 net::URLRequest* request, |
149 const std::string& scheme) { | 149 const std::string& scheme) { |
150 ChromeURLRequestContext* context = | 150 ChromeURLRequestContext* context = |
151 static_cast<ChromeURLRequestContext*>(request->context()); | 151 static_cast<ChromeURLRequestContext*>(request->context()); |
152 | 152 |
153 // TODO(mpcomplete): better error code. | 153 // TODO(mpcomplete): better error code. |
154 if (!AllowExtensionResourceLoad(request, context, scheme)) | 154 if (!AllowExtensionResourceLoad(request, context, scheme)) |
155 return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE); | 155 return new net::URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE); |
156 | 156 |
157 // chrome-extension://extension-id/resource/path.js | 157 // chrome-extension://extension-id/resource/path.js |
158 const std::string& extension_id = request->url().host(); | 158 const std::string& extension_id = request->url().host(); |
159 FilePath directory_path = context->extension_info_map()-> | 159 FilePath directory_path = context->extension_info_map()-> |
160 GetPathForExtension(extension_id); | 160 GetPathForExtension(extension_id); |
161 if (directory_path.value().empty()) { | 161 if (directory_path.value().empty()) { |
162 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; | 162 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; |
163 return NULL; | 163 return NULL; |
164 } | 164 } |
165 | 165 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 return new net::URLRequestFileJob(request, resource.GetFilePath()); | 219 return new net::URLRequestFileJob(request, resource.GetFilePath()); |
220 } | 220 } |
221 | 221 |
222 void RegisterExtensionProtocols() { | 222 void RegisterExtensionProtocols() { |
223 net::URLRequest::RegisterProtocolFactory(chrome::kExtensionScheme, | 223 net::URLRequest::RegisterProtocolFactory(chrome::kExtensionScheme, |
224 &CreateExtensionURLRequestJob); | 224 &CreateExtensionURLRequestJob); |
225 net::URLRequest::RegisterProtocolFactory(chrome::kUserScriptScheme, | 225 net::URLRequest::RegisterProtocolFactory(chrome::kUserScriptScheme, |
226 &CreateUserScriptURLRequestJob); | 226 &CreateUserScriptURLRequestJob); |
227 } | 227 } |
OLD | NEW |