summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/KURL.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/KURL.h')
-rw-r--r--WebCore/platform/KURL.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/WebCore/platform/KURL.h b/WebCore/platform/KURL.h
index 0809f7e..647330d 100644
--- a/WebCore/platform/KURL.h
+++ b/WebCore/platform/KURL.h
@@ -55,15 +55,18 @@ namespace WebCore {
class TextEncoding;
struct KURLHash;
+enum ParsedURLStringTag { ParsedURLString };
+
class KURL {
public:
// Generates a URL which contains a null string.
KURL() { invalidate(); }
- // The argument is an absolute URL string. The string is assumed to be
- // an already encoded (ASCII-only) valid absolute URL.
- explicit KURL(const char*);
- explicit KURL(const String&);
+ // The argument is an absolute URL string. The string is assumed to be output of KURL::string() called on a valid
+ // KURL object, or indiscernible from such.
+ // It is usually best to avoid repeatedly parsing a string, unless memory saving outweigh the possible slow-downs.
+ KURL(ParsedURLStringTag, const char*);
+ KURL(ParsedURLStringTag, const String&);
// Resolves the relative URL with the given base URL. If provided, the
// TextEncoding is used to encode non-ASCII characers. The base URL can be
@@ -75,6 +78,7 @@ public:
KURL(const KURL& base, const String& relative);
KURL(const KURL& base, const String& relative, const TextEncoding&);
+
#if USE(GOOGLEURL)
// For conversions for other structures that have already parsed and
// canonicalized the URL. The input must be exactly what KURL would have
@@ -101,6 +105,12 @@ public:
// non-hierarchical (like "javascript:") URLs will have no path.
bool hasPath() const;
+ // Returns true if you can set the host and port for the URL.
+ // Non-hierarchical URLs don't have a host and port.
+ bool canSetHostOrPort() const { return isHierarchical(); }
+
+ bool canSetPathname() const { return isHierarchical(); }
+
#if USE(GOOGLEURL)
const String& string() const { return m_url.string(); }
#else
@@ -110,6 +120,7 @@ public:
String protocol() const;
String host() const;
unsigned short port() const;
+ bool hasPort() const;
String user() const;
String pass() const;
String path() const;
@@ -132,7 +143,7 @@ public:
void setProtocol(const String&);
void setHost(const String&);
- // Setting the port to 0 will clear any port from the URL.
+ void removePort();
void setPort(unsigned short);
// Input is like "foo.com" or "foo.com:8000".
@@ -251,6 +262,10 @@ const KURL& blankURL();
bool protocolIs(const String& url, const char* protocol);
bool protocolIsJavaScript(const String& url);
+bool isValidProtocol(const String& protocol);
+
+bool isDefaultPortForProtocol(unsigned short port, const String& protocol);
+bool portAllowed(const KURL&); // Blacklist ports that should never be used for Web resources.
String mimeTypeFromDataURL(const String& url);
@@ -314,6 +329,11 @@ inline bool KURL::isValid() const
return m_isValid;
}
+inline bool KURL::hasPort() const
+{
+ return m_hostEnd < m_portEnd;
+}
+
inline bool KURL::protocolInHTTPFamily() const
{
return m_protocolInHTTPFamily;