| Index: url/url_util.cc
|
| diff --git a/url/url_util.cc b/url/url_util.cc
|
| index c1e997992d3569496b96e64014a79e692bc01bcf..1d37daab6b255c34598c9b92aa13be066c941676 100644
|
| --- a/url/url_util.cc
|
| +++ b/url/url_util.cc
|
| @@ -40,12 +40,21 @@ const SchemeWithType kReferrerURLSchemes[kNumReferrerURLSchemes] = {
|
| {kHttpsScheme, SCHEME_WITH_PORT},
|
| };
|
|
|
| +const int kNumPrinterURLSchemes = 4;
|
| +const SchemeWithType kPrinterURLSchemes[kNumPrinterURLSchemes] = {
|
| + {kPrinterIppScheme, SCHEME_WITH_PORT},
|
| + {kPrinterIppsScheme, SCHEME_WITH_PORT},
|
| + {kPrinterLpdScheme, SCHEME_WITH_PORT},
|
| + {kPrinterSocketScheme, SCHEME_WITH_PORT},
|
| +};
|
| +
|
| // Lists of the currently installed standard and referrer schemes. These lists
|
| // are lazily initialized by InitStandardSchemes and InitReferrerSchemes and are
|
| // leaked on shutdown to prevent any destructors from being called that will
|
| // slow us down or cause problems.
|
| std::vector<SchemeWithType>* standard_schemes = nullptr;
|
| std::vector<SchemeWithType>* referrer_schemes = nullptr;
|
| +std::vector<SchemeWithType>* printer_schemes = nullptr;
|
|
|
| // See the LockSchemeRegistries declaration in the header.
|
| bool scheme_registries_locked = false;
|
| @@ -84,6 +93,12 @@ void InitReferrerSchemes() {
|
| InitSchemes(&referrer_schemes, kReferrerURLSchemes, kNumReferrerURLSchemes);
|
| }
|
|
|
| +// Ensures that the printer_schemes list is initialized, does nothing if it
|
| +// already has values.
|
| +void InitPrinterSchemes() {
|
| + InitSchemes(&printer_schemes, kPrinterURLSchemes, kNumPrinterURLSchemes);
|
| +}
|
| +
|
| // Given a string and a range inside the string, compares it to the given
|
| // lower-case |compare_to| buffer.
|
| template<typename CHAR>
|
| @@ -125,6 +140,13 @@ bool DoIsStandard(const CHAR* spec, const Component& scheme, SchemeType* type) {
|
| return DoIsInSchemes(spec, scheme, type, *standard_schemes);
|
| }
|
|
|
| +template <typename CHAR>
|
| +bool IsPrinterScheme(const CHAR* spec,
|
| + const Component& scheme,
|
| + SchemeType* type) {
|
| + InitPrinterSchemes();
|
| + return DoIsInSchemes(spec, scheme, type, *printer_schemes);
|
| +}
|
|
|
| template<typename CHAR>
|
| bool DoFindAndCompareScheme(const CHAR* str,
|
| @@ -204,7 +226,8 @@ bool DoCanonicalize(const CHAR* in_spec,
|
| charset_converter, output,
|
| output_parsed);
|
|
|
| - } else if (DoIsStandard(spec, scheme, &unused_scheme_type)) {
|
| + } else if (DoIsStandard(spec, scheme, &unused_scheme_type) ||
|
| + IsPrinterScheme(spec, scheme, &unused_scheme_type)) {
|
| // All "normal" URLs.
|
| ParseStandardURL(spec, spec_len, &parsed_input);
|
| success = CanonicalizeStandardURL(spec, spec_len, parsed_input,
|
|
|