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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 FilePath resources_path; | 368 FilePath resources_path; |
369 FilePath relative_path; | 369 FilePath relative_path; |
370 // Try to load extension resources from chrome resource file if | 370 // Try to load extension resources from chrome resource file if |
371 // directory_path is a descendant of resources_path. resources_path | 371 // directory_path is a descendant of resources_path. resources_path |
372 // corresponds to src/chrome/browser/resources in source tree. | 372 // corresponds to src/chrome/browser/resources in source tree. |
373 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && | 373 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && |
374 // Since component extension resources are included in | 374 // Since component extension resources are included in |
375 // component_extension_resources.pak file in resources_path, calculate | 375 // component_extension_resources.pak file in resources_path, calculate |
376 // extension relative path against resources_path. | 376 // extension relative path against resources_path. |
377 resources_path.AppendRelativePath(directory_path, &relative_path)) { | 377 resources_path.AppendRelativePath(directory_path, &relative_path)) { |
378 relative_path = relative_path.Append( | 378 FilePath request_path = |
379 extension_file_util::ExtensionURLToRelativeFilePath(request->url())); | 379 extension_file_util::ExtensionURLToRelativeFilePath(request->url()); |
380 relative_path = relative_path.NormalizePathSeparators(); | 380 int resource_id; |
381 | 381 if (extension_file_util::IsComponentExtensionResource(extension, |
Aaron Boodman
2012/09/28 22:38:52
Is it possible to just put the icons here:
http:/
| |
382 // TODO(tc): Make a map of FilePath -> resource ids so we don't have to | 382 request_path, resource_id)) { |
383 // covert to FilePaths all the time. This will be more useful as we add | 383 relative_path = relative_path.Append(request_path); |
384 // more resources. | 384 relative_path = relative_path.NormalizePathSeparators(); |
385 for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { | 385 return new URLRequestResourceBundleJob( |
386 FilePath bm_resource_path = | 386 request, |
387 FilePath().AppendASCII(kComponentExtensionResources[i].name); | 387 network_delegate, |
388 bm_resource_path = bm_resource_path.NormalizePathSeparators(); | 388 relative_path, |
389 if (relative_path == bm_resource_path) { | 389 resource_id, |
390 return new URLRequestResourceBundleJob( | 390 content_security_policy, |
391 request, | 391 send_cors_header); |
392 network_delegate, | |
393 relative_path, | |
394 kComponentExtensionResources[i].value, | |
395 content_security_policy, | |
396 send_cors_header); | |
397 } | |
398 } | 392 } |
399 } | 393 } |
400 | 394 |
401 return new URLRequestExtensionJob(request, | 395 return new URLRequestExtensionJob(request, |
402 network_delegate, | 396 network_delegate, |
403 extension_id, | 397 extension_id, |
404 directory_path, | 398 directory_path, |
405 content_security_policy, | 399 content_security_policy, |
406 send_cors_header); | 400 send_cors_header); |
407 } | 401 } |
408 | 402 |
409 } // namespace | 403 } // namespace |
410 | 404 |
411 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 405 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
412 bool is_incognito, | 406 bool is_incognito, |
413 ExtensionInfoMap* extension_info_map) { | 407 ExtensionInfoMap* extension_info_map) { |
414 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 408 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
415 } | 409 } |
OLD | NEW |