Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: url/url_util.cc

Issue 2679383003: Share schemes needed for CSP between the browser and the renderer. (Closed)
Patch Set: Rebase and fix conflict. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « url/url_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "url/url_util.h" 5 #include "url/url_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // any destructors from being called that will slow us down or cause problems. 89 // any destructors from being called that will slow us down or cause problems.
90 std::vector<SchemeWithType>* standard_schemes = nullptr; 90 std::vector<SchemeWithType>* standard_schemes = nullptr;
91 std::vector<SchemeWithType>* referrer_schemes = nullptr; 91 std::vector<SchemeWithType>* referrer_schemes = nullptr;
92 92
93 // Similar to above, initialized by the Init*Schemes methods. 93 // Similar to above, initialized by the Init*Schemes methods.
94 std::vector<std::string>* secure_schemes = nullptr; 94 std::vector<std::string>* secure_schemes = nullptr;
95 std::vector<std::string>* local_schemes = nullptr; 95 std::vector<std::string>* local_schemes = nullptr;
96 std::vector<std::string>* no_access_schemes = nullptr; 96 std::vector<std::string>* no_access_schemes = nullptr;
97 std::vector<std::string>* cors_enabled_schemes = nullptr; 97 std::vector<std::string>* cors_enabled_schemes = nullptr;
98 std::vector<std::string>* web_storage_schemes = nullptr; 98 std::vector<std::string>* web_storage_schemes = nullptr;
99 std::vector<std::string>* csp_bypassing_schemes = nullptr;
99 100
100 // See the LockSchemeRegistries declaration in the header. 101 // See the LockSchemeRegistries declaration in the header.
101 bool scheme_registries_locked = false; 102 bool scheme_registries_locked = false;
102 103
103 // This template converts a given character type to the corresponding 104 // This template converts a given character type to the corresponding
104 // StringPiece type. 105 // StringPiece type.
105 template<typename CHAR> struct CharToStringPiece { 106 template<typename CHAR> struct CharToStringPiece {
106 }; 107 };
107 template<> struct CharToStringPiece<char> { 108 template<> struct CharToStringPiece<char> {
108 typedef base::StringPiece Piece; 109 typedef base::StringPiece Piece;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 InitSchemesWithType(&referrer_schemes, kReferrerURLSchemes, 518 InitSchemesWithType(&referrer_schemes, kReferrerURLSchemes,
518 arraysize(kReferrerURLSchemes)); 519 arraysize(kReferrerURLSchemes));
519 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes)); 520 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes));
520 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes)); 521 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes));
521 InitSchemes(&no_access_schemes, kNoAccessSchemes, 522 InitSchemes(&no_access_schemes, kNoAccessSchemes,
522 arraysize(kNoAccessSchemes)); 523 arraysize(kNoAccessSchemes));
523 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes, 524 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes,
524 arraysize(kCORSEnabledSchemes)); 525 arraysize(kCORSEnabledSchemes));
525 InitSchemes(&web_storage_schemes, kWebStorageSchemes, 526 InitSchemes(&web_storage_schemes, kWebStorageSchemes,
526 arraysize(kWebStorageSchemes)); 527 arraysize(kWebStorageSchemes));
528 InitSchemes(&csp_bypassing_schemes, nullptr, 0);
527 initialized = true; 529 initialized = true;
528 } 530 }
529 531
530 void Shutdown() { 532 void Shutdown() {
531 initialized = false; 533 initialized = false;
532 delete standard_schemes; 534 delete standard_schemes;
533 standard_schemes = nullptr; 535 standard_schemes = nullptr;
534 delete referrer_schemes; 536 delete referrer_schemes;
535 referrer_schemes = nullptr; 537 referrer_schemes = nullptr;
536 delete secure_schemes; 538 delete secure_schemes;
537 secure_schemes = nullptr; 539 secure_schemes = nullptr;
538 delete local_schemes; 540 delete local_schemes;
539 local_schemes = nullptr; 541 local_schemes = nullptr;
540 delete no_access_schemes; 542 delete no_access_schemes;
541 no_access_schemes = nullptr; 543 no_access_schemes = nullptr;
542 delete cors_enabled_schemes; 544 delete cors_enabled_schemes;
543 cors_enabled_schemes = nullptr; 545 cors_enabled_schemes = nullptr;
544 delete web_storage_schemes; 546 delete web_storage_schemes;
545 web_storage_schemes = nullptr; 547 web_storage_schemes = nullptr;
548 delete csp_bypassing_schemes;
549 csp_bypassing_schemes = nullptr;
546 } 550 }
547 551
548 void AddStandardScheme(const char* new_scheme, SchemeType type) { 552 void AddStandardScheme(const char* new_scheme, SchemeType type) {
549 Initialize(); 553 Initialize();
550 DoAddSchemeWithType(new_scheme, type, standard_schemes); 554 DoAddSchemeWithType(new_scheme, type, standard_schemes);
551 } 555 }
552 556
553 void AddReferrerScheme(const char* new_scheme, SchemeType type) { 557 void AddReferrerScheme(const char* new_scheme, SchemeType type) {
554 Initialize(); 558 Initialize();
555 DoAddSchemeWithType(new_scheme, type, referrer_schemes); 559 DoAddSchemeWithType(new_scheme, type, referrer_schemes);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 void AddWebStorageScheme(const char* new_scheme) { 602 void AddWebStorageScheme(const char* new_scheme) {
599 Initialize(); 603 Initialize();
600 DoAddScheme(new_scheme, web_storage_schemes); 604 DoAddScheme(new_scheme, web_storage_schemes);
601 } 605 }
602 606
603 const std::vector<std::string>& GetWebStorageSchemes() { 607 const std::vector<std::string>& GetWebStorageSchemes() {
604 Initialize(); 608 Initialize();
605 return *web_storage_schemes; 609 return *web_storage_schemes;
606 } 610 }
607 611
612 void AddCSPBypassingScheme(const char* new_scheme) {
613 Initialize();
614 DoAddScheme(new_scheme, csp_bypassing_schemes);
615 }
616
617 const std::vector<std::string>& GetCSPBypassingSchemes() {
618 Initialize();
619 return *csp_bypassing_schemes;
620 }
621
608 void LockSchemeRegistries() { 622 void LockSchemeRegistries() {
609 scheme_registries_locked = true; 623 scheme_registries_locked = true;
610 } 624 }
611 625
612 bool IsStandard(const char* spec, const Component& scheme) { 626 bool IsStandard(const char* spec, const Component& scheme) {
613 SchemeType unused_scheme_type; 627 SchemeType unused_scheme_type;
614 return DoIsStandard(spec, scheme, &unused_scheme_type); 628 return DoIsStandard(spec, scheme, &unused_scheme_type);
615 } 629 }
616 630
617 bool GetStandardSchemeType(const char* spec, 631 bool GetStandardSchemeType(const char* spec,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 return DoCompareSchemeComponent(spec, component, compare_to); 853 return DoCompareSchemeComponent(spec, component, compare_to);
840 } 854 }
841 855
842 bool CompareSchemeComponent(const base::char16* spec, 856 bool CompareSchemeComponent(const base::char16* spec,
843 const Component& component, 857 const Component& component,
844 const char* compare_to) { 858 const char* compare_to) {
845 return DoCompareSchemeComponent(spec, component, compare_to); 859 return DoCompareSchemeComponent(spec, component, compare_to);
846 } 860 }
847 861
848 } // namespace url 862 } // namespace url
OLDNEW
« no previous file with comments | « url/url_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698