0

Revert 203027 "Revert 203025 "Make the copy of GURL in src/url b..."

> Revert 203025 "Make the copy of GURL in src/url buildable as a c..."
> 
> > Make the copy of GURL in src/url buildable as a component build. (try 2)
> > 
> > BUG=229660
> > TBR=brettw
> > 
> > Review URL: https://chromiumcodereview.appspot.com/15805003
> 
> TBR=thestig@chromium.org
> 
> Review URL: https://codereview.chromium.org/15848009

TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/15799007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203324 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
thestig@chromium.org
2013-05-31 03:39:51 +00:00
parent 0d73505820
commit 760ea500a1
9 changed files with 440 additions and 391 deletions

@@ -11,9 +11,10 @@
#include "base/string16.h" #include "base/string16.h"
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_canon_stdstring.h" #include "url/url_canon_stdstring.h"
#include "url/url_export.h"
#include "url/url_parse.h" #include "url/url_parse.h"
class GURL { class URL_EXPORT GURL {
public: public:
typedef url_canon::StdStringReplacements<std::string> Replacements; typedef url_canon::StdStringReplacements<std::string> Replacements;
typedef url_canon::StdStringReplacements<string16> ReplacementsW; typedef url_canon::StdStringReplacements<string16> ReplacementsW;
@@ -32,10 +33,8 @@ class GURL {
// encode the query parameters. It is probably sufficient for the narrow // encode the query parameters. It is probably sufficient for the narrow
// version to assume the query parameter encoding should be the same as the // version to assume the query parameter encoding should be the same as the
// input encoding. // input encoding.
explicit GURL(const std::string& url_string explicit GURL(const std::string& url_string /*, output_param_encoding*/);
/*, output_param_encoding*/); explicit GURL(const string16& url_string /*, output_param_encoding*/);
explicit GURL(const string16& url_string
/*, output_param_encoding*/);
// Constructor for URLs that have already been parsed and canonicalized. This // Constructor for URLs that have already been parsed and canonicalized. This
// is used for conversions from KURL, for example. The caller must supply all // is used for conversions from KURL, for example. The caller must supply all
@@ -361,6 +360,6 @@ class GURL {
}; };
// Stream operator so GURL can be used in assertion statements. // Stream operator so GURL can be used in assertion statements.
std::ostream& operator<<(std::ostream& out, const GURL& url); URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url);
#endif // URL_GURL_H_ #endif // URL_GURL_H_

@@ -8,8 +8,11 @@
}, },
'targets': [ 'targets': [
{ {
'target_name': 'url', # Note, this target_name cannot be 'url', because that will generate
'type': 'static_library', # 'url.dll' for a Windows component build, and that will confuse Windows,
# which has a system DLL with the same name.
'target_name': 'url_lib',
'type': '<(component)',
'dependencies': [ 'dependencies': [
'../base/base.gyp:base', '../base/base.gyp:base',
'../third_party/icu/icu.gyp:icudata', '../third_party/icu/icu.gyp:icudata',
@@ -52,7 +55,7 @@
], ],
}, },
'defines': [ 'defines': [
'FULL_FILESYSTEM_URL_SUPPORT=1', 'URL_IMPLEMENTATION',
], ],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations. # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [4267, ], 'msvs_disabled_warnings': [4267, ],
@@ -65,7 +68,7 @@
'../base/base.gyp:run_all_unittests', '../base/base.gyp:run_all_unittests',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
'url', 'url_lib',
], ],
'sources': [ 'sources': [
'gurl_unittest.cc', 'gurl_unittest.cc',
@@ -74,9 +77,6 @@
'url_test_utils.h', 'url_test_utils.h',
'url_util_unittest.cc', 'url_util_unittest.cc',
], ],
'defines': [
'FULL_FILESYSTEM_URL_SUPPORT=1',
],
'conditions': [ 'conditions': [
['os_posix==1 and OS!="mac" and OS!="ios"', ['os_posix==1 and OS!="mac" and OS!="ios"',
{ {

@@ -9,6 +9,7 @@
#include <string.h> #include <string.h>
#include "base/string16.h" #include "base/string16.h"
#include "url/url_export.h"
#include "url/url_parse.h" #include "url/url_parse.h"
namespace url_canon { namespace url_canon {
@@ -186,7 +187,7 @@ class RawCanonOutputW : public RawCanonOutputT<char16, fixed_capacity> {};
// //
// Embedders will want to see the unit test for the ICU version. // Embedders will want to see the unit test for the ICU version.
class CharsetConverter { class URL_EXPORT CharsetConverter {
public: public:
CharsetConverter() {} CharsetConverter() {}
virtual ~CharsetConverter() {} virtual ~CharsetConverter() {}
@@ -224,12 +225,12 @@ class CharsetConverter {
// //
// Therefore, callers should not use the buffer, since it may actuall be empty, // Therefore, callers should not use the buffer, since it may actuall be empty,
// use the computed pointer and |*output_len| instead. // use the computed pointer and |*output_len| instead.
const char* RemoveURLWhitespace(const char* input, int input_len, URL_EXPORT const char* RemoveURLWhitespace(const char* input, int input_len,
CanonOutputT<char>* buffer, CanonOutputT<char>* buffer,
int* output_len); int* output_len);
const char16* RemoveURLWhitespace(const char16* input, int input_len, URL_EXPORT const char16* RemoveURLWhitespace(const char16* input, int input_len,
CanonOutputT<char16>* buffer, CanonOutputT<char16>* buffer,
int* output_len); int* output_len);
// IDN ------------------------------------------------------------------------ // IDN ------------------------------------------------------------------------
@@ -242,7 +243,9 @@ const char16* RemoveURLWhitespace(const char16* input, int input_len,
// the length of the output will be set to the length of the new host name. // the length of the output will be set to the length of the new host name.
// //
// On error, returns false. The output in this case is undefined. // On error, returns false. The output in this case is undefined.
bool IDNToASCII(const char16* src, int src_len, CanonOutputW* output); URL_EXPORT bool IDNToASCII(const char16* src,
int src_len,
CanonOutputW* output);
// Piece-by-piece canonicalizers ---------------------------------------------- // Piece-by-piece canonicalizers ----------------------------------------------
// //
@@ -268,14 +271,14 @@ bool IDNToASCII(const char16* src, int src_len, CanonOutputW* output);
// URLs. // URLs.
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
bool CanonicalizeScheme(const char* spec, URL_EXPORT bool CanonicalizeScheme(const char* spec,
const url_parse::Component& scheme, const url_parse::Component& scheme,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_scheme); url_parse::Component* out_scheme);
bool CanonicalizeScheme(const char16* spec, URL_EXPORT bool CanonicalizeScheme(const char16* spec,
const url_parse::Component& scheme, const url_parse::Component& scheme,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_scheme); url_parse::Component* out_scheme);
// User info: username/password. If present, this will add the delimiters so // User info: username/password. If present, this will add the delimiters so
// the output will be "<username>:<password>@" or "<username>@". Empty // the output will be "<username>:<password>@" or "<username>@". Empty
@@ -287,20 +290,20 @@ bool CanonicalizeScheme(const char16* spec,
// is legal as long as the two components don't overlap. // is legal as long as the two components don't overlap.
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
bool CanonicalizeUserInfo(const char* username_source, URL_EXPORT bool CanonicalizeUserInfo(const char* username_source,
const url_parse::Component& username, const url_parse::Component& username,
const char* password_source, const char* password_source,
const url_parse::Component& password, const url_parse::Component& password,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_username, url_parse::Component* out_username,
url_parse::Component* out_password); url_parse::Component* out_password);
bool CanonicalizeUserInfo(const char16* username_source, URL_EXPORT bool CanonicalizeUserInfo(const char16* username_source,
const url_parse::Component& username, const url_parse::Component& username,
const char16* password_source, const char16* password_source,
const url_parse::Component& password, const url_parse::Component& password,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_username, url_parse::Component* out_username,
url_parse::Component* out_password); url_parse::Component* out_password);
// This structure holds detailed state exported from the IP/Host canonicalizers. // This structure holds detailed state exported from the IP/Host canonicalizers.
@@ -353,27 +356,27 @@ struct CanonHostInfo {
// //
// The 8-bit version requires UTF-8 encoding. Use this version when you only // The 8-bit version requires UTF-8 encoding. Use this version when you only
// need to know whether canonicalization succeeded. // need to know whether canonicalization succeeded.
bool CanonicalizeHost(const char* spec, URL_EXPORT bool CanonicalizeHost(const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_host); url_parse::Component* out_host);
bool CanonicalizeHost(const char16* spec, URL_EXPORT bool CanonicalizeHost(const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_host); url_parse::Component* out_host);
// Extended version of CanonicalizeHost, which returns additional information. // Extended version of CanonicalizeHost, which returns additional information.
// Use this when you need to know whether the hostname was an IP address. // 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 // A successful return is indicated by host_info->family != BROKEN. See the
// definition of CanonHostInfo above for details. // definition of CanonHostInfo above for details.
void CanonicalizeHostVerbose(const char* spec, URL_EXPORT void CanonicalizeHostVerbose(const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
CanonHostInfo* host_info); CanonHostInfo* host_info);
void CanonicalizeHostVerbose(const char16* spec, URL_EXPORT void CanonicalizeHostVerbose(const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
CanonHostInfo* host_info); CanonHostInfo* host_info);
// IP addresses. // IP addresses.
@@ -386,34 +389,34 @@ void CanonicalizeHostVerbose(const char16* spec,
// This is called AUTOMATICALLY from the host canonicalizer, which ensures that // This is called AUTOMATICALLY from the host canonicalizer, which ensures that
// the input is unescaped and name-prepped, etc. It should not normally be // the input is unescaped and name-prepped, etc. It should not normally be
// necessary or wise to call this directly. // necessary or wise to call this directly.
void CanonicalizeIPAddress(const char* spec, URL_EXPORT void CanonicalizeIPAddress(const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
CanonHostInfo* host_info); CanonHostInfo* host_info);
void CanonicalizeIPAddress(const char16* spec, URL_EXPORT void CanonicalizeIPAddress(const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
CanonOutput* output, CanonOutput* output,
CanonHostInfo* host_info); CanonHostInfo* host_info);
// Port: this function will add the colon for the port if a port is present. // 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 url_parse::PORT_UNSPECIFIED as the
// default_port_for_scheme argument if there is no default port. // default_port_for_scheme argument if there is no default port.
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
bool CanonicalizePort(const char* spec, URL_EXPORT bool CanonicalizePort(const char* spec,
const url_parse::Component& port, const url_parse::Component& port,
int default_port_for_scheme, int default_port_for_scheme,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_port); url_parse::Component* out_port);
bool CanonicalizePort(const char16* spec, URL_EXPORT bool CanonicalizePort(const char16* spec,
const url_parse::Component& port, const url_parse::Component& port,
int default_port_for_scheme, int default_port_for_scheme,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_port); url_parse::Component* out_port);
// Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED // Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED
// if the scheme is unknown. // if the scheme is unknown.
int DefaultPortForScheme(const char* scheme, int scheme_len); URL_EXPORT int DefaultPortForScheme(const char* scheme, int scheme_len);
// Path. If the input does not begin in a slash (including if the input is // Path. If the input does not begin in a slash (including if the input is
// empty), we'll prepend a slash to the path to make it canonical. // empty), we'll prepend a slash to the path to make it canonical.
@@ -424,14 +427,14 @@ int DefaultPortForScheme(const char* scheme, int scheme_len);
// an issue. Somebody giving us an 8-bit path is responsible for generating // an issue. Somebody giving us an 8-bit path is responsible for generating
// the path that the server expects (we'll escape high-bit characters), so // the path that the server expects (we'll escape high-bit characters), so
// if something is invalid, it's their problem. // if something is invalid, it's their problem.
bool CanonicalizePath(const char* spec, URL_EXPORT bool CanonicalizePath(const char* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
bool CanonicalizePath(const char16* spec, URL_EXPORT bool CanonicalizePath(const char16* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
// Canonicalizes the input as a file path. This is like CanonicalizePath except // 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 // that it also handles Windows drive specs. For example, the path can begin
@@ -439,14 +442,14 @@ bool CanonicalizePath(const char16* spec,
// The string will be appended to |*output| and |*out_path| will be updated. // The string will be appended to |*output| and |*out_path| will be updated.
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
bool FileCanonicalizePath(const char* spec, URL_EXPORT bool FileCanonicalizePath(const char* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
bool FileCanonicalizePath(const char16* spec, URL_EXPORT bool FileCanonicalizePath(const char16* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
// Query: Prepends the ? if needed. // Query: Prepends the ? if needed.
// //
@@ -460,16 +463,16 @@ bool FileCanonicalizePath(const char16* spec,
// if necessary, for ASCII input, no conversions are necessary. // if necessary, for ASCII input, no conversions are necessary.
// //
// The converter can be NULL. In this case, the output encoding will be UTF-8. // The converter can be NULL. In this case, the output encoding will be UTF-8.
void CanonicalizeQuery(const char* spec, URL_EXPORT void CanonicalizeQuery(const char* spec,
const url_parse::Component& query, const url_parse::Component& query,
CharsetConverter* converter, CharsetConverter* converter,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_query); url_parse::Component* out_query);
void CanonicalizeQuery(const char16* spec, URL_EXPORT void CanonicalizeQuery(const char16* spec,
const url_parse::Component& query, const url_parse::Component& query,
CharsetConverter* converter, CharsetConverter* converter,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_query); url_parse::Component* out_query);
// Ref: Prepends the # if needed. The output will be UTF-8 (this is the only // 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 // canonicalizer that does not produce ASCII output). The output is
@@ -477,14 +480,14 @@ void CanonicalizeQuery(const char16* spec,
// //
// This function will not fail. If the input is invalid UTF-8/UTF-16, we'll use // 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. // the "Unicode replacement character" for the confusing bits and copy the rest.
void CanonicalizeRef(const char* spec, URL_EXPORT void CanonicalizeRef(const char* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
void CanonicalizeRef(const char16* spec, URL_EXPORT void CanonicalizeRef(const char16* spec,
const url_parse::Component& path, const url_parse::Component& path,
CanonOutput* output, CanonOutput* output,
url_parse::Component* out_path); url_parse::Component* out_path);
// Full canonicalizer --------------------------------------------------------- // Full canonicalizer ---------------------------------------------------------
// //
@@ -497,75 +500,75 @@ void CanonicalizeRef(const char16* spec,
// The 8-bit versions require UTF-8 encoding. // The 8-bit versions require UTF-8 encoding.
// Use for standard URLs with authorities and paths. // Use for standard URLs with authorities and paths.
bool CanonicalizeStandardURL(const char* spec, URL_EXPORT bool CanonicalizeStandardURL(const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool CanonicalizeStandardURL(const char16* spec, URL_EXPORT bool CanonicalizeStandardURL(const char16* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Use for file URLs. // Use for file URLs.
bool CanonicalizeFileURL(const char* spec, URL_EXPORT bool CanonicalizeFileURL(const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool CanonicalizeFileURL(const char16* spec, URL_EXPORT bool CanonicalizeFileURL(const char16* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Use for filesystem URLs. // Use for filesystem URLs.
bool CanonicalizeFileSystemURL(const char* spec, URL_EXPORT bool CanonicalizeFileSystemURL(const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool CanonicalizeFileSystemURL(const char16* spec, URL_EXPORT bool CanonicalizeFileSystemURL(const char16* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Use for path URLs such as javascript. This does not modify the path in any // Use for path URLs such as javascript. This does not modify the path in any
// way, for example, by escaping it. // way, for example, by escaping it.
bool CanonicalizePathURL(const char* spec, URL_EXPORT bool CanonicalizePathURL(const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool CanonicalizePathURL(const char16* spec, URL_EXPORT bool CanonicalizePathURL(const char16* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Use for mailto URLs. This "canonicalizes" the url into a path and query // 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 // component. It does not attempt to merge "to" fields. It uses UTF-8 for
// the query encoding if there is a query. This is because a mailto URL is // the query encoding if there is a query. This is because a mailto URL is
// really intended for an external mail program, and the encoding of a page, // really intended for an external mail program, and the encoding of a page,
// etc. which would influence a query encoding normally are irrelevant. // etc. which would influence a query encoding normally are irrelevant.
bool CanonicalizeMailtoURL(const char* spec, URL_EXPORT bool CanonicalizeMailtoURL(const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool CanonicalizeMailtoURL(const char16* spec, URL_EXPORT bool CanonicalizeMailtoURL(const char16* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Part replacer -------------------------------------------------------------- // Part replacer --------------------------------------------------------------
@@ -750,74 +753,74 @@ class Replacements {
}; };
// The base must be an 8-bit canonical URL. // The base must be an 8-bit canonical URL.
bool ReplaceStandardURL(const char* base, URL_EXPORT bool ReplaceStandardURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char>& replacements, const Replacements<char>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool ReplaceStandardURL(const char* base, URL_EXPORT bool ReplaceStandardURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char16>& replacements, const Replacements<char16>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Filesystem URLs can only have the path, query, or ref replaced. // Filesystem URLs can only have the path, query, or ref replaced.
// All other components will be ignored. // All other components will be ignored.
bool ReplaceFileSystemURL(const char* base, URL_EXPORT bool ReplaceFileSystemURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char>& replacements, const Replacements<char>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool ReplaceFileSystemURL(const char* base, URL_EXPORT bool ReplaceFileSystemURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char16>& replacements, const Replacements<char16>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Replacing some parts of a file URL is not permitted. Everything except // Replacing some parts of a file URL is not permitted. Everything except
// the host, path, query, and ref will be ignored. // the host, path, query, and ref will be ignored.
bool ReplaceFileURL(const char* base, URL_EXPORT bool ReplaceFileURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char>& replacements, const Replacements<char>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool ReplaceFileURL(const char* base, URL_EXPORT bool ReplaceFileURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char16>& replacements, const Replacements<char16>& replacements,
CharsetConverter* query_converter, CharsetConverter* query_converter,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Path URLs can only have the scheme and path replaced. All other components // Path URLs can only have the scheme and path replaced. All other components
// will be ignored. // will be ignored.
bool ReplacePathURL(const char* base, URL_EXPORT bool ReplacePathURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char>& replacements, const Replacements<char>& replacements,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool ReplacePathURL(const char* base, URL_EXPORT bool ReplacePathURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char16>& replacements, const Replacements<char16>& replacements,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Mailto URLs can only have the scheme, path, and query replaced. // Mailto URLs can only have the scheme, path, and query replaced.
// All other components will be ignored. // All other components will be ignored.
bool ReplaceMailtoURL(const char* base, URL_EXPORT bool ReplaceMailtoURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char>& replacements, const Replacements<char>& replacements,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
bool ReplaceMailtoURL(const char* base, URL_EXPORT bool ReplaceMailtoURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const Replacements<char16>& replacements, const Replacements<char16>& replacements,
CanonOutput* output, CanonOutput* output,
url_parse::Parsed* new_parsed); url_parse::Parsed* new_parsed);
// Relative URL --------------------------------------------------------------- // Relative URL ---------------------------------------------------------------
@@ -832,20 +835,20 @@ bool ReplaceMailtoURL(const char* base,
// not). Failure means that the combination of URLs doesn't make any sense. // not). Failure means that the combination of URLs doesn't make any sense.
// //
// The base URL should always be canonical, therefore is ASCII. // The base URL should always be canonical, therefore is ASCII.
bool IsRelativeURL(const char* base, URL_EXPORT bool IsRelativeURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const char* fragment, const char* fragment,
int fragment_len, int fragment_len,
bool is_base_hierarchical, bool is_base_hierarchical,
bool* is_relative, bool* is_relative,
url_parse::Component* relative_component); url_parse::Component* relative_component);
bool IsRelativeURL(const char* base, URL_EXPORT bool IsRelativeURL(const char* base,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const char16* fragment, const char16* fragment,
int fragment_len, int fragment_len,
bool is_base_hierarchical, bool is_base_hierarchical,
bool* is_relative, bool* is_relative,
url_parse::Component* relative_component); url_parse::Component* relative_component);
// Given a canonical parsed source URL, a URL fragment known to be relative, // Given a canonical parsed source URL, a URL fragment known to be relative,
// and the identified relevant portion of the relative URL (computed by // and the identified relevant portion of the relative URL (computed by
@@ -865,22 +868,24 @@ bool IsRelativeURL(const char* base,
// Returns true on success. On failure, the output will be "something // Returns true on success. On failure, the output will be "something
// reasonable" that will be consistent and valid, just probably not what // reasonable" that will be consistent and valid, just probably not what
// was intended by the web page author or caller. // was intended by the web page author or caller.
bool ResolveRelativeURL(const char* base_url, URL_EXPORT bool ResolveRelativeURL(
const url_parse::Parsed& base_parsed, const char* base_url,
bool base_is_file, const url_parse::Parsed& base_parsed,
const char* relative_url, bool base_is_file,
const url_parse::Component& relative_component, const char* relative_url,
CharsetConverter* query_converter, const url_parse::Component& relative_component,
CanonOutput* output, CharsetConverter* query_converter,
url_parse::Parsed* out_parsed); CanonOutput* output,
bool ResolveRelativeURL(const char* base_url, url_parse::Parsed* out_parsed);
const url_parse::Parsed& base_parsed, URL_EXPORT bool ResolveRelativeURL(
bool base_is_file, const char* base_url,
const char16* relative_url, const url_parse::Parsed& base_parsed,
const url_parse::Component& relative_component, bool base_is_file,
CharsetConverter* query_converter, const char16* relative_url,
CanonOutput* output, const url_parse::Component& relative_component,
url_parse::Parsed* out_parsed); CharsetConverter* query_converter,
CanonOutput* output,
url_parse::Parsed* out_parsed);
} // namespace url_canon } // namespace url_canon

@@ -8,6 +8,7 @@
// ICU integration functions. // ICU integration functions.
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_export.h"
typedef struct UConverter UConverter; typedef struct UConverter UConverter;
@@ -15,7 +16,7 @@ namespace url_canon {
// An implementation of CharsetConverter that implementations can use to // An implementation of CharsetConverter that implementations can use to
// interface the canonicalizer with ICU's conversion routines. // interface the canonicalizer with ICU's conversion routines.
class ICUCharsetConverter : public CharsetConverter { class URL_EXPORT ICUCharsetConverter : public CharsetConverter {
public: public:
// Constructs a converter using an already-existing ICU character set // Constructs a converter using an already-existing ICU character set
// converter. This converter is NOT owned by this object; the lifetime must // converter. This converter is NOT owned by this object; the lifetime must

@@ -83,7 +83,7 @@ void AppendStringOfType(const char16* source, int length,
// Maps the hex numerical values 0x0 to 0xf to the corresponding ASCII digit // Maps the hex numerical values 0x0 to 0xf to the corresponding ASCII digit
// that will be used to represent it. // that will be used to represent it.
extern const char kHexCharLookup[0x10]; URL_EXPORT extern const char kHexCharLookup[0x10];
// This lookup table allows fast conversion between ASCII hex letters and their // This lookup table allows fast conversion between ASCII hex letters and their
// corresponding numerical value. The 8-bit range is divided up into 8 // corresponding numerical value. The 8-bit range is divided up into 8
@@ -150,8 +150,8 @@ extern const char16 kUnicodeReplacementCharacter;
// (for a single-byte ASCII character, it will not be changed). // (for a single-byte ASCII character, it will not be changed).
// //
// Implementation is in url_canon_icu.cc. // Implementation is in url_canon_icu.cc.
bool ReadUTFChar(const char* str, int* begin, int length, URL_EXPORT bool ReadUTFChar(const char* str, int* begin, int length,
unsigned* code_point_out); unsigned* code_point_out);
// Generic To-UTF-8 converter. This will call the given append method for each // Generic To-UTF-8 converter. This will call the given append method for each
// character that should be appended, with the given output method. Wrappers // character that should be appended, with the given output method. Wrappers
@@ -227,8 +227,8 @@ inline void AppendUTF8EscapedValue(unsigned char_value, CanonOutput* output) {
// (for a single-16-bit-word character, it will not be changed). // (for a single-16-bit-word character, it will not be changed).
// //
// Implementation is in url_canon_icu.cc. // Implementation is in url_canon_icu.cc.
bool ReadUTFChar(const char16* str, int* begin, int length, URL_EXPORT bool ReadUTFChar(const char16* str, int* begin, int length,
unsigned* code_point); unsigned* code_point);
// Equivalent to U16_APPEND_UNSAFE in ICU but uses our output method. // Equivalent to U16_APPEND_UNSAFE in ICU but uses our output method.
inline void AppendUTF16Value(unsigned code_point, inline void AppendUTF16Value(unsigned code_point,
@@ -346,10 +346,10 @@ void AppendInvalidNarrowString(const char16* spec, int begin, int end,
// replacing the invalid characters with the "invalid character". It will // replacing the invalid characters with the "invalid character". It will
// return false in the failure case, and the caller should not continue as // return false in the failure case, and the caller should not continue as
// normal. // normal.
bool ConvertUTF16ToUTF8(const char16* input, int input_len, URL_EXPORT bool ConvertUTF16ToUTF8(const char16* input, int input_len,
CanonOutput* output); CanonOutput* output);
bool ConvertUTF8ToUTF16(const char* input, int input_len, URL_EXPORT bool ConvertUTF8ToUTF16(const char* input, int input_len,
CanonOutputT<char16>* output); CanonOutputT<char16>* output);
// Converts from UTF-16 to 8-bit using the character set converter. If the // Converts from UTF-16 to 8-bit using the character set converter. If the
// converter is NULL, this will use UTF-8. // converter is NULL, this will use UTF-8.
@@ -408,9 +408,10 @@ bool CanonicalizePartialPath(const char16* spec,
#ifndef WIN32 #ifndef WIN32
// Implementations of Windows' int-to-string conversions // Implementations of Windows' int-to-string conversions
int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix); URL_EXPORT int _itoa_s(int value, char* buffer, size_t size_in_chars,
int _itow_s(int value, char16* buffer, size_t size_in_chars, int radix);
int radix); URL_EXPORT int _itow_s(int value, char16* buffer, size_t size_in_chars,
int radix);
// Secure template overloads for these functions // Secure template overloads for these functions
template<size_t N> template<size_t N>

@@ -7,17 +7,18 @@
#include "base/string16.h" #include "base/string16.h"
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_export.h"
#include "url/url_parse.h" #include "url/url_parse.h"
namespace url_canon { namespace url_canon {
// Writes the given IPv4 address to |output|. // Writes the given IPv4 address to |output|.
void AppendIPv4Address(const unsigned char address[4], URL_EXPORT void AppendIPv4Address(const unsigned char address[4],
CanonOutput* output); CanonOutput* output);
// Writes the given IPv6 address to |output|. // Writes the given IPv6 address to |output|.
void AppendIPv6Address(const unsigned char address[16], URL_EXPORT void AppendIPv6Address(const unsigned char address[16],
CanonOutput* output); CanonOutput* output);
// Searches the host name for the portions of the IPv4 address. On success, // Searches the host name for the portions of the IPv4 address. On success,
// each component will be placed into |components| and it will return true. // each component will be placed into |components| and it will return true.
@@ -37,12 +38,12 @@ void AppendIPv6Address(const unsigned char address[16],
// Mozilla), so this code path never gets hit. Our host canonicalization will // Mozilla), so this code path never gets hit. Our host canonicalization will
// notice these spaces and escape them, which will make IP address finding // notice these spaces and escape them, which will make IP address finding
// fail. This seems like better behavior than stripping after a space. // fail. This seems like better behavior than stripping after a space.
bool FindIPv4Components(const char* spec, URL_EXPORT bool FindIPv4Components(const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
url_parse::Component components[4]); url_parse::Component components[4]);
bool FindIPv4Components(const char16* spec, URL_EXPORT bool FindIPv4Components(const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
url_parse::Component components[4]); url_parse::Component components[4]);
// Converts an IPv4 address to a 32-bit number (network byte order). // Converts an IPv4 address to a 32-bit number (network byte order).
// //
@@ -55,12 +56,12 @@ bool FindIPv4Components(const char16* spec,
// //
// On success, |num_ipv4_components| will be populated with the number of // On success, |num_ipv4_components| will be populated with the number of
// components in the IPv4 address. // components in the IPv4 address.
CanonHostInfo::Family IPv4AddressToNumber( URL_EXPORT CanonHostInfo::Family IPv4AddressToNumber(
const char* spec, const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
unsigned char address[4], unsigned char address[4],
int* num_ipv4_components); int* num_ipv4_components);
CanonHostInfo::Family IPv4AddressToNumber( URL_EXPORT CanonHostInfo::Family IPv4AddressToNumber(
const char16* spec, const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
unsigned char address[4], unsigned char address[4],
@@ -71,12 +72,12 @@ CanonHostInfo::Family IPv4AddressToNumber(
// //
// NOTE that |host| is expected to be surrounded by square brackets. // NOTE that |host| is expected to be surrounded by square brackets.
// i.e. "[::1]" rather than "::1". // i.e. "[::1]" rather than "::1".
bool IPv6AddressToNumber(const char* spec, URL_EXPORT bool IPv6AddressToNumber(const char* spec,
const url_parse::Component& host, const url_parse::Component& host,
unsigned char address[16]); unsigned char address[16]);
bool IPv6AddressToNumber(const char16* spec, URL_EXPORT bool IPv6AddressToNumber(const char16* spec,
const url_parse::Component& host, const url_parse::Component& host,
unsigned char address[16]); unsigned char address[16]);
} // namespace url_canon } // namespace url_canon

33
url/url_export.h Normal file

@@ -0,0 +1,33 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef URL_URL_EXPORT_H_
#define URL_URL_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(URL_IMPLEMENTATION)
#define URL_EXPORT __declspec(dllexport)
#else
#define URL_EXPORT __declspec(dllimport)
#endif // defined(URL_IMPLEMENTATION)
#else // !defined(WIN32)
#if defined(URL_IMPLEMENTATION)
#define URL_EXPORT __attribute__((visibility("default")))
#else
#define URL_EXPORT
#endif // defined(URL_IMPLEMENTATION)
#endif // defined(WIN32)
#else // !defined(COMPONENT_BUILD)
#define URL_EXPORT
#endif // define(COMPONENT_BUILD)
#endif // URL_URL_EXPORT_H_

@@ -9,6 +9,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/string16.h" #include "base/string16.h"
#include "url/url_export.h"
namespace url_parse { namespace url_parse {
@@ -80,7 +81,7 @@ inline Component MakeRange(int begin, int end) {
// else // else
// url_parse::ParsePathURL(url, url_len, &parsed); // url_parse::ParsePathURL(url, url_len, &parsed);
// //
struct Parsed { struct URL_EXPORT Parsed {
// Identifies different components. // Identifies different components.
enum ComponentType { enum ComponentType {
SCHEME, SCHEME,
@@ -134,8 +135,7 @@ struct Parsed {
// *QUERY: 14 15 <- // *QUERY: 14 15 <-
// *REF: 20 20 // *REF: 20 20
// //
int CountCharactersBefore(ComponentType type, int CountCharactersBefore(ComponentType type, bool include_delimiter) const;
bool include_delimiter) const;
// Scheme without the colon: "http://foo"/ would have a scheme of "http". // Scheme without the colon: "http://foo"/ would have a scheme of "http".
// The length will be -1 if no scheme is specified ("foo.com"), or 0 if there // The length will be -1 if no scheme is specified ("foo.com"), or 0 if there
@@ -220,32 +220,36 @@ struct Parsed {
// StandardURL is for when the scheme is known to be one that has an // StandardURL is for when the scheme is known to be one that has an
// authority (host) like "http". This function will not handle weird ones // authority (host) like "http". This function will not handle weird ones
// like "about:" and "javascript:", or do the right thing for "file:" URLs. // like "about:" and "javascript:", or do the right thing for "file:" URLs.
void ParseStandardURL(const char* url, int url_len, Parsed* parsed); URL_EXPORT void ParseStandardURL(const char* url,
void ParseStandardURL(const char16* url, int url_len, Parsed* parsed); int url_len,
Parsed* parsed);
URL_EXPORT void ParseStandardURL(const char16* url,
int url_len,
Parsed* parsed);
// PathURL is for when the scheme is known not to have an authority (host) // PathURL is for when the scheme is known not to have an authority (host)
// section but that aren't file URLs either. The scheme is parsed, and // section but that aren't file URLs either. The scheme is parsed, and
// everything after the scheme is considered as the path. This is used for // everything after the scheme is considered as the path. This is used for
// things like "about:" and "javascript:" // things like "about:" and "javascript:"
void ParsePathURL(const char* url, int url_len, Parsed* parsed); URL_EXPORT void ParsePathURL(const char* url, int url_len, Parsed* parsed);
void ParsePathURL(const char16* url, int url_len, Parsed* parsed); URL_EXPORT void ParsePathURL(const char16* url, int url_len, Parsed* parsed);
// FileURL is for file URLs. There are some special rules for interpreting // FileURL is for file URLs. There are some special rules for interpreting
// these. // these.
void ParseFileURL(const char* url, int url_len, Parsed* parsed); URL_EXPORT void ParseFileURL(const char* url, int url_len, Parsed* parsed);
void ParseFileURL(const char16* url, int url_len, Parsed* parsed); URL_EXPORT void ParseFileURL(const char16* url, int url_len, Parsed* parsed);
// Filesystem URLs are structured differently than other URLs. // Filesystem URLs are structured differently than other URLs.
void ParseFileSystemURL(const char* url, URL_EXPORT void ParseFileSystemURL(const char* url,
int url_len, int url_len,
Parsed* parsed); Parsed* parsed);
void ParseFileSystemURL(const char16* url, URL_EXPORT void ParseFileSystemURL(const char16* url,
int url_len, int url_len,
Parsed* parsed); Parsed* parsed);
// MailtoURL is for mailto: urls. They are made up scheme,path,query // MailtoURL is for mailto: urls. They are made up scheme,path,query
void ParseMailtoURL(const char* url, int url_len, Parsed* parsed); URL_EXPORT void ParseMailtoURL(const char* url, int url_len, Parsed* parsed);
void ParseMailtoURL(const char16* url, int url_len, Parsed* parsed); URL_EXPORT void ParseMailtoURL(const char16* url, int url_len, Parsed* parsed);
// Helper functions ----------------------------------------------------------- // Helper functions -----------------------------------------------------------
@@ -269,27 +273,31 @@ void ParseMailtoURL(const char16* url, int url_len, Parsed* parsed);
// end of the string). // end of the string).
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
bool ExtractScheme(const char* url, int url_len, Component* scheme); URL_EXPORT bool ExtractScheme(const char* url,
bool ExtractScheme(const char16* url, int url_len, Component* scheme); int url_len,
Component* scheme);
URL_EXPORT bool ExtractScheme(const char16* url,
int url_len,
Component* scheme);
// Returns true if ch is a character that terminates the authority segment // Returns true if ch is a character that terminates the authority segment
// of a URL. // of a URL.
bool IsAuthorityTerminator(char16 ch); URL_EXPORT bool IsAuthorityTerminator(char16 ch);
// Does a best effort parse of input |spec|, in range |auth|. If a particular // Does a best effort parse of input |spec|, in range |auth|. If a particular
// component is not found, it will be set to invalid. // component is not found, it will be set to invalid.
void ParseAuthority(const char* spec, URL_EXPORT void ParseAuthority(const char* spec,
const Component& auth, const Component& auth,
Component* username, Component* username,
Component* password, Component* password,
Component* hostname, Component* hostname,
Component* port_num); Component* port_num);
void ParseAuthority(const char16* spec, URL_EXPORT void ParseAuthority(const char16* spec,
const Component& auth, const Component& auth,
Component* username, Component* username,
Component* password, Component* password,
Component* hostname, Component* hostname,
Component* port_num); Component* port_num);
// Computes the integer port value from the given port component. The port // Computes the integer port value from the given port component. The port
// component should have been identified by one of the init functions on // component should have been identified by one of the init functions on
@@ -298,8 +306,8 @@ void ParseAuthority(const char16* spec,
// The return value will be a positive integer between 0 and 64K, or one of // The return value will be a positive integer between 0 and 64K, or one of
// the two special values below. // the two special values below.
enum SpecialPort { PORT_UNSPECIFIED = -1, PORT_INVALID = -2 }; enum SpecialPort { PORT_UNSPECIFIED = -1, PORT_INVALID = -2 };
int ParsePort(const char* url, const Component& port); URL_EXPORT int ParsePort(const char* url, const Component& port);
int ParsePort(const char16* url, const Component& port); URL_EXPORT int ParsePort(const char16* url, const Component& port);
// Extracts the range of the file name in the given url. The path must // Extracts the range of the file name in the given url. The path must
// already have been computed by the parse function, and the matching URL // already have been computed by the parse function, and the matching URL
@@ -311,12 +319,12 @@ int ParsePort(const char16* url, const Component& port);
// following the last slash. // following the last slash.
// //
// The 8-bit version requires UTF-8 encoding. // The 8-bit version requires UTF-8 encoding.
void ExtractFileName(const char* url, URL_EXPORT void ExtractFileName(const char* url,
const Component& path, const Component& path,
Component* file_name); Component* file_name);
void ExtractFileName(const char16* url, URL_EXPORT void ExtractFileName(const char16* url,
const Component& path, const Component& path,
Component* file_name); Component* file_name);
// Extract the first key/value from the range defined by |*query|. Updates // Extract the first key/value from the range defined by |*query|. Updates
// |*query| to start at the end of the extracted key/value pair. This is // |*query| to start at the end of the extracted key/value pair. This is
@@ -333,14 +341,14 @@ void ExtractFileName(const char16* url,
// //
// If no key/value are found |*key| and |*value| will be unchanged and it will // If no key/value are found |*key| and |*value| will be unchanged and it will
// return false. // return false.
bool ExtractQueryKeyValue(const char* url, URL_EXPORT bool ExtractQueryKeyValue(const char* url,
Component* query, Component* query,
Component* key, Component* key,
Component* value); Component* value);
bool ExtractQueryKeyValue(const char16* url, URL_EXPORT bool ExtractQueryKeyValue(const char16* url,
Component* query, Component* query,
Component* key, Component* key,
Component* value); Component* value);
} // namespace url_parse } // namespace url_parse

@@ -9,6 +9,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_export.h"
#include "url/url_parse.h" #include "url/url_parse.h"
namespace url_util { namespace url_util {
@@ -26,13 +27,13 @@ namespace url_util {
// "noop", unless Shutdown() was called in the mean time. This will also be a // "noop", unless Shutdown() was called in the mean time. This will also be a
// "noop" if other calls to the library have forced an initialization // "noop" if other calls to the library have forced an initialization
// beforehand. // beforehand.
void Initialize(); URL_EXPORT void Initialize();
// Cleanup is not required, except some strings may leak. For most user // Cleanup is not required, except some strings may leak. For most user
// applications, this is fine. If you're using it in a library that may get // applications, this is fine. If you're using it in a library that may get
// loaded and unloaded, you'll want to unload to properly clean up your // loaded and unloaded, you'll want to unload to properly clean up your
// library. // library.
void Shutdown(); URL_EXPORT void Shutdown();
// Schemes -------------------------------------------------------------------- // Schemes --------------------------------------------------------------------
@@ -40,7 +41,7 @@ void Shutdown();
// schemes. This function is not threadsafe and can not be called concurrently // schemes. This function is not threadsafe and can not be called concurrently
// with any other url_util function. It will assert if the list of standard // with any other url_util function. It will assert if the list of standard
// schemes has been locked (see LockStandardSchemes). // schemes has been locked (see LockStandardSchemes).
void AddStandardScheme(const char* new_scheme); URL_EXPORT void AddStandardScheme(const char* new_scheme);
// Sets a flag to prevent future calls to AddStandardScheme from succeeding. // Sets a flag to prevent future calls to AddStandardScheme from succeeding.
// //
@@ -54,7 +55,7 @@ void AddStandardScheme(const char* new_scheme);
// We could have had AddStandardScheme use a lock instead, but that would add // We could have had AddStandardScheme use a lock instead, but that would add
// some platform-specific dependencies we don't otherwise have now, and is // some platform-specific dependencies we don't otherwise have now, and is
// overkill considering the normal usage is so simple. // overkill considering the normal usage is so simple.
void LockStandardSchemes(); URL_EXPORT void LockStandardSchemes();
// Locates the scheme in the given string and places it into |found_scheme|, // Locates the scheme in the given string and places it into |found_scheme|,
// which may be NULL to indicate the caller does not care about the range. // which may be NULL to indicate the caller does not care about the range.
@@ -62,14 +63,14 @@ void LockStandardSchemes();
// Returns whether the given |compare| scheme matches the scheme found in the // Returns whether the given |compare| scheme matches the scheme found in the
// input (if any). The |compare| scheme must be a valid canonical scheme or // input (if any). The |compare| scheme must be a valid canonical scheme or
// the result of the comparison is undefined. // the result of the comparison is undefined.
bool FindAndCompareScheme(const char* str, URL_EXPORT bool FindAndCompareScheme(const char* str,
int str_len, int str_len,
const char* compare, const char* compare,
url_parse::Component* found_scheme); url_parse::Component* found_scheme);
bool FindAndCompareScheme(const char16* str, URL_EXPORT bool FindAndCompareScheme(const char16* str,
int str_len, int str_len,
const char* compare, const char* compare,
url_parse::Component* found_scheme); url_parse::Component* found_scheme);
inline bool FindAndCompareScheme(const std::string& str, inline bool FindAndCompareScheme(const std::string& str,
const char* compare, const char* compare,
url_parse::Component* found_scheme) { url_parse::Component* found_scheme) {
@@ -85,10 +86,10 @@ inline bool FindAndCompareScheme(const string16& str,
// Returns true if the given string represents a standard URL. This means that // Returns true if the given string represents a standard URL. This means that
// either the scheme is in the list of known standard schemes. // either the scheme is in the list of known standard schemes.
bool IsStandard(const char* spec, URL_EXPORT bool IsStandard(const char* spec,
const url_parse::Component& scheme); const url_parse::Component& scheme);
bool IsStandard(const char16* spec, URL_EXPORT bool IsStandard(const char16* spec,
const url_parse::Component& scheme); const url_parse::Component& scheme);
// TODO(brettw) remove this. This is a temporary compatibility hack to avoid // TODO(brettw) remove this. This is a temporary compatibility hack to avoid
// breaking the WebKit build when this version is synced via Chrome. // breaking the WebKit build when this version is synced via Chrome.
@@ -109,16 +110,16 @@ inline bool IsStandard(const char* spec, int spec_len,
// Returns true if a valid URL was produced, false if not. On failure, the // Returns true if a valid URL was produced, false if not. On failure, the
// output and parsed structures will still be filled and will be consistent, // output and parsed structures will still be filled and will be consistent,
// but they will not represent a loadable URL. // but they will not represent a loadable URL.
bool Canonicalize(const char* spec, URL_EXPORT bool Canonicalize(const char* spec,
int spec_len, int spec_len,
url_canon::CharsetConverter* charset_converter, url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output, url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed); url_parse::Parsed* output_parsed);
bool Canonicalize(const char16* spec, URL_EXPORT bool Canonicalize(const char16* spec,
int spec_len, int spec_len,
url_canon::CharsetConverter* charset_converter, url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output, url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed); url_parse::Parsed* output_parsed);
// Resolves a potentially relative URL relative to the given parsed base URL. // Resolves a potentially relative URL relative to the given parsed base URL.
// The base MUST be valid. The resulting canonical URL and parsed information // The base MUST be valid. The resulting canonical URL and parsed information
@@ -130,28 +131,28 @@ bool Canonicalize(const char16* spec,
// //
// Returns true if the output is valid, false if the input could not produce // Returns true if the output is valid, false if the input could not produce
// a valid URL. // a valid URL.
bool ResolveRelative(const char* base_spec, URL_EXPORT bool ResolveRelative(const char* base_spec,
int base_spec_len, int base_spec_len,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const char* relative, const char* relative,
int relative_length, int relative_length,
url_canon::CharsetConverter* charset_converter, url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output, url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed); url_parse::Parsed* output_parsed);
bool ResolveRelative(const char* base_spec, URL_EXPORT bool ResolveRelative(const char* base_spec,
int base_spec_len, int base_spec_len,
const url_parse::Parsed& base_parsed, const url_parse::Parsed& base_parsed,
const char16* relative, const char16* relative,
int relative_length, int relative_length,
url_canon::CharsetConverter* charset_converter, url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output, url_canon::CanonOutput* output,
url_parse::Parsed* output_parsed); url_parse::Parsed* output_parsed);
// Replaces components in the given VALID input url. The new canonical URL info // Replaces components in the given VALID input url. The new canonical URL info
// is written to output and out_parsed. // is written to output and out_parsed.
// //
// Returns true if the resulting URL is valid. // Returns true if the resulting URL is valid.
bool ReplaceComponents( URL_EXPORT bool ReplaceComponents(
const char* spec, const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
@@ -159,7 +160,7 @@ bool ReplaceComponents(
url_canon::CharsetConverter* charset_converter, url_canon::CharsetConverter* charset_converter,
url_canon::CanonOutput* output, url_canon::CanonOutput* output,
url_parse::Parsed* out_parsed); url_parse::Parsed* out_parsed);
bool ReplaceComponents( URL_EXPORT bool ReplaceComponents(
const char* spec, const char* spec,
int spec_len, int spec_len,
const url_parse::Parsed& parsed, const url_parse::Parsed& parsed,
@@ -176,25 +177,25 @@ bool ReplaceComponents(
// //
// The versions of this function that don't take a b_end assume that the b // The versions of this function that don't take a b_end assume that the b
// string is NULL terminated. // string is NULL terminated.
bool LowerCaseEqualsASCII(const char* a_begin, URL_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
const char* a_end, const char* a_end,
const char* b); const char* b);
bool LowerCaseEqualsASCII(const char* a_begin, URL_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
const char* a_end, const char* a_end,
const char* b_begin, const char* b_begin,
const char* b_end); const char* b_end);
bool LowerCaseEqualsASCII(const char16* a_begin, URL_EXPORT bool LowerCaseEqualsASCII(const char16* a_begin,
const char16* a_end, const char16* a_end,
const char* b); const char* b);
// Unescapes the given string using URL escaping rules. // Unescapes the given string using URL escaping rules.
void DecodeURLEscapeSequences(const char* input, int length, URL_EXPORT void DecodeURLEscapeSequences(const char* input, int length,
url_canon::CanonOutputW* output); url_canon::CanonOutputW* output);
// Escapes the given string as defined by the JS method encodeURIComponent. See // Escapes the given string as defined by the JS method encodeURIComponent. See
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent
void EncodeURIComponent(const char* input, int length, URL_EXPORT void EncodeURIComponent(const char* input, int length,
url_canon::CanonOutput* output); url_canon::CanonOutput* output);
} // namespace url_util } // namespace url_util