diff options
Diffstat (limited to 'url/url_canon.h')
-rw-r--r-- | url/url_canon.h | 248 |
1 files changed, 122 insertions, 126 deletions
diff --git a/url/url_canon.h b/url/url_canon.h index e118f3a..624eeaf 100644 --- a/url/url_canon.h +++ b/url/url_canon.h @@ -12,7 +12,7 @@ #include "url/url_export.h" #include "url/url_parse.h" -namespace url_canon { +namespace url { // Canonicalizer output ------------------------------------------------------- @@ -274,13 +274,13 @@ URL_EXPORT bool IDNToASCII(const base::char16* src, // // The 8-bit version requires UTF-8 encoding. URL_EXPORT bool CanonicalizeScheme(const char* spec, - const url_parse::Component& scheme, + const Component& scheme, CanonOutput* output, - url_parse::Component* out_scheme); + Component* out_scheme); URL_EXPORT bool CanonicalizeScheme(const base::char16* spec, - const url_parse::Component& scheme, + const Component& scheme, CanonOutput* output, - url_parse::Component* out_scheme); + Component* out_scheme); // User info: username/password. If present, this will add the delimiters so // the output will be "<username>:<password>@" or "<username>@". Empty @@ -293,20 +293,19 @@ URL_EXPORT bool CanonicalizeScheme(const base::char16* spec, // // The 8-bit version requires UTF-8 encoding. URL_EXPORT bool CanonicalizeUserInfo(const char* username_source, - const url_parse::Component& username, + const Component& username, const char* password_source, - const url_parse::Component& password, + const Component& password, CanonOutput* output, - url_parse::Component* out_username, - url_parse::Component* out_password); + Component* out_username, + Component* out_password); URL_EXPORT bool CanonicalizeUserInfo(const base::char16* username_source, - const url_parse::Component& username, + const Component& username, const base::char16* password_source, - const url_parse::Component& password, + const Component& password, CanonOutput* output, - url_parse::Component* out_username, - url_parse::Component* out_password); - + Component* out_username, + Component* out_password); // This structure holds detailed state exported from the IP/Host canonicalizers. // Additional fields may be added as callers require them. @@ -339,7 +338,7 @@ struct CanonHostInfo { // Location of host within the canonicalized output. // CanonicalizeIPAddress() only sets this field if |family| is IPV4 or IPV6. // CanonicalizeHostVerbose() always sets it. - url_parse::Component out_host; + Component out_host; // |address| contains the parsed IP Address (if any) in its first // AddressLength() bytes, in network order. If IsIPAddress() is false @@ -359,28 +358,27 @@ struct CanonHostInfo { // The 8-bit version requires UTF-8 encoding. Use this version when you only // need to know whether canonicalization succeeded. URL_EXPORT bool CanonicalizeHost(const char* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, - url_parse::Component* out_host); + Component* out_host); URL_EXPORT bool CanonicalizeHost(const base::char16* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, - url_parse::Component* out_host); + Component* out_host); // Extended version of CanonicalizeHost, which returns additional information. // Use this when you need to know whether the hostname was an IP address. // A successful return is indicated by host_info->family != BROKEN. See the // definition of CanonHostInfo above for details. URL_EXPORT void CanonicalizeHostVerbose(const char* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, CanonHostInfo* host_info); URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, CanonHostInfo* host_info); - // IP addresses. // // Tries to interpret the given host name as an IPv4 or IPv6 address. If it is @@ -392,29 +390,29 @@ URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec, // the input is unescaped and name-prepped, etc. It should not normally be // necessary or wise to call this directly. URL_EXPORT void CanonicalizeIPAddress(const char* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, CanonHostInfo* host_info); URL_EXPORT void CanonicalizeIPAddress(const base::char16* spec, - const url_parse::Component& host, + const Component& host, CanonOutput* output, CanonHostInfo* host_info); // Port: this function will add the colon for the port if a port is present. -// The caller can pass url_parse::PORT_UNSPECIFIED as the +// The caller can pass PORT_UNSPECIFIED as the // default_port_for_scheme argument if there is no default port. // // The 8-bit version requires UTF-8 encoding. URL_EXPORT bool CanonicalizePort(const char* spec, - const url_parse::Component& port, + const Component& port, int default_port_for_scheme, CanonOutput* output, - url_parse::Component* out_port); + Component* out_port); URL_EXPORT bool CanonicalizePort(const base::char16* spec, - const url_parse::Component& port, + const Component& port, int default_port_for_scheme, CanonOutput* output, - url_parse::Component* out_port); + Component* out_port); // Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED // if the scheme is unknown. @@ -430,13 +428,13 @@ URL_EXPORT int DefaultPortForScheme(const char* scheme, int scheme_len); // the path that the server expects (we'll escape high-bit characters), so // if something is invalid, it's their problem. URL_EXPORT bool CanonicalizePath(const char* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); URL_EXPORT bool CanonicalizePath(const base::char16* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); // Canonicalizes the input as a file path. This is like CanonicalizePath except // that it also handles Windows drive specs. For example, the path can begin @@ -445,13 +443,13 @@ URL_EXPORT bool CanonicalizePath(const base::char16* spec, // // The 8-bit version requires UTF-8 encoding. URL_EXPORT bool FileCanonicalizePath(const char* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); URL_EXPORT bool FileCanonicalizePath(const base::char16* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); // Query: Prepends the ? if needed. // @@ -466,15 +464,15 @@ URL_EXPORT bool FileCanonicalizePath(const base::char16* spec, // // The converter can be NULL. In this case, the output encoding will be UTF-8. URL_EXPORT void CanonicalizeQuery(const char* spec, - const url_parse::Component& query, + const Component& query, CharsetConverter* converter, CanonOutput* output, - url_parse::Component* out_query); + Component* out_query); URL_EXPORT void CanonicalizeQuery(const base::char16* spec, - const url_parse::Component& query, + const Component& query, CharsetConverter* converter, CanonOutput* output, - url_parse::Component* out_query); + Component* out_query); // Ref: Prepends the # if needed. The output will be UTF-8 (this is the only // canonicalizer that does not produce ASCII output). The output is @@ -483,13 +481,13 @@ URL_EXPORT void CanonicalizeQuery(const base::char16* spec, // This function will not fail. If the input is invalid UTF-8/UTF-16, we'll use // the "Unicode replacement character" for the confusing bits and copy the rest. URL_EXPORT void CanonicalizeRef(const char* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); URL_EXPORT void CanonicalizeRef(const base::char16* spec, - const url_parse::Component& path, + const Component& path, CanonOutput* output, - url_parse::Component* out_path); + Component* out_path); // Full canonicalizer --------------------------------------------------------- // @@ -504,57 +502,57 @@ URL_EXPORT void CanonicalizeRef(const base::char16* spec, // Use for standard URLs with authorities and paths. URL_EXPORT bool CanonicalizeStandardURL(const char* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool CanonicalizeStandardURL(const base::char16* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Use for file URLs. URL_EXPORT bool CanonicalizeFileURL(const char* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool CanonicalizeFileURL(const base::char16* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Use for filesystem URLs. URL_EXPORT bool CanonicalizeFileSystemURL(const char* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool CanonicalizeFileSystemURL(const base::char16* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Use for path URLs such as javascript. This does not modify the path in any // way, for example, by escaping it. URL_EXPORT bool CanonicalizePathURL(const char* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool CanonicalizePathURL(const base::char16* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Use for mailto URLs. This "canonicalizes" the url into a path and query // component. It does not attempt to merge "to" fields. It uses UTF-8 for @@ -563,14 +561,14 @@ URL_EXPORT bool CanonicalizePathURL(const base::char16* spec, // etc. which would influence a query encoding normally are irrelevant. URL_EXPORT bool CanonicalizeMailtoURL(const char* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool CanonicalizeMailtoURL(const base::char16* spec, int spec_len, - const url_parse::Parsed& parsed, + const Parsed& parsed, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Part replacer -------------------------------------------------------------- @@ -580,7 +578,7 @@ URL_EXPORT bool CanonicalizeMailtoURL(const base::char16* spec, // treated on the same code path as regular canonicalization (the same string // for each component). // -// A url_parse::Parsed structure usually goes along with this. Those +// A Parsed structure usually goes along with this. Those // components identify offsets within these strings, so that they can all be // in the same string, or spread arbitrarily across different ones. // @@ -643,7 +641,7 @@ class Replacements { } // Scheme - void SetScheme(const CHAR* s, const url_parse::Component& comp) { + void SetScheme(const CHAR* s, const Component& comp) { sources_.scheme = s; components_.scheme = comp; } @@ -651,86 +649,86 @@ class Replacements { bool IsSchemeOverridden() const { return sources_.scheme != NULL; } // Username - void SetUsername(const CHAR* s, const url_parse::Component& comp) { + void SetUsername(const CHAR* s, const Component& comp) { sources_.username = s; components_.username = comp; } void ClearUsername() { sources_.username = Placeholder(); - components_.username = url_parse::Component(); + components_.username = Component(); } bool IsUsernameOverridden() const { return sources_.username != NULL; } // Password - void SetPassword(const CHAR* s, const url_parse::Component& comp) { + void SetPassword(const CHAR* s, const Component& comp) { sources_.password = s; components_.password = comp; } void ClearPassword() { sources_.password = Placeholder(); - components_.password = url_parse::Component(); + components_.password = Component(); } bool IsPasswordOverridden() const { return sources_.password != NULL; } // Host - void SetHost(const CHAR* s, const url_parse::Component& comp) { + void SetHost(const CHAR* s, const Component& comp) { sources_.host = s; components_.host = comp; } void ClearHost() { sources_.host = Placeholder(); - components_.host = url_parse::Component(); + components_.host = Component(); } bool IsHostOverridden() const { return sources_.host != NULL; } // Port - void SetPort(const CHAR* s, const url_parse::Component& comp) { + void SetPort(const CHAR* s, const Component& comp) { sources_.port = s; components_.port = comp; } void ClearPort() { sources_.port = Placeholder(); - components_.port = url_parse::Component(); + components_.port = Component(); } bool IsPortOverridden() const { return sources_.port != NULL; } // Path - void SetPath(const CHAR* s, const url_parse::Component& comp) { + void SetPath(const CHAR* s, const Component& comp) { sources_.path = s; components_.path = comp; } void ClearPath() { sources_.path = Placeholder(); - components_.path = url_parse::Component(); + components_.path = Component(); } bool IsPathOverridden() const { return sources_.path != NULL; } // Query - void SetQuery(const CHAR* s, const url_parse::Component& comp) { + void SetQuery(const CHAR* s, const Component& comp) { sources_.query = s; components_.query = comp; } void ClearQuery() { sources_.query = Placeholder(); - components_.query = url_parse::Component(); + components_.query = Component(); } bool IsQueryOverridden() const { return sources_.query != NULL; } // Ref - void SetRef(const CHAR* s, const url_parse::Component& comp) { + void SetRef(const CHAR* s, const Component& comp) { sources_.ref = s; components_.ref = comp; } void ClearRef() { sources_.ref = Placeholder(); - components_.ref = url_parse::Component(); + components_.ref = Component(); } bool IsRefOverridden() const { return sources_.ref != NULL; } // Getters for the itnernal data. See the variables below for how the // information is encoded. const URLComponentSource<CHAR>& sources() const { return sources_; } - const url_parse::Parsed& components() const { return components_; } + const Parsed& components() const { return components_; } private: // Returns a pointer to a static empty string that is used as a placeholder @@ -751,80 +749,80 @@ class Replacements { // We use a pointer to the empty string for the source when the component // should be deleted. URLComponentSource<CHAR> sources_; - url_parse::Parsed components_; + Parsed components_; }; // The base must be an 8-bit canonical URL. URL_EXPORT bool ReplaceStandardURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<char>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool ReplaceStandardURL( const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<base::char16>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Filesystem URLs can only have the path, query, or ref replaced. // All other components will be ignored. URL_EXPORT bool ReplaceFileSystemURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<char>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool ReplaceFileSystemURL( const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<base::char16>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Replacing some parts of a file URL is not permitted. Everything except // the host, path, query, and ref will be ignored. URL_EXPORT bool ReplaceFileURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<char>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool ReplaceFileURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<base::char16>& replacements, CharsetConverter* query_converter, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Path URLs can only have the scheme and path replaced. All other components // will be ignored. URL_EXPORT bool ReplacePathURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<char>& replacements, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool ReplacePathURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<base::char16>& replacements, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Mailto URLs can only have the scheme, path, and query replaced. // All other components will be ignored. URL_EXPORT bool ReplaceMailtoURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<char>& replacements, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); URL_EXPORT bool ReplaceMailtoURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const Replacements<base::char16>& replacements, CanonOutput* output, - url_parse::Parsed* new_parsed); + Parsed* new_parsed); // Relative URL --------------------------------------------------------------- @@ -840,19 +838,19 @@ URL_EXPORT bool ReplaceMailtoURL(const char* base, // // The base URL should always be canonical, therefore is ASCII. URL_EXPORT bool IsRelativeURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const char* fragment, int fragment_len, bool is_base_hierarchical, bool* is_relative, - url_parse::Component* relative_component); + Component* relative_component); URL_EXPORT bool IsRelativeURL(const char* base, - const url_parse::Parsed& base_parsed, + const Parsed& base_parsed, const base::char16* fragment, int fragment_len, bool is_base_hierarchical, bool* is_relative, - url_parse::Component* relative_component); + Component* relative_component); // Given a canonical parsed source URL, a URL fragment known to be relative, // and the identified relevant portion of the relative URL (computed by @@ -872,25 +870,23 @@ URL_EXPORT bool IsRelativeURL(const char* base, // Returns true on success. On failure, the output will be "something // reasonable" that will be consistent and valid, just probably not what // was intended by the web page author or caller. -URL_EXPORT bool ResolveRelativeURL( - const char* base_url, - const url_parse::Parsed& base_parsed, - bool base_is_file, - const char* relative_url, - const url_parse::Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - url_parse::Parsed* out_parsed); -URL_EXPORT bool ResolveRelativeURL( - const char* base_url, - const url_parse::Parsed& base_parsed, - bool base_is_file, - const base::char16* relative_url, - const url_parse::Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - url_parse::Parsed* out_parsed); +URL_EXPORT bool ResolveRelativeURL(const char* base_url, + const Parsed& base_parsed, + bool base_is_file, + const char* relative_url, + const Component& relative_component, + CharsetConverter* query_converter, + CanonOutput* output, + Parsed* out_parsed); +URL_EXPORT bool ResolveRelativeURL(const char* base_url, + const Parsed& base_parsed, + bool base_is_file, + const base::char16* relative_url, + const Component& relative_component, + CharsetConverter* query_converter, + CanonOutput* output, + Parsed* out_parsed); -} // namespace url_canon +} // namespace url #endif // URL_URL_CANON_H_ |