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

Side by Side Diff: url/url_util.cc

Issue 2760463005: Fix handling of external protocols with PlzNavigate. (Closed)
Patch Set: review comments Created 3 years, 9 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 const char* kWebStorageSchemes[] = { 75 const char* kWebStorageSchemes[] = {
76 kHttpScheme, 76 kHttpScheme,
77 kHttpsScheme, 77 kHttpsScheme,
78 kFileScheme, 78 kFileScheme,
79 kFtpScheme, 79 kFtpScheme,
80 kWsScheme, 80 kWsScheme,
81 kWssScheme, 81 kWssScheme,
82 }; 82 };
83 83
84 const char* kEmptyDocumentSchemes[] = {
85 kAboutScheme,
brettw 2017/03/23 22:02:13 Indenting.
jam 2017/03/23 22:36:04 I'll do this in a followup if you don't mind, just
86 };
87
84 bool initialized = false; 88 bool initialized = false;
85 89
86 // Lists of the currently installed standard and referrer schemes. These lists 90 // Lists of the currently installed standard and referrer schemes. These lists
87 // are lazily initialized by Initialize and are leaked on shutdown to prevent 91 // are lazily initialized by Initialize and are leaked on shutdown to prevent
88 // any destructors from being called that will slow us down or cause problems. 92 // any destructors from being called that will slow us down or cause problems.
89 std::vector<SchemeWithType>* standard_schemes = nullptr; 93 std::vector<SchemeWithType>* standard_schemes = nullptr;
90 std::vector<SchemeWithType>* referrer_schemes = nullptr; 94 std::vector<SchemeWithType>* referrer_schemes = nullptr;
91 95
92 // Similar to above, initialized by the Init*Schemes methods. 96 // Similar to above, initialized by the Init*Schemes methods.
93 std::vector<std::string>* secure_schemes = nullptr; 97 std::vector<std::string>* secure_schemes = nullptr;
94 std::vector<std::string>* local_schemes = nullptr; 98 std::vector<std::string>* local_schemes = nullptr;
95 std::vector<std::string>* no_access_schemes = nullptr; 99 std::vector<std::string>* no_access_schemes = nullptr;
96 std::vector<std::string>* cors_enabled_schemes = nullptr; 100 std::vector<std::string>* cors_enabled_schemes = nullptr;
97 std::vector<std::string>* web_storage_schemes = nullptr; 101 std::vector<std::string>* web_storage_schemes = nullptr;
98 std::vector<std::string>* csp_bypassing_schemes = nullptr; 102 std::vector<std::string>* csp_bypassing_schemes = nullptr;
103 std::vector<std::string>* empty_document_schemes = nullptr;
99 104
100 // See the LockSchemeRegistries declaration in the header. 105 // See the LockSchemeRegistries declaration in the header.
101 bool scheme_registries_locked = false; 106 bool scheme_registries_locked = false;
102 107
103 // This template converts a given character type to the corresponding 108 // This template converts a given character type to the corresponding
104 // StringPiece type. 109 // StringPiece type.
105 template<typename CHAR> struct CharToStringPiece { 110 template<typename CHAR> struct CharToStringPiece {
106 }; 111 };
107 template<> struct CharToStringPiece<char> { 112 template<> struct CharToStringPiece<char> {
108 typedef base::StringPiece Piece; 113 typedef base::StringPiece Piece;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 arraysize(kReferrerURLSchemes)); 523 arraysize(kReferrerURLSchemes));
519 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes)); 524 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes));
520 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes)); 525 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes));
521 InitSchemes(&no_access_schemes, kNoAccessSchemes, 526 InitSchemes(&no_access_schemes, kNoAccessSchemes,
522 arraysize(kNoAccessSchemes)); 527 arraysize(kNoAccessSchemes));
523 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes, 528 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes,
524 arraysize(kCORSEnabledSchemes)); 529 arraysize(kCORSEnabledSchemes));
525 InitSchemes(&web_storage_schemes, kWebStorageSchemes, 530 InitSchemes(&web_storage_schemes, kWebStorageSchemes,
526 arraysize(kWebStorageSchemes)); 531 arraysize(kWebStorageSchemes));
527 InitSchemes(&csp_bypassing_schemes, nullptr, 0); 532 InitSchemes(&csp_bypassing_schemes, nullptr, 0);
533 InitSchemes(&empty_document_schemes, kEmptyDocumentSchemes,
534 arraysize(kEmptyDocumentSchemes));
528 initialized = true; 535 initialized = true;
529 } 536 }
530 537
531 void Shutdown() { 538 void Shutdown() {
532 initialized = false; 539 initialized = false;
533 delete standard_schemes; 540 delete standard_schemes;
534 standard_schemes = nullptr; 541 standard_schemes = nullptr;
535 delete referrer_schemes; 542 delete referrer_schemes;
536 referrer_schemes = nullptr; 543 referrer_schemes = nullptr;
537 delete secure_schemes; 544 delete secure_schemes;
538 secure_schemes = nullptr; 545 secure_schemes = nullptr;
539 delete local_schemes; 546 delete local_schemes;
540 local_schemes = nullptr; 547 local_schemes = nullptr;
541 delete no_access_schemes; 548 delete no_access_schemes;
542 no_access_schemes = nullptr; 549 no_access_schemes = nullptr;
543 delete cors_enabled_schemes; 550 delete cors_enabled_schemes;
544 cors_enabled_schemes = nullptr; 551 cors_enabled_schemes = nullptr;
545 delete web_storage_schemes; 552 delete web_storage_schemes;
546 web_storage_schemes = nullptr; 553 web_storage_schemes = nullptr;
547 delete csp_bypassing_schemes; 554 delete csp_bypassing_schemes;
548 csp_bypassing_schemes = nullptr; 555 csp_bypassing_schemes = nullptr;
556 delete empty_document_schemes;
557 empty_document_schemes = nullptr;
549 } 558 }
550 559
551 void AddStandardScheme(const char* new_scheme, SchemeType type) { 560 void AddStandardScheme(const char* new_scheme, SchemeType type) {
552 Initialize(); 561 Initialize();
553 DoAddSchemeWithType(new_scheme, type, standard_schemes); 562 DoAddSchemeWithType(new_scheme, type, standard_schemes);
554 } 563 }
555 564
556 void AddReferrerScheme(const char* new_scheme, SchemeType type) { 565 void AddReferrerScheme(const char* new_scheme, SchemeType type) {
557 Initialize(); 566 Initialize();
558 DoAddSchemeWithType(new_scheme, type, referrer_schemes); 567 DoAddSchemeWithType(new_scheme, type, referrer_schemes);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 void AddCSPBypassingScheme(const char* new_scheme) { 620 void AddCSPBypassingScheme(const char* new_scheme) {
612 Initialize(); 621 Initialize();
613 DoAddScheme(new_scheme, csp_bypassing_schemes); 622 DoAddScheme(new_scheme, csp_bypassing_schemes);
614 } 623 }
615 624
616 const std::vector<std::string>& GetCSPBypassingSchemes() { 625 const std::vector<std::string>& GetCSPBypassingSchemes() {
617 Initialize(); 626 Initialize();
618 return *csp_bypassing_schemes; 627 return *csp_bypassing_schemes;
619 } 628 }
620 629
630 void AddEmptyDocumentScheme(const char* new_scheme) {
631 Initialize();
632 DoAddScheme(new_scheme, empty_document_schemes);
633 }
634
635 const std::vector<std::string>& GetEmptyDocumentSchemes() {
636 Initialize();
637 return *empty_document_schemes;
638 }
639
621 void LockSchemeRegistries() { 640 void LockSchemeRegistries() {
622 scheme_registries_locked = true; 641 scheme_registries_locked = true;
623 } 642 }
624 643
625 bool IsStandard(const char* spec, const Component& scheme) { 644 bool IsStandard(const char* spec, const Component& scheme) {
626 SchemeType unused_scheme_type; 645 SchemeType unused_scheme_type;
627 return DoIsStandard(spec, scheme, &unused_scheme_type); 646 return DoIsStandard(spec, scheme, &unused_scheme_type);
628 } 647 }
629 648
630 bool GetStandardSchemeType(const char* spec, 649 bool GetStandardSchemeType(const char* spec,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 return DoCompareSchemeComponent(spec, component, compare_to); 856 return DoCompareSchemeComponent(spec, component, compare_to);
838 } 857 }
839 858
840 bool CompareSchemeComponent(const base::char16* spec, 859 bool CompareSchemeComponent(const base::char16* spec,
841 const Component& component, 860 const Component& component,
842 const char* compare_to) { 861 const char* compare_to) {
843 return DoCompareSchemeComponent(spec, component, compare_to); 862 return DoCompareSchemeComponent(spec, component, compare_to);
844 } 863 }
845 864
846 } // namespace url 865 } // 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