| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/threading/worker_pool.h" | 18 #include "base/threading/worker_pool.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/browser/extensions/extension_info_map.h" | 20 #include "chrome/browser/extensions/extension_info_map.h" |
| 21 #include "chrome/browser/extensions/image_loading_tracker.h" | 21 #include "chrome/browser/extensions/image_loader.h" |
| 22 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_file_util.h" | 25 #include "chrome/common/extensions/extension_file_util.h" |
| 26 #include "chrome/common/extensions/extension_resource.h" | 26 #include "chrome/common/extensions/extension_resource.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "content/public/browser/resource_request_info.h" | 28 #include "content/public/browser/resource_request_info.h" |
| 29 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
| 30 #include "googleurl/src/url_util.h" | 30 #include "googleurl/src/url_util.h" |
| 31 #include "grit/component_extension_resources_map.h" | 31 #include "grit/component_extension_resources_map.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 FilePath request_path = | 378 FilePath request_path = |
| 379 extension_file_util::ExtensionURLToRelativeFilePath(request->url()); | 379 extension_file_util::ExtensionURLToRelativeFilePath(request->url()); |
| 380 int resource_id; | 380 int resource_id; |
| 381 if (ImageLoadingTracker::IsComponentExtensionResource(extension, | 381 if (extensions::ImageLoader::IsComponentExtensionResource(extension, |
| 382 request_path, &resource_id)) { | 382 request_path, &resource_id)) { |
| 383 relative_path = relative_path.Append(request_path); | 383 relative_path = relative_path.Append(request_path); |
| 384 relative_path = relative_path.NormalizePathSeparators(); | 384 relative_path = relative_path.NormalizePathSeparators(); |
| 385 return new URLRequestResourceBundleJob( | 385 return new URLRequestResourceBundleJob( |
| 386 request, | 386 request, |
| 387 network_delegate, | 387 network_delegate, |
| 388 relative_path, | 388 relative_path, |
| 389 resource_id, | 389 resource_id, |
| 390 content_security_policy, | 390 content_security_policy, |
| 391 send_cors_header); | 391 send_cors_header); |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 | 394 |
| 395 return new URLRequestExtensionJob(request, | 395 return new URLRequestExtensionJob(request, |
| 396 network_delegate, | 396 network_delegate, |
| 397 extension_id, | 397 extension_id, |
| 398 directory_path, | 398 directory_path, |
| 399 content_security_policy, | 399 content_security_policy, |
| 400 send_cors_header); | 400 send_cors_header); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace | 403 } // namespace |
| 404 | 404 |
| 405 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 405 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 406 bool is_incognito, | 406 bool is_incognito, |
| 407 ExtensionInfoMap* extension_info_map) { | 407 ExtensionInfoMap* extension_info_map) { |
| 408 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 408 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 409 } | 409 } |
| OLD | NEW |