1cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block/*
2cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * Copyright (C) 2009 Apple Inc.  All rights reserved.
3cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block *
4cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * Redistribution and use in source and binary forms, with or without
5cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * modification, are permitted provided that the following conditions
6cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * are met:
7cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * 1. Redistributions of source code must retain the above copyright
8cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block *    notice, this list of conditions and the following disclaimer.
9cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * 2. Redistributions in binary form must reproduce the above copyright
10cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block *    notice, this list of conditions and the following disclaimer in the
11cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block *    documentation and/or other materials provided with the distribution.
12cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block *
13cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block */
25cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
26cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "config.h"
27cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "WebKitDLL.h"
28cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "WebNavigationData.h"
29cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
30643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockusing namespace WebCore;
31cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
32cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block// IUnknown -------------------------------------------------------------------
33cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
34cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT STDMETHODCALLTYPE WebNavigationData::QueryInterface(REFIID riid, void** ppvObject)
35cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
36cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *ppvObject = 0;
37cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (IsEqualGUID(riid, IID_IUnknown))
38cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        *ppvObject = static_cast<IWebNavigationData*>(this);
39cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    else if (IsEqualGUID(riid, IID_IWebNavigationData))
40cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        *ppvObject = static_cast<IWebNavigationData*>(this);
41cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    else
42cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_NOINTERFACE;
43cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
44cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    AddRef();
45cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
46cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
47cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
48cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockULONG STDMETHODCALLTYPE WebNavigationData::AddRef(void)
49cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
50cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return ++m_refCount;
51cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
52cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
53cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockULONG STDMETHODCALLTYPE WebNavigationData::Release(void)
54cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
55cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    ULONG newRef = --m_refCount;
56cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!newRef)
57cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        delete(this);
58cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
59cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return newRef;
60cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
61cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
62cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block// WebNavigationData -------------------------------------------------------------------
63cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
64643ca7872b450ea4efacab6188849e5aac2ba161Steve BlockWebNavigationData::WebNavigationData(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource)
65cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    : m_refCount(0)
66643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    , m_url(url)
67643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    , m_title(title)
68cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    , m_request(request)
69cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    , m_response(response)
70cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    , m_hasSubstituteData(hasSubstituteData)
71643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    , m_clientRedirectSource(clientRedirectSource)
72cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
73cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
74cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    gClassCount++;
75cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    gClassNameCount.add("WebNavigationData");
76cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
77cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
78cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockWebNavigationData::~WebNavigationData()
79cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
80cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    gClassCount--;
81cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    gClassNameCount.remove("WebNavigationData");
82cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
83cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
84643ca7872b450ea4efacab6188849e5aac2ba161Steve BlockWebNavigationData* WebNavigationData::createInstance(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource)
85cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
86cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    WebNavigationData* instance = new WebNavigationData(url, title, request, response, hasSubstituteData, clientRedirectSource);
87cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    instance->AddRef();
88cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return instance;
89cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
90cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
91cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block// IWebNavigationData -------------------------------------------------------------------
92cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
93cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::url(BSTR* url)
94cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
95cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!url)
96cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
97cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *url = BString(m_url).release();
98cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
99cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
100cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
101cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::title(BSTR* title)
102cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
103cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!title)
104cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
105cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *title = BString(m_title).release();
106cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
107cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
108cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
109cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::originalRequest(IWebURLRequest** request)
110cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
111cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!request)
112cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
113cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *request = m_request.get();
114cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    m_request->AddRef();
115cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
116cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
117cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
118cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::response(IWebURLResponse** response)
119cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
120cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!response)
121cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
122cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *response = m_response.get();
123cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    m_response->AddRef();
124cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
125cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
126cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
127cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::hasSubstituteData(BOOL* hasSubstituteData)
128cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
129cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!hasSubstituteData)
130cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
131cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *hasSubstituteData = m_hasSubstituteData;
132cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
133cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
134cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
135cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT WebNavigationData::clientRedirectSource(BSTR* clientRedirectSource)
136cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
137cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!clientRedirectSource)
138cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_POINTER;
139cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
140cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *clientRedirectSource = BString(m_clientRedirectSource).release();
141cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
142cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
143