2 * Copyright (C) 2010 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.
32 #include "WebSecurityOrigin.h"
35 #include "SecurityOrigin.h"
36 #include "WebString.h"
38 #include <wtf/PassRefPtr.h>
40 using namespace WebCore;
44 class WebSecurityOriginPrivate : public SecurityOrigin {
47 WebSecurityOrigin WebSecurityOrigin::createFromDatabaseIdentifier(const WebString& databaseIdentifier)
49 return WebSecurityOrigin(SecurityOrigin::createFromDatabaseIdentifier(databaseIdentifier));
52 WebSecurityOrigin WebSecurityOrigin::createFromString(const WebString& origin)
54 return WebSecurityOrigin(SecurityOrigin::createFromString(origin));
57 WebSecurityOrigin WebSecurityOrigin::create(const WebURL& url)
59 return WebSecurityOrigin(SecurityOrigin::create(url));
62 void WebSecurityOrigin::reset()
67 void WebSecurityOrigin::assign(const WebSecurityOrigin& other)
69 WebSecurityOriginPrivate* p = const_cast<WebSecurityOriginPrivate*>(other.m_private);
75 WebString WebSecurityOrigin::protocol() const
78 return m_private->protocol();
81 WebString WebSecurityOrigin::host() const
84 return m_private->host();
87 unsigned short WebSecurityOrigin::port() const
90 return m_private->port();
93 bool WebSecurityOrigin::isUnique() const
96 return m_private->isUnique();
99 bool WebSecurityOrigin::canAccess(const WebSecurityOrigin& other) const
102 ASSERT(other.m_private);
103 return m_private->canAccess(other.m_private);
106 bool WebSecurityOrigin::canRequest(const WebURL& url) const
109 return m_private->canRequest(url);
112 WebString WebSecurityOrigin::toString() const
115 return m_private->toString();
118 WebString WebSecurityOrigin::databaseIdentifier() const
121 return m_private->databaseIdentifier();
124 bool WebSecurityOrigin::canAccessPasswordManager() const
127 return m_private->canAccessPasswordManager();
130 WebSecurityOrigin::WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)
131 : m_private(static_cast<WebSecurityOriginPrivate*>(origin.leakRef()))
135 WebSecurityOrigin& WebSecurityOrigin::operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)
137 assign(static_cast<WebSecurityOriginPrivate*>(origin.leakRef()));
141 WebSecurityOrigin::operator WTF::PassRefPtr<WebCore::SecurityOrigin>() const
143 return PassRefPtr<SecurityOrigin>(const_cast<WebSecurityOriginPrivate*>(m_private));
146 SecurityOrigin* WebSecurityOrigin::get() const
151 void WebSecurityOrigin::assign(WebSecurityOriginPrivate* p)
153 // p is already ref'd for us by the caller
159 } // namespace WebKit