| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 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 | |
| 13 * distribution. | |
| 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. | |
| 17 * | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "WebSecurityOrigin.h" | |
| 33 | |
| 34 #include "SecurityOrigin.h" | |
| 35 #include "WebString.h" | |
| 36 #include <wtf/PassRefPtr.h> | |
| 37 | |
| 38 using namespace WebCore; | |
| 39 | |
| 40 namespace WebKit { | |
| 41 | |
| 42 class WebSecurityOriginPrivate : public SecurityOrigin { | |
| 43 }; | |
| 44 | |
| 45 void WebSecurityOrigin::reset() | |
| 46 { | |
| 47 assign(0); | |
| 48 } | |
| 49 | |
| 50 void WebSecurityOrigin::assign(const WebSecurityOrigin& other) | |
| 51 { | |
| 52 WebSecurityOriginPrivate* p = const_cast<WebSecurityOriginPrivate*>(other.m_private); | |
| 53 if (p) | |
| 54 p->ref(); | |
| 55 assign(p); | |
| 56 } | |
| 57 | |
| 58 WebString WebSecurityOrigin::protocol() const | |
| 59 { | |
| 60 ASSERT(m_private); | |
| 61 return m_private->protocol(); | |
| 62 } | |
| 63 | |
| 64 WebString WebSecurityOrigin::host() const | |
| 65 { | |
| 66 ASSERT(m_private); | |
| 67 return m_private->host(); | |
| 68 } | |
| 69 | |
| 70 unsigned short WebSecurityOrigin::port() const | |
| 71 { | |
| 72 ASSERT(m_private); | |
| 73 return m_private->port(); | |
| 74 } | |
| 75 | |
| 76 bool WebSecurityOrigin::isEmpty() const | |
| 77 { | |
| 78 ASSERT(m_private); | |
| 79 return m_private->isEmpty(); | |
| 80 } | |
| 81 | |
| 82 WebString WebSecurityOrigin::toString() const | |
| 83 { | |
| 84 // FIXME: We should not support calling this method when m_private is null. | |
| 85 if (m_private) | |
| 86 return m_private->toString(); | |
| 87 | |
| 88 return WebString::fromUTF8("null"); | |
| 89 } | |
| 90 | |
| 91 WebString WebSecurityOrigin::databaseIdentifier() | |
| 92 { | |
| 93 // FIXME: We should not support calling this method when m_private is null. | |
| 94 if (m_private) | |
| 95 return m_private->databaseIdentifier(); | |
| 96 | |
| 97 return WebString::fromUTF8("null"); | |
| 98 } | |
| 99 | |
| 100 WebSecurityOrigin::WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin) | |
| 101 : m_private(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef())) | |
| 102 { | |
| 103 } | |
| 104 | |
| 105 WebSecurityOrigin& WebSecurityOrigin::operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin) | |
| 106 { | |
| 107 assign(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef())); | |
| 108 return *this; | |
| 109 } | |
| 110 | |
| 111 WebSecurityOrigin::operator WTF::PassRefPtr<WebCore::SecurityOrigin>() const | |
| 112 { | |
| 113 return PassRefPtr<SecurityOrigin>(const_cast<WebSecurityOriginPrivate*>(m_private)); | |
| 114 } | |
| 115 | |
| 116 void WebSecurityOrigin::assign(WebSecurityOriginPrivate* p) | |
| 117 { | |
| 118 // p is already ref'd for us by the caller | |
| 119 if (m_private) | |
| 120 m_private->deref(); | |
| 121 m_private = p; | |
| 122 } | |
| 123 | |
| 124 } // namespace WebKit | |
| OLD | NEW |