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 "HistoryDelegate.h"
28cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
29cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "DumpRenderTree.h"
30cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "DumpRenderTreeWin.h"
31cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "LayoutTestController.h"
32cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include <string>
33cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include <WebKit/WebKit.h>
34cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
35cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockusing std::wstring;
36cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
37cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockstatic inline wstring wstringFromBSTR(BSTR str)
38cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
39cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return wstring(str, ::SysStringLen(str));
40cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
41cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
42cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHistoryDelegate::HistoryDelegate()
43cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    : m_refCount(1)
44cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
45cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
46cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
47cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHistoryDelegate::~HistoryDelegate()
48cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
49cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
50cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
51cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    // IUnknown
52cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::QueryInterface(REFIID riid, void** ppvObject)
53cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
54cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    *ppvObject = 0;
55cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (IsEqualGUID(riid, IID_IUnknown))
56cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        *ppvObject = static_cast<IWebHistoryDelegate*>(this);
57cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    else if (IsEqualGUID(riid, IID_IWebHistoryDelegate))
58cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        *ppvObject = static_cast<IWebHistoryDelegate*>(this);
59cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    else
60cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_NOINTERFACE;
61cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
62cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    AddRef();
63cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
64cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
65cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
66cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockULONG HistoryDelegate::AddRef(void)
67cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
68cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return ++m_refCount;
69cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
70cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
71cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockULONG HistoryDelegate::Release(void)
72cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
73cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    ULONG newRef = --m_refCount;
74cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!newRef)
75cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        delete(this);
76cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
77cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return newRef;
78cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
79cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
80cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block// IWebHistoryDelegate
81cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::didNavigateWithNavigationData(IWebView* webView, IWebNavigationData* navigationData, IWebFrame* webFrame)
82cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
83cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
84cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return S_OK;
85cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
86cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BSTR urlBSTR;
87cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->url(&urlBSTR)))
88cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
89cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring url;
90cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (urlBSTR)
91cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
92cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    SysFreeString(urlBSTR);
93cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
94cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BSTR titleBSTR;
95cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->title(&titleBSTR)))
96cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
97cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring title;
98cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (titleBSTR)
99cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        title = wstringFromBSTR(titleBSTR);
100cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    SysFreeString(titleBSTR);
101cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
102cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    COMPtr<IWebURLRequest> request;
103cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->originalRequest(&request)))
104cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
105cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
106cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BSTR httpMethodBSTR;
107cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(request->HTTPMethod(&httpMethodBSTR)))
108cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
109cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring httpMethod;
110cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (httpMethodBSTR)
111cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        httpMethod = wstringFromBSTR(httpMethodBSTR);
112cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    SysFreeString(httpMethodBSTR);
113cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
114cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    COMPtr<IWebURLResponse> response;
115cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->response(&response)))
116cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
117cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
118cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    COMPtr<IWebHTTPURLResponse> httpResponse;
119cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(response->QueryInterface(&httpResponse)))
120cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
121cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
122cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    int statusCode = 0;
123cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(httpResponse->statusCode(&statusCode)))
124cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
125cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
126cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BOOL hasSubstituteData;
127cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->hasSubstituteData(&hasSubstituteData)))
128cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
129cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
130cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BSTR clientRedirectSourceBSTR;
131cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR)))
132cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
133cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    bool hasClientRedirect = clientRedirectSourceBSTR && SysStringLen(clientRedirectSourceBSTR);
134cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring redirectSource;
135cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (clientRedirectSourceBSTR)
136cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        redirectSource = urlSuitableForTestResult(wstringFromBSTR(clientRedirectSourceBSTR));
137cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    SysFreeString(clientRedirectSourceBSTR);
138cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
139cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400);
140cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
141cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    printf("WebView navigated to url \"%S\" with title \"%S\" with HTTP equivalent method \"%S\".  The navigation was %s and was %s%S.\n",
142cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        url.c_str(),
143cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        title.c_str(),
144cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        httpMethod.c_str(),
145cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        wasFailure ? "a failure" : "successful",
146cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        hasClientRedirect ? "a client redirect from " : "not a client redirect",
147cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        redirectSource.c_str());
148cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
149cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
150cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
151cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
152cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::didPerformClientRedirectFromURL(IWebView*, BSTR sourceURL, BSTR destinationURL, IWebFrame*)
153cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
154cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
155cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return S_OK;
156cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
157cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring source;
158cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (sourceURL)
159cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        source = urlSuitableForTestResult(wstringFromBSTR(sourceURL));
160cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
161cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring destination;
162cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (destinationURL)
163cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
164cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
165cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    printf("WebView performed a client redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
166cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
167cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
168cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
169cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::didPerformServerRedirectFromURL(IWebView* webView, BSTR sourceURL, BSTR destinationURL, IWebFrame* webFrame)
170cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
171cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
172cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return S_OK;
173cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
174cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring source;
175cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (sourceURL)
176cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        source = urlSuitableForTestResult(wstringFromBSTR(sourceURL));
177cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
178cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring destination;
179cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (destinationURL)
180cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
181cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
182cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    printf("WebView performed a server redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
183cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
184cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
185cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
186cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::updateHistoryTitle(IWebView* webView, BSTR titleBSTR, BSTR urlBSTR)
187cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
188cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
189cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return S_OK;
190cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
191cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring url;
192cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (urlBSTR)
193cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
194cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
195cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring title;
196cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (titleBSTR)
197cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        title = wstringFromBSTR(titleBSTR);
198cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
199cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    printf("WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), title.c_str());
200cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
201cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
202cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
203cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve BlockHRESULT HistoryDelegate::populateVisitedLinksForWebView(IWebView* webView)
204cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
205cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
206cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return S_OK;
207cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
208cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    BSTR urlBSTR;
209cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (FAILED(webView->mainFrameURL(&urlBSTR)))
210cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        return E_FAIL;
211cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
212cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    wstring url;
213cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (urlBSTR)
214cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
215cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    SysFreeString(urlBSTR);
216cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
217cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    if (gLayoutTestController->dumpVisitedLinksCallback())
218cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block        printf("Asked to populate visited links for WebView \"%S\"\n", url.c_str());
219cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
220cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return S_OK;
221cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
222