| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 using content::BrowserThread; | 67 using content::BrowserThread; |
| 68 using content::ResourceRequestInfo; | 68 using content::ResourceRequestInfo; |
| 69 using content::ResourceType; | 69 using content::ResourceType; |
| 70 using extensions::Extension; | 70 using extensions::Extension; |
| 71 using extensions::SharedModuleInfo; | 71 using extensions::SharedModuleInfo; |
| 72 | 72 |
| 73 namespace extensions { | 73 namespace extensions { |
| 74 namespace { | 74 namespace { |
| 75 | 75 |
| 76 ExtensionProtocolTestHandler* g_test_handler = nullptr; |
| 77 |
| 76 class GeneratedBackgroundPageJob : public net::URLRequestSimpleJob { | 78 class GeneratedBackgroundPageJob : public net::URLRequestSimpleJob { |
| 77 public: | 79 public: |
| 78 GeneratedBackgroundPageJob(net::URLRequest* request, | 80 GeneratedBackgroundPageJob(net::URLRequest* request, |
| 79 net::NetworkDelegate* network_delegate, | 81 net::NetworkDelegate* network_delegate, |
| 80 const scoped_refptr<const Extension> extension, | 82 const scoped_refptr<const Extension> extension, |
| 81 const std::string& content_security_policy) | 83 const std::string& content_security_policy) |
| 82 : net::URLRequestSimpleJob(request, network_delegate), | 84 : net::URLRequestSimpleJob(request, network_delegate), |
| 83 extension_(extension) { | 85 extension_(extension) { |
| 84 const bool send_cors_headers = false; | 86 const bool send_cors_headers = false; |
| 85 // Leave cache headers out of generated background page jobs. | 87 // Leave cache headers out of generated background page jobs. |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 518 |
| 517 if (SharedModuleInfo::ImportsExtensionById(extension, new_extension_id) && | 519 if (SharedModuleInfo::ImportsExtensionById(extension, new_extension_id) && |
| 518 new_extension) { | 520 new_extension) { |
| 519 directory_path = new_extension->path(); | 521 directory_path = new_extension->path(); |
| 520 extension_id = new_extension_id; | 522 extension_id = new_extension_id; |
| 521 relative_path = base::FilePath::FromUTF8Unsafe(new_relative_path); | 523 relative_path = base::FilePath::FromUTF8Unsafe(new_relative_path); |
| 522 } else { | 524 } else { |
| 523 return NULL; | 525 return NULL; |
| 524 } | 526 } |
| 525 } | 527 } |
| 528 |
| 529 if (g_test_handler) { |
| 530 net::URLRequestJob* test_job = |
| 531 g_test_handler->Run(request, network_delegate, relative_path); |
| 532 if (test_job) |
| 533 return test_job; |
| 534 } |
| 535 |
| 526 ContentVerifyJob* verify_job = NULL; | 536 ContentVerifyJob* verify_job = NULL; |
| 527 ContentVerifier* verifier = extension_info_map_->content_verifier(); | 537 ContentVerifier* verifier = extension_info_map_->content_verifier(); |
| 528 if (verifier) { | 538 if (verifier) { |
| 529 verify_job = | 539 verify_job = |
| 530 verifier->CreateJobFor(extension_id, directory_path, relative_path); | 540 verifier->CreateJobFor(extension_id, directory_path, relative_path); |
| 531 if (verify_job) | 541 if (verify_job) |
| 532 verify_job->Start(); | 542 verify_job->Start(); |
| 533 } | 543 } |
| 534 | 544 |
| 535 return new URLRequestExtensionJob(request, | 545 return new URLRequestExtensionJob(request, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 return new net::HttpResponseHeaders(raw_headers); | 593 return new net::HttpResponseHeaders(raw_headers); |
| 584 } | 594 } |
| 585 | 595 |
| 586 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler> | 596 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 587 CreateExtensionProtocolHandler(bool is_incognito, | 597 CreateExtensionProtocolHandler(bool is_incognito, |
| 588 extensions::InfoMap* extension_info_map) { | 598 extensions::InfoMap* extension_info_map) { |
| 589 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito, | 599 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito, |
| 590 extension_info_map); | 600 extension_info_map); |
| 591 } | 601 } |
| 592 | 602 |
| 603 void SetExtensionProtocolTestHandler(ExtensionProtocolTestHandler* handler) { |
| 604 g_test_handler = handler; |
| 605 } |
| 606 |
| 593 } // namespace extensions | 607 } // namespace extensions |
| OLD | NEW |