2 * Copyright (C) 2007 Apple 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
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "WebSecurityOrigin.h"
31 #include "WebKitDLL.h"
33 #include <WebCore/BString.h>
34 #include <WebCore/DatabaseTracker.h>
36 #if !ENABLE(SQL_DATABASE)
37 #include <wtf/UnusedParam.h>
40 using namespace WebCore;
42 // WebSecurityOrigin ---------------------------------------------------------------
43 WebSecurityOrigin* WebSecurityOrigin::createInstance(SecurityOrigin* securityOrigin)
45 WebSecurityOrigin* origin = new WebSecurityOrigin(securityOrigin);
50 WebSecurityOrigin::WebSecurityOrigin(SecurityOrigin* securityOrigin)
52 , m_securityOrigin(securityOrigin)
55 gClassNameCount.add("WebSecurityOrigin");
58 WebSecurityOrigin::~WebSecurityOrigin()
61 gClassNameCount.remove("WebSecurityOrigin");
64 // IUnknown ------------------------------------------------------------------------
65 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::QueryInterface(REFIID riid, void** ppvObject)
68 if (IsEqualGUID(riid, IID_IUnknown))
69 *ppvObject = static_cast<IWebSecurityOrigin*>(this);
70 else if (IsEqualGUID(riid, IID_IWebSecurityOrigin))
71 *ppvObject = static_cast<IWebSecurityOrigin*>(this);
72 else if (IsEqualGUID(riid, __uuidof(this)))
81 ULONG STDMETHODCALLTYPE WebSecurityOrigin::AddRef()
86 ULONG STDMETHODCALLTYPE WebSecurityOrigin::Release()
88 ULONG newRef = --m_refCount;
95 // IWebSecurityOrigin --------------------------------------------------------------
97 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::protocol(
98 /* [retval][out] */ BSTR* result)
103 *result = BString(m_securityOrigin->protocol()).release();
108 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::host(
109 /* [retval][out] */ BSTR* result)
114 *result = BString(m_securityOrigin->host()).release();
119 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::port(
120 /* [retval][out] */ unsigned short* result)
125 *result = m_securityOrigin->port();
130 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::usage(
131 /* [retval][out] */ unsigned long long* result)
133 #if ENABLE(SQL_DATABASE)
137 *result = DatabaseTracker::tracker().usageForOrigin(m_securityOrigin.get());
141 UNUSED_PARAM(result);
146 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::quota(
147 /* [retval][out] */ unsigned long long* result)
149 #if ENABLE(SQL_DATABASE)
153 *result = DatabaseTracker::tracker().quotaForOrigin(m_securityOrigin.get());
156 UNUSED_PARAM(result);
161 HRESULT STDMETHODCALLTYPE WebSecurityOrigin::setQuota(
162 /* [in] */ unsigned long long quota)
164 #if ENABLE(SQL_DATABASE)
165 DatabaseTracker::tracker().setQuota(m_securityOrigin.get(), quota);