| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 ExtensionResource resource(extension_id, directory_path, | 192 ExtensionResource resource(extension_id, directory_path, |
| 193 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); | 193 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); |
| 194 | 194 |
| 195 FilePath resource_file_path; | 195 FilePath resource_file_path; |
| 196 { | 196 { |
| 197 // Getting the file path will touch the file system. Fixing | 197 // Getting the file path will touch the file system. Fixing |
| 198 // crbug.com/59849 would also fix this. Suppress the error for now. | 198 // crbug.com/59849 would also fix this. Suppress the error for now. |
| 199 base::ThreadRestrictions::ScopedAllowIO allow_io; | 199 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 200 resource_file_path = resource.GetFilePath(); | 200 resource_file_path = resource.GetFilePath(); |
| 201 } | 201 } |
| 202 return new URLRequestFileJob(request, resource_file_path); | 202 return new net::URLRequestFileJob(request, resource_file_path); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Factory registered with net::URLRequest to create URLRequestJobs for | 205 // Factory registered with net::URLRequest to create URLRequestJobs for |
| 206 // chrome-user-script:/ URLs. | 206 // chrome-user-script:/ URLs. |
| 207 static net::URLRequestJob* CreateUserScriptURLRequestJob( | 207 static net::URLRequestJob* CreateUserScriptURLRequestJob( |
| 208 net::URLRequest* request, | 208 net::URLRequest* request, |
| 209 const std::string& scheme) { | 209 const std::string& scheme) { |
| 210 ChromeURLRequestContext* context = | 210 ChromeURLRequestContext* context = |
| 211 static_cast<ChromeURLRequestContext*>(request->context()); | 211 static_cast<ChromeURLRequestContext*>(request->context()); |
| 212 | 212 |
| 213 // chrome-user-script:/user-script-name.user.js | 213 // chrome-user-script:/user-script-name.user.js |
| 214 FilePath directory_path = context->user_script_dir_path(); | 214 FilePath directory_path = context->user_script_dir_path(); |
| 215 | 215 |
| 216 ExtensionResource resource(request->url().host(), directory_path, | 216 ExtensionResource resource(request->url().host(), directory_path, |
| 217 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); | 217 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); |
| 218 | 218 |
| 219 return new 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 |