| 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 "googleurl/src/url_util.h" | 29 #include "googleurl/src/url_util.h" |
| 30 #include "grit/component_extension_resources_map.h" | 30 #include "grit/component_extension_resources_map.h" |
| 31 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // directory_path is a descendant of resources_path. resources_path | 372 // directory_path is a descendant of resources_path. resources_path |
| 373 // corresponds to src/chrome/browser/resources in source tree. | 373 // corresponds to src/chrome/browser/resources in source tree. |
| 374 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && | 374 if (PathService::Get(chrome::DIR_RESOURCES, &resources_path) && |
| 375 // Since component extension resources are included in | 375 // Since component extension resources are included in |
| 376 // component_extension_resources.pak file in resources_path, calculate | 376 // component_extension_resources.pak file in resources_path, calculate |
| 377 // extension relative path against resources_path. | 377 // extension relative path against resources_path. |
| 378 resources_path.AppendRelativePath(directory_path, &relative_path)) { | 378 resources_path.AppendRelativePath(directory_path, &relative_path)) { |
| 379 FilePath request_path = | 379 FilePath request_path = |
| 380 extension_file_util::ExtensionURLToRelativeFilePath(request->url()); | 380 extension_file_util::ExtensionURLToRelativeFilePath(request->url()); |
| 381 int resource_id; | 381 int resource_id; |
| 382 if (ImageLoadingTracker::IsComponentExtensionResource(extension, | 382 if (extensions::ImageLoader::IsComponentExtensionResource(extension, |
| 383 request_path, &resource_id)) { | 383 request_path, &resource_id)) { |
| 384 relative_path = relative_path.Append(request_path); | 384 relative_path = relative_path.Append(request_path); |
| 385 relative_path = relative_path.NormalizePathSeparators(); | 385 relative_path = relative_path.NormalizePathSeparators(); |
| 386 return new URLRequestResourceBundleJob( | 386 return new URLRequestResourceBundleJob( |
| 387 request, | 387 request, |
| 388 network_delegate, | 388 network_delegate, |
| 389 relative_path, | 389 relative_path, |
| 390 resource_id, | 390 resource_id, |
| 391 content_security_policy, | 391 content_security_policy, |
| 392 send_cors_header); | 392 send_cors_header); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 return new URLRequestExtensionJob(request, | 396 return new URLRequestExtensionJob(request, |
| 397 network_delegate, | 397 network_delegate, |
| 398 extension_id, | 398 extension_id, |
| 399 directory_path, | 399 directory_path, |
| 400 content_security_policy, | 400 content_security_policy, |
| 401 send_cors_header); | 401 send_cors_header); |
| 402 } | 402 } |
| 403 | 403 |
| 404 } // namespace | 404 } // namespace |
| 405 | 405 |
| 406 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 406 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 407 bool is_incognito, | 407 bool is_incognito, |
| 408 ExtensionInfoMap* extension_info_map) { | 408 ExtensionInfoMap* extension_info_map) { |
| 409 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 409 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 410 } | 410 } |
| OLD | NEW |