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/base64.h" | 9 #include "base/base64.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 class URLRequestExtensionJob : public net::URLRequestFileJob { | 278 class URLRequestExtensionJob : public net::URLRequestFileJob { |
279 public: | 279 public: |
280 URLRequestExtensionJob(net::URLRequest* request, | 280 URLRequestExtensionJob(net::URLRequest* request, |
281 net::NetworkDelegate* network_delegate, | 281 net::NetworkDelegate* network_delegate, |
282 const std::string& extension_id, | 282 const std::string& extension_id, |
283 const base::FilePath& directory_path, | 283 const base::FilePath& directory_path, |
284 const base::FilePath& relative_path, | 284 const base::FilePath& relative_path, |
285 const std::string& content_security_policy, | 285 const std::string& content_security_policy, |
286 bool send_cors_header) | 286 bool send_cors_header, |
| 287 bool follow_symlinks_anywhere) |
287 : net::URLRequestFileJob( | 288 : net::URLRequestFileJob( |
288 request, network_delegate, base::FilePath(), | 289 request, network_delegate, base::FilePath(), |
289 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 290 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
290 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), | 291 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
291 directory_path_(directory_path), | 292 directory_path_(directory_path), |
292 // TODO(tc): Move all of these files into resources.pak so we don't break | 293 // TODO(tc): Move all of these files into resources.pak so we don't break |
293 // when updating on Linux. | 294 // when updating on Linux. |
294 resource_(extension_id, directory_path, relative_path), | 295 resource_(extension_id, directory_path, relative_path), |
295 content_security_policy_(content_security_policy), | 296 content_security_policy_(content_security_policy), |
296 send_cors_header_(send_cors_header), | 297 send_cors_header_(send_cors_header), |
297 weak_factory_(this) { | 298 weak_factory_(this) { |
| 299 if (follow_symlinks_anywhere) { |
| 300 resource_.set_follow_symlinks_anywhere(); |
| 301 } |
298 } | 302 } |
299 | 303 |
300 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { | 304 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { |
301 *info = response_info_; | 305 *info = response_info_; |
302 } | 306 } |
303 | 307 |
304 virtual void Start() OVERRIDE { | 308 virtual void Start() OVERRIDE { |
305 base::FilePath* read_file_path = new base::FilePath; | 309 base::FilePath* read_file_path = new base::FilePath; |
306 base::Time* last_modified_time = new base::Time(); | 310 base::Time* last_modified_time = new base::Time(); |
307 bool posted = BrowserThread::PostBlockingPoolTaskAndReply( | 311 bool posted = BrowserThread::PostBlockingPoolTaskAndReply( |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (URLIsForExtensionIcon(request->url(), disabled_extension)) | 522 if (URLIsForExtensionIcon(request->url(), disabled_extension)) |
519 directory_path = disabled_extension->path(); | 523 directory_path = disabled_extension->path(); |
520 if (directory_path.value().empty()) { | 524 if (directory_path.value().empty()) { |
521 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; | 525 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; |
522 return NULL; | 526 return NULL; |
523 } | 527 } |
524 } | 528 } |
525 | 529 |
526 std::string content_security_policy; | 530 std::string content_security_policy; |
527 bool send_cors_header = false; | 531 bool send_cors_header = false; |
| 532 bool follow_symlinks_anywhere = false; |
528 if (extension) { | 533 if (extension) { |
529 std::string resource_path = request->url().path(); | 534 std::string resource_path = request->url().path(); |
530 content_security_policy = | 535 content_security_policy = |
531 extensions::CSPInfo::GetResourceContentSecurityPolicy(extension, | 536 extensions::CSPInfo::GetResourceContentSecurityPolicy(extension, |
532 resource_path); | 537 resource_path); |
533 if ((extension->manifest_version() >= 2 || | 538 if ((extension->manifest_version() >= 2 || |
534 extensions::WebAccessibleResourcesInfo::HasWebAccessibleResources( | 539 extensions::WebAccessibleResourcesInfo::HasWebAccessibleResources( |
535 extension)) && | 540 extension)) && |
536 extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( | 541 extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( |
537 extension, resource_path)) | 542 extension, resource_path)) |
538 send_cors_header = true; | 543 send_cors_header = true; |
| 544 |
| 545 follow_symlinks_anywhere = |
| 546 (extension->creation_flags() & Extension::FOLLOW_SYMLINKS_ANYWHERE) |
| 547 != 0; |
539 } | 548 } |
540 | 549 |
541 std::string path = request->url().path(); | 550 std::string path = request->url().path(); |
542 if (path.size() > 1 && | 551 if (path.size() > 1 && |
543 path.substr(1) == extensions::kGeneratedBackgroundPageFilename) { | 552 path.substr(1) == extensions::kGeneratedBackgroundPageFilename) { |
544 return new GeneratedBackgroundPageJob( | 553 return new GeneratedBackgroundPageJob( |
545 request, network_delegate, extension, content_security_policy); | 554 request, network_delegate, extension, content_security_policy); |
546 } | 555 } |
547 | 556 |
548 base::FilePath resources_path; | 557 base::FilePath resources_path; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 return NULL; | 619 return NULL; |
611 } | 620 } |
612 } | 621 } |
613 | 622 |
614 return new URLRequestExtensionJob(request, | 623 return new URLRequestExtensionJob(request, |
615 network_delegate, | 624 network_delegate, |
616 extension_id, | 625 extension_id, |
617 directory_path, | 626 directory_path, |
618 relative_path, | 627 relative_path, |
619 content_security_policy, | 628 content_security_policy, |
620 send_cors_header); | 629 send_cors_header, |
| 630 follow_symlinks_anywhere); |
621 } | 631 } |
622 | 632 |
623 } // namespace | 633 } // namespace |
624 | 634 |
625 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 635 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
626 bool is_incognito, | 636 bool is_incognito, |
627 extensions::InfoMap* extension_info_map) { | 637 extensions::InfoMap* extension_info_map) { |
628 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 638 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
629 } | 639 } |
OLD | NEW |