2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "WebCString.h"
35 #include "WebString.h"
36 #include <url/third_party/mozilla/url_parse.h>
57 WebURL(const WebURL
& url
)
58 : m_string(url
.m_string
)
59 , m_parsed(url
.m_parsed
)
60 , m_isValid(url
.m_isValid
)
64 WebURL
& operator=(const WebURL
& url
)
66 m_string
= url
.m_string
;
67 m_parsed
= url
.m_parsed
;
68 m_isValid
= url
.m_isValid
;
72 // FIXME: Remove this API.
73 WebCString
spec() const
75 std::string spec
= m_string
.utf8();
76 return WebCString(spec
.data(), spec
.length());
79 const WebString
& string() const
84 const url::Parsed
& parsed() const
96 return m_string
.isEmpty();
101 return m_string
.isEmpty();
105 BLINK_PLATFORM_EXPORT
WebURL(const KURL
&);
106 BLINK_PLATFORM_EXPORT WebURL
& operator=(const KURL
&);
107 BLINK_PLATFORM_EXPORT
operator KURL() const;
109 WebURL(const GURL
& url
)
110 : m_string(WebString::fromUTF8(url
.possibly_invalid_spec()))
111 , m_parsed(url
.parsed_for_possibly_invalid_spec())
112 , m_isValid(url
.is_valid())
116 WebURL
& operator=(const GURL
& url
)
118 m_string
= WebString::fromUTF8(url
.possibly_invalid_spec());
119 m_parsed
= url
.parsed_for_possibly_invalid_spec();
120 m_isValid
= url
.is_valid();
124 operator GURL() const
126 return isNull() ? GURL() : GURL(m_string
.utf8(), m_parsed
, m_isValid
);
132 url::Parsed m_parsed
;
136 inline bool operator==(const WebURL
& a
, const WebURL
& b
)
138 return a
.string().equals(b
.string());
141 inline bool operator!=(const WebURL
& a
, const WebURL
& b
)