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_protocols.h" | 5 #include "chrome/browser/extensions/extension_protocols.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 path.substr(1) == extension_filenames::kGeneratedBackgroundPageFilename) { | 279 path.substr(1) == extension_filenames::kGeneratedBackgroundPageFilename) { |
280 return new GeneratedBackgroundPageJob( | 280 return new GeneratedBackgroundPageJob( |
281 request, extension, content_security_policy); | 281 request, extension, content_security_policy); |
282 } | 282 } |
283 | 283 |
284 FilePath resources_path; | 284 FilePath resources_path; |
285 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && | 285 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && |
286 directory_path.DirName() == resources_path) { | 286 directory_path.DirName() == resources_path) { |
287 FilePath relative_path = directory_path.BaseName().Append( | 287 FilePath relative_path = directory_path.BaseName().Append( |
288 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); | 288 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); |
289 #if defined(OS_WIN) | 289 relative_path = relative_path.NormalizePathSeparators(); |
290 relative_path = relative_path.NormalizeWindowsPathSeparators(); | |
291 #endif | |
292 | 290 |
293 // TODO(tc): Make a map of FilePath -> resource ids so we don't have to | 291 // TODO(tc): Make a map of FilePath -> resource ids so we don't have to |
294 // covert to FilePaths all the time. This will be more useful as we add | 292 // covert to FilePaths all the time. This will be more useful as we add |
295 // more resources. | 293 // more resources. |
296 for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { | 294 for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { |
297 FilePath bm_resource_path = | 295 FilePath bm_resource_path = |
298 FilePath().AppendASCII(kComponentExtensionResources[i].name); | 296 FilePath().AppendASCII(kComponentExtensionResources[i].name); |
299 #if defined(OS_WIN) | 297 bm_resource_path = bm_resource_path.NormalizePathSeparators(); |
300 bm_resource_path = bm_resource_path.NormalizeWindowsPathSeparators(); | |
301 #endif | |
302 if (relative_path == bm_resource_path) { | 298 if (relative_path == bm_resource_path) { |
303 return new URLRequestResourceBundleJob(request, relative_path, | 299 return new URLRequestResourceBundleJob(request, relative_path, |
304 kComponentExtensionResources[i].value, content_security_policy, | 300 kComponentExtensionResources[i].value, content_security_policy, |
305 send_cors_header); | 301 send_cors_header); |
306 } | 302 } |
307 } | 303 } |
308 } | 304 } |
309 // TODO(tc): Move all of these files into resources.pak so we don't break | 305 // TODO(tc): Move all of these files into resources.pak so we don't break |
310 // when updating on Linux. | 306 // when updating on Linux. |
311 ExtensionResource resource(extension_id, directory_path, | 307 ExtensionResource resource(extension_id, directory_path, |
(...skipping 11 matching lines...) Expand all Loading... |
323 content_security_policy, send_cors_header); | 319 content_security_policy, send_cors_header); |
324 } | 320 } |
325 | 321 |
326 } // namespace | 322 } // namespace |
327 | 323 |
328 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 324 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
329 bool is_incognito, | 325 bool is_incognito, |
330 ExtensionInfoMap* extension_info_map) { | 326 ExtensionInfoMap* extension_info_map) { |
331 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 327 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
332 } | 328 } |
OLD | NEW |