[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

beidson at apple.com beidson at apple.com
Thu Oct 29 20:44:26 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit b3d1d6e9b34d9e53e6ee33017f1b3fd367584a51
Author: beidson at apple.com <beidson at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 14 16:03:31 2009 +0000

    WebKit Win API should provide a delegate interface for global history.
    https://bugs.webkit.org/show_bug.cgi?id=29905
    
    Reviewed by Sam Weinig.
    
    WebKit/win:
    
    -Add IWebHistoryDelegate for clients to implement.
    -Add (I)WebNavigationData for the history delegate's use.
    -When it exists, call the history delegate instead of using WebHistory.
    
    * Interfaces/IWebHistoryDelegate.idl: Added.
    * Interfaces/IWebHistoryPrivate.idl:
    * Interfaces/IWebNavigationData.idl: Added.
    * Interfaces/IWebViewPrivate.idl:
    * Interfaces/WebKit.idl:
    
    * WebKit.vcproj/Interfaces.vcproj:
    * WebKit.vcproj/WebKit.vcproj:
    
    * WebCoreSupport/WebChromeClient.cpp:
    (WebChromeClient::populateVisitedLinks):
    * WebCoreSupport/WebFrameLoaderClient.cpp:
    (WebFrameLoaderClient::updateGlobalHistory):
    (WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):
    (WebFrameLoaderClient::setTitle):
    
     * WebView.cpp:
    (WebView::close):
    (WebView::mainFrameURL):
    (WebView::setHistoryDelegate):
    (WebView::historyDelegate):
    (WebView::addVisitedLinks):
    * WebView.h:
    
    * WebHistory.cpp:
    (WebHistory::setVisitedLinkTrackingEnabled):
    (WebHistory::removeAllVisitedLinks):
    * WebHistory.h:
    
    * WebNavigationData.cpp: Added.
    (WebNavigationData::QueryInterface):
    (WebNavigationData::AddRef):
    (WebNavigationData::Release):
    (WebNavigationData::WebNavigationData):
    (WebNavigationData::~WebNavigationData):
    (WebNavigationData::createInstance):
    (WebNavigationData::url):
    (WebNavigationData::title):
    (WebNavigationData::originalRequest):
    (WebNavigationData::response):
    (WebNavigationData::hasSubstituteData):
    (WebNavigationData::clientRedirectSource):
    * WebNavigationData.h: Added.
    
    WebKitTools:
    
    * DumpRenderTree/LayoutTestController.cpp:
    (LayoutTestController::LayoutTestController):
    * DumpRenderTree/LayoutTestController.h:
    (LayoutTestController::dumpHistoryDelegateCallbacks):
    (LayoutTestController::setDumpHistoryDelegateCallbacks):
    
    * DumpRenderTree/win/DumpRenderTree.cpp:
    (shouldLogHistoryDelegates):
    (runTest):
    (createWebViewAndOffscreenWindow):
    (main):
    * DumpRenderTree/win/DumpRenderTree.vcproj:
    
    Add the IWebHistoryDelegate to DRT Windows:
    * DumpRenderTree/win/HistoryDelegate.cpp: Added.
    (wstringFromBSTR):
    (HistoryDelegate::HistoryDelegate):
    (HistoryDelegate::~HistoryDelegate):
    (HistoryDelegate::QueryInterface):
    (HistoryDelegate::AddRef):
    (HistoryDelegate::Release):
    (HistoryDelegate::didNavigateWithNavigationData):
    (HistoryDelegate::didPerformClientRedirectFromURL):
    (HistoryDelegate::didPerformServerRedirectFromURL):
    (HistoryDelegate::updateHistoryTitle):
    (HistoryDelegate::populateVisitedLinksForWebView):
    * DumpRenderTree/win/HistoryDelegate.h: Added.
    
    * DumpRenderTree/win/LayoutTestControllerWin.cpp:
    (LayoutTestController::removeAllVisitedLinks):
    
    LayoutTests:
    
    * platform/win/Skipped: Enable globalhistory tests.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49564 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6214044..4e41f31 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,6 +1,15 @@
-2009-10-02  Yong Li  <yong.li at torchmobile.com>
+2009-10-14  Brady Eidson  <beidson at apple.com>
 
-        Reviewed by NOBODY Adele Peterson.
+        Reviewed by Sam Weinig.
+
+        WebKit Win API should provide a delegate interface for global history.
+        https://bugs.webkit.org/show_bug.cgi?id=29905
+
+        * platform/win/Skipped: Enable globalhistory tests.
+
+2009-10-14  Yong Li  <yong.li at torchmobile.com>
+
+        Reviewed by Adele Peterson.
 
         Added a test case that loads an invalid image to make sure
         we don't crash in this situation.
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index d391eb1..cdfd8c2 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -680,9 +680,6 @@ http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception.html
 # This port doesn't support detecting slow unload handlers.
 fast/dom/Window/slow_unload_handler.html
 
-# This port doesn't have a global history delegate yet
-http/tests/globalhistory
-
 # <https://bugs.webkit.org/show_bug.cgi?id=29966>
 fast/inline/relative-positioned-overflow.html
 
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 38c2716..e6a6a0d 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,58 @@
+2009-10-14  Brady Eidson  <beidson at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKit Win API should provide a delegate interface for global history.
+        https://bugs.webkit.org/show_bug.cgi?id=29905
+
+        -Add IWebHistoryDelegate for clients to implement.
+        -Add (I)WebNavigationData for the history delegate's use.
+        -When it exists, call the history delegate instead of using WebHistory.
+        
+        * Interfaces/IWebHistoryDelegate.idl: Added.
+        * Interfaces/IWebHistoryPrivate.idl:
+        * Interfaces/IWebNavigationData.idl: Added.
+        * Interfaces/IWebViewPrivate.idl:
+        * Interfaces/WebKit.idl:
+        
+        * WebKit.vcproj/Interfaces.vcproj:
+        * WebKit.vcproj/WebKit.vcproj:
+
+        * WebCoreSupport/WebChromeClient.cpp:
+        (WebChromeClient::populateVisitedLinks):
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::updateGlobalHistory):
+        (WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):
+        (WebFrameLoaderClient::setTitle):
+ 
+         * WebView.cpp:
+        (WebView::close):
+        (WebView::mainFrameURL):
+        (WebView::setHistoryDelegate):
+        (WebView::historyDelegate):
+        (WebView::addVisitedLinks):
+        * WebView.h:
+        
+        * WebHistory.cpp:
+        (WebHistory::setVisitedLinkTrackingEnabled):
+        (WebHistory::removeAllVisitedLinks):
+        * WebHistory.h:
+
+        * WebNavigationData.cpp: Added.
+        (WebNavigationData::QueryInterface):
+        (WebNavigationData::AddRef):
+        (WebNavigationData::Release):
+        (WebNavigationData::WebNavigationData):
+        (WebNavigationData::~WebNavigationData):
+        (WebNavigationData::createInstance):
+        (WebNavigationData::url):
+        (WebNavigationData::title):
+        (WebNavigationData::originalRequest):
+        (WebNavigationData::response):
+        (WebNavigationData::hasSubstituteData):
+        (WebNavigationData::clientRedirectSource):
+        * WebNavigationData.h: Added.
+
 2009-10-13  Dave Hyatt  <hyatt at apple.com>
 
         Fix more WebView bustage.
diff --git a/WebKit/win/Interfaces/IWebHistoryDelegate.idl b/WebKit/win/Interfaces/IWebHistoryDelegate.idl
new file mode 100644
index 0000000..6233208
--- /dev/null
+++ b/WebKit/win/Interfaces/IWebHistoryDelegate.idl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DO_NO_IMPORTS
+import "oaidl.idl";
+import "ocidl.idl";
+import "IWebNavigationData.idl";
+#endif
+
+interface IWebFrame;
+interface IWebNavigationData;
+interface IWebView;
+
+[
+    object,
+    oleautomation,
+    uuid(16AF211F-7C00-4f7f-A8DB-B1219FEABF3B),
+    pointer_default(unique)
+]
+interface IWebHistoryDelegate : IUnknown
+{
+    HRESULT didNavigateWithNavigationData([in] IWebView* webView, [in] IWebNavigationData* navigationData, [in] IWebFrame* webFrame);
+    HRESULT didPerformClientRedirectFromURL([in] IWebView* webView, [in] BSTR sourceURL, [in] BSTR destinationURL, [in] IWebFrame* webFrame);
+    HRESULT didPerformServerRedirectFromURL([in] IWebView* webView, [in] BSTR sourceURL, [in] BSTR destinationURL, [in] IWebFrame* webFrame);
+    HRESULT updateHistoryTitle([in] IWebView* webView, [in] BSTR title, [in] BSTR url);
+    HRESULT populateVisitedLinksForWebView([in] IWebView* webView);
+}
diff --git a/WebKit/win/Interfaces/IWebHistoryPrivate.idl b/WebKit/win/Interfaces/IWebHistoryPrivate.idl
index 6ad08c9..af6c27a 100644
--- a/WebKit/win/Interfaces/IWebHistoryPrivate.idl
+++ b/WebKit/win/Interfaces/IWebHistoryPrivate.idl
@@ -36,4 +36,6 @@ interface IWebHistoryPrivate : IUnknown
 {
     HRESULT allItems([in, out] int* count, [out, retval] IWebHistoryItem** items);
     HRESULT data([out, retval] IStream**);
+    HRESULT setVisitedLinkTrackingEnabled([in] BOOL visitedLinkTrackingEnable);
+    HRESULT removeAllVisitedLinks();
 }
diff --git a/WebKit/win/Interfaces/IWebNavigationData.idl b/WebKit/win/Interfaces/IWebNavigationData.idl
new file mode 100644
index 0000000..cd39159
--- /dev/null
+++ b/WebKit/win/Interfaces/IWebNavigationData.idl
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DO_NO_IMPORTS
+import "oaidl.idl";
+import "ocidl.idl";
+import "IWebURLRequest.idl";
+import "IWebURLResponse.idl";
+#endif
+
+interface IWebURLRequest;
+interface IWebURLResponse;
+
+[
+    object,
+    oleautomation,
+    hidden,
+    uuid(1F162644-73D1-4de1-A20C-295FB68BF048),
+    pointer_default(unique)
+]
+interface IWebNavigationData : IUnknown
+{
+    HRESULT url([out, retval] BSTR*);
+    HRESULT title([out, retval] BSTR*);
+    HRESULT originalRequest([out, retval] IWebURLRequest**);
+    HRESULT response([out, retval] IWebURLResponse**);
+    HRESULT hasSubstituteData([out, retval] BOOL*);
+    HRESULT clientRedirectSource([out, retval] BSTR*);
+}
diff --git a/WebKit/win/Interfaces/IWebViewPrivate.idl b/WebKit/win/Interfaces/IWebViewPrivate.idl
index 003464a..52d97dc 100644
--- a/WebKit/win/Interfaces/IWebViewPrivate.idl
+++ b/WebKit/win/Interfaces/IWebViewPrivate.idl
@@ -28,6 +28,7 @@ import "oaidl.idl";
 import "ocidl.idl";
 import "IWebFormDelegate.idl";
 import "IWebFrameLoadDelegatePrivate.idl";
+import "IWebHistoryDelegate.idl";
 import "IWebInspector.idl";
 import "IWebInspectorPrivate.idl";
 #endif
@@ -38,6 +39,7 @@ cpp_quote("#define WebViewWillCloseNotification L\"WebViewWillCloseNotification\
 interface IEnumTextMatches;
 interface IWebFormDelegate;
 interface IWebFrameLoadDelegatePrivate;
+interface IWebHistoryDelegate;
 interface IWebInspector;
 interface IWebInspectorPrivate;
 interface IWebPluginHalterDelegate;
@@ -210,4 +212,8 @@ interface IWebViewPrivate : IUnknown
 
     // Removes all white list entries created with whiteListAccessFromOrigin.
     HRESULT resetOriginAccessWhiteLists();
+
+    HRESULT setHistoryDelegate([in] IWebHistoryDelegate* historyDelegate);
+    HRESULT historyDelegate([out,retval] IWebHistoryDelegate** historyDelegate);
+    HRESULT addVisitedLinks([in] BSTR* visitedURLs, [in] unsigned visitedURLCount);
 }
diff --git a/WebKit/win/Interfaces/WebKit.idl b/WebKit/win/Interfaces/WebKit.idl
index c9b33cc..1897601 100644
--- a/WebKit/win/Interfaces/WebKit.idl
+++ b/WebKit/win/Interfaces/WebKit.idl
@@ -90,6 +90,7 @@ import "ocidl.idl";
 #include "IWebHTMLRepresentation.idl"
 #include "IWebHTTPURLResponse.idl"
 #include "IWebHistory.idl"
+#include "IWebHistoryDelegate.idl"
 #include "IWebHistoryItem.idl"
 #include "IWebHistoryItemPrivate.idl"
 #include "IWebHistoryPrivate.idl"
@@ -100,6 +101,7 @@ import "ocidl.idl";
 #include "IWebJavaScriptCollector.idl"
 #include "IWebKitStatistics.idl"
 #include "IWebMutableURLRequestPrivate.idl"
+#include "IWebNavigationData.idl"
 #include "IWebNotification.idl"
 #include "IWebNotificationCenter.idl"
 #include "IWebNotificationObserver.idl"
diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
index 5d39452..0bae1ae 100644
--- a/WebKit/win/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
@@ -571,6 +571,13 @@ void WebChromeClient::reachedMaxAppCacheSize(int64_t spaceNeeded)
 
 void WebChromeClient::populateVisitedLinks()
 {
+    COMPtr<IWebHistoryDelegate> historyDelegate;
+    m_webView->historyDelegate(&historyDelegate);
+    if (historyDelegate) {
+        historyDelegate->populateVisitedLinksForWebView(m_webView);
+        return;
+    }
+
     WebHistory* history = WebHistory::sharedHistory();
     if (!history)
         return;
diff --git a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
index 1fd3b2b..2a3bf3c 100644
--- a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -43,6 +43,7 @@
 #include "WebHistory.h"
 #include "WebHistoryItem.h"
 #include "WebMutableURLRequest.h"
+#include "WebNavigationData.h"
 #include "WebNotificationCenter.h"
 #include "WebSecurityOrigin.h"
 #include "WebURLAuthenticationChallenge.h"
@@ -493,34 +494,70 @@ void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
 
 void WebFrameLoaderClient::updateGlobalHistory()
 {
+    DocumentLoader* loader = core(m_webFrame)->loader()->documentLoader();
+    WebView* webView = m_webFrame->webView();
+    COMPtr<IWebHistoryDelegate> historyDelegate;
+    webView->historyDelegate(&historyDelegate);
+
+    if (historyDelegate) {
+        BString url(loader->urlForHistory());
+        BString title(loader->title());
+        BString redirectSource(loader->clientRedirectSourceForHistory());
+        COMPtr<IWebURLResponse> urlResponse(AdoptCOM, WebURLResponse::createInstance(loader->response()));
+        COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(loader->originalRequestCopy()));
+        
+        COMPtr<IWebNavigationData> navigationData(AdoptCOM, WebNavigationData::createInstance(
+            url, title, urlRequest.get(), urlResponse.get(), loader->substituteData().isValid(), redirectSource));
+
+        historyDelegate->didNavigateWithNavigationData(webView, navigationData.get(), m_webFrame);
+        return;
+    }
+
     WebHistory* history = WebHistory::sharedHistory();
     if (!history)
         return;
 
-    DocumentLoader* loader = core(m_webFrame)->loader()->documentLoader();
     history->visitedURL(loader->urlForHistory(), loader->title(), loader->originalRequestCopy().httpMethod(), loader->urlForHistoryReflectsFailure(), !loader->clientRedirectSourceForHistory());
 }
 
 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
 {
+    WebView* webView = m_webFrame->webView();
+    COMPtr<IWebHistoryDelegate> historyDelegate;
+    webView->historyDelegate(&historyDelegate);
+
     WebHistory* history = WebHistory::sharedHistory();
-    if (!history)
-        return;
 
     DocumentLoader* loader = core(m_webFrame)->loader()->documentLoader();
     ASSERT(loader->unreachableURL().isEmpty());
 
     if (!loader->clientRedirectSourceForHistory().isNull()) {
-        if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->clientRedirectSourceForHistory())) {
-            COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
-            webHistoryItem->historyItem()->addRedirectURL(loader->clientRedirectDestinationForHistory());
+        if (historyDelegate) {
+            BString sourceURL(loader->clientRedirectSourceForHistory());
+            BString destURL(loader->clientRedirectDestinationForHistory());
+            historyDelegate->didPerformClientRedirectFromURL(webView, sourceURL, destURL, m_webFrame);
+        } else {
+            if (history) {
+                if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->clientRedirectSourceForHistory())) {
+                    COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
+                    webHistoryItem->historyItem()->addRedirectURL(loader->clientRedirectDestinationForHistory());
+                }
+            }
         }
     }
 
     if (!loader->serverRedirectSourceForHistory().isNull()) {
-        if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->serverRedirectSourceForHistory())) {
-            COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
-            webHistoryItem->historyItem()->addRedirectURL(loader->serverRedirectDestinationForHistory());
+        if (historyDelegate) {
+            BString sourceURL(loader->serverRedirectSourceForHistory());
+            BString destURL(loader->serverRedirectDestinationForHistory());
+            historyDelegate->didPerformServerRedirectFromURL(webView, sourceURL, destURL, m_webFrame);
+        } else {
+            if (history) {
+                if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->serverRedirectSourceForHistory())) {
+                    COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
+                    webHistoryItem->historyItem()->addRedirectURL(loader->serverRedirectDestinationForHistory());
+                }
+            }
         }
     }
 }
@@ -572,6 +609,16 @@ PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const Reso
 
 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
 {
+    WebView* webView = m_webFrame->webView();
+    COMPtr<IWebHistoryDelegate> historyDelegate;
+    webView->historyDelegate(&historyDelegate);
+    if (historyDelegate) {
+        BString titleBSTR(title);
+        BString urlBSTR(url.string());
+        historyDelegate->updateHistoryTitle(webView, titleBSTR, urlBSTR);
+        return;
+    }
+
     BOOL privateBrowsingEnabled = FALSE;
     COMPtr<IWebPreferences> preferences;
     if (SUCCEEDED(m_webFrame->webView()->preferences(&preferences)))
diff --git a/WebKit/win/WebHistory.cpp b/WebKit/win/WebHistory.cpp
index 854031a..deb75e5 100644
--- a/WebKit/win/WebHistory.cpp
+++ b/WebKit/win/WebHistory.cpp
@@ -577,6 +577,18 @@ HRESULT WebHistory::data(IStream** stream)
     return result.copyRefTo(stream);
 }
 
+HRESULT WebHistory::setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnabled)
+{
+    PageGroup::setShouldTrackVisitedLinks(visitedLinkTrackingEnabled);
+    return S_OK;
+}
+
+HRESULT WebHistory::removeAllVisitedLinks()
+{
+    PageGroup::removeAllVisitedLinks();
+    return S_OK;
+}
+
 HRESULT STDMETHODCALLTYPE WebHistory::setHistoryItemLimit( 
     /* [in] */ int limit)
 {
diff --git a/WebKit/win/WebHistory.h b/WebKit/win/WebHistory.h
index 96e1404..9d8acb3 100644
--- a/WebKit/win/WebHistory.h
+++ b/WebKit/win/WebHistory.h
@@ -116,6 +116,9 @@ public:
 
     virtual HRESULT STDMETHODCALLTYPE data(IStream**);
 
+    virtual HRESULT STDMETHODCALLTYPE setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnable);
+    virtual HRESULT STDMETHODCALLTYPE removeAllVisitedLinks();
+
     // WebHistory
     static WebHistory* sharedHistory();
     void visitedURL(const WebCore::KURL&, const WebCore::String& title, const WebCore::String& httpMethod, bool wasFailure, bool increaseVisitCount);
diff --git a/WebKit/win/WebKit.vcproj/Interfaces.vcproj b/WebKit/win/WebKit.vcproj/Interfaces.vcproj
index cbc8231..d6046a2 100644
--- a/WebKit/win/WebKit.vcproj/Interfaces.vcproj
+++ b/WebKit/win/WebKit.vcproj/Interfaces.vcproj
@@ -784,6 +784,18 @@
 			</FileConfiguration>
 		</File>
 		<File
+			RelativePath="..\Interfaces\IWebHistoryDelegate.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				ExcludedFromBuild="true"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
 			RelativePath="..\Interfaces\IWebHistoryItem.idl"
 			>
 			<FileConfiguration
@@ -1044,6 +1056,18 @@
 			</FileConfiguration>
 		</File>
 		<File
+			RelativePath="..\Interfaces\IWebNavigationData.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				ExcludedFromBuild="true"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
 			RelativePath="..\Interfaces\IWebNotification.idl"
 			>
 			<FileConfiguration
diff --git a/WebKit/win/WebKit.vcproj/WebKit.vcproj b/WebKit/win/WebKit.vcproj/WebKit.vcproj
index 021dc94..4a5ebac 100644
--- a/WebKit/win/WebKit.vcproj/WebKit.vcproj
+++ b/WebKit/win/WebKit.vcproj/WebKit.vcproj
@@ -679,6 +679,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\WebNavigationData.h"
+				>
+			</File>
+			<File
 				RelativePath="..\WebNodeHighlight.h"
 				>
 			</File>
@@ -995,6 +999,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\WebNavigationData.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\WebNotification.cpp"
 				>
 			</File>
diff --git a/WebKit/win/WebNavigationData.cpp b/WebKit/win/WebNavigationData.cpp
new file mode 100644
index 0000000..1ae3fe5
--- /dev/null
+++ b/WebKit/win/WebNavigationData.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "WebKitDLL.h"
+#include "WebNavigationData.h"
+
+#include <WebCore/BString.h>
+using WebCore::BString;
+
+// IUnknown -------------------------------------------------------------------
+
+HRESULT STDMETHODCALLTYPE WebNavigationData::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebNavigationData*>(this);
+    else if (IsEqualGUID(riid, IID_IWebNavigationData))
+        *ppvObject = static_cast<IWebNavigationData*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE WebNavigationData::AddRef(void)
+{
+    return ++m_refCount;
+}
+
+ULONG STDMETHODCALLTYPE WebNavigationData::Release(void)
+{
+    ULONG newRef = --m_refCount;
+    if (!newRef)
+        delete(this);
+
+    return newRef;
+}
+
+// WebNavigationData -------------------------------------------------------------------
+
+WebNavigationData::WebNavigationData(BSTR url, BSTR title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, BSTR clientRedirectSource)
+    : m_refCount(0)
+    , m_request(request)
+    , m_response(response)
+    , m_hasSubstituteData(hasSubstituteData)
+
+{
+    gClassCount++;
+    gClassNameCount.add("WebNavigationData");
+
+    m_url.adoptBSTR(url);
+    m_title.adoptBSTR(title);
+    m_clientRedirectSource.adoptBSTR(clientRedirectSource);
+}
+
+WebNavigationData::~WebNavigationData()
+{
+    gClassCount--;
+    gClassNameCount.remove("WebNavigationData");
+}
+
+WebNavigationData* WebNavigationData::createInstance(BSTR url, BSTR title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, BSTR clientRedirectSource)
+{
+    WebNavigationData* instance = new WebNavigationData(url, title, request, response, hasSubstituteData, clientRedirectSource);
+    instance->AddRef();
+    return instance;
+}
+
+// IWebNavigationData -------------------------------------------------------------------
+
+HRESULT WebNavigationData::url(BSTR* url)
+{
+    if (!url)
+        return E_POINTER;
+    *url = BString(m_url).release();
+    return S_OK;
+}
+
+HRESULT WebNavigationData::title(BSTR* title)
+{
+    if (!title)
+        return E_POINTER;
+    *title = BString(m_title).release();
+    return S_OK;
+}
+
+HRESULT WebNavigationData::originalRequest(IWebURLRequest** request)
+{
+    if (!request)
+        return E_POINTER;
+    *request = m_request.get();
+    m_request->AddRef();
+    return S_OK;
+}
+
+HRESULT WebNavigationData::response(IWebURLResponse** response)
+{
+    if (!response)
+        return E_POINTER;
+    *response = m_response.get();
+    m_response->AddRef();
+    return S_OK;
+}
+
+HRESULT WebNavigationData::hasSubstituteData(BOOL* hasSubstituteData)
+{
+    if (!hasSubstituteData)
+        return E_POINTER;
+    *hasSubstituteData = m_hasSubstituteData;
+    return S_OK;
+}
+
+HRESULT WebNavigationData::clientRedirectSource(BSTR* clientRedirectSource)
+{
+    if (!clientRedirectSource)
+        return E_POINTER;
+
+    *clientRedirectSource = BString(m_clientRedirectSource).release();
+    return S_OK;
+}
diff --git a/WebKit/win/WebNavigationData.h b/WebKit/win/WebNavigationData.h
new file mode 100644
index 0000000..0443fd7
--- /dev/null
+++ b/WebKit/win/WebNavigationData.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef WebNavigationData_h
+#define WebNavigationData_h
+
+#include "WebKit.h"
+
+#include "COMPtr.h"
+#include <WebCore/BString.h>
+
+class WebNavigationData : public IWebNavigationData {
+public:
+    static WebNavigationData* createInstance(BSTR, BSTR, IWebURLRequest*, IWebURLResponse*, bool, BSTR);
+private:
+    WebNavigationData(BSTR url, BSTR title, IWebURLRequest*, IWebURLResponse*, bool hasSubstituteData, BSTR clientRedirectSource);
+    ~WebNavigationData();
+
+public:
+    // IUnknown
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef(void);
+    virtual ULONG STDMETHODCALLTYPE Release(void);
+
+    // IWebNavigationData
+    virtual HRESULT STDMETHODCALLTYPE url(
+        /* [retval][out] */ BSTR*);
+
+    virtual HRESULT STDMETHODCALLTYPE title(
+        /* [retval][out] */ BSTR*);
+
+    virtual HRESULT STDMETHODCALLTYPE originalRequest(
+        /* [retval][out] */ IWebURLRequest**);
+
+    virtual HRESULT STDMETHODCALLTYPE response(
+        /* [retval][out] */ IWebURLResponse**);
+
+    virtual HRESULT STDMETHODCALLTYPE hasSubstituteData(
+        /* [retval][out] */ BOOL*);
+
+    virtual HRESULT STDMETHODCALLTYPE clientRedirectSource(
+        /* [retval][out] */ BSTR*);
+
+private:
+    ULONG m_refCount;
+    WebCore::BString m_url;
+    WebCore::BString m_title;
+    COMPtr<IWebURLRequest> m_request;
+    COMPtr<IWebURLResponse> m_response;
+    bool m_hasSubstituteData;
+    WebCore::BString m_clientRedirectSource;
+
+};
+
+#endif // WebNavigationData_h
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index 2a1210d..3798528 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -639,6 +639,7 @@ HRESULT STDMETHODCALLTYPE WebView::close()
     setEditingDelegate(0);
     setFrameLoadDelegate(0);
     setFrameLoadDelegatePrivate(0);
+    setHistoryDelegate(0);
     setPolicyDelegate(0);
     setResourceLoadDelegate(0);
     setUIDelegate(0);
@@ -3360,10 +3361,34 @@ HRESULT STDMETHODCALLTYPE WebView::setMainFrameURL(
 }
     
 HRESULT STDMETHODCALLTYPE WebView::mainFrameURL( 
-        /* [retval][out] */ BSTR* /*urlString*/)
+        /* [retval][out] */ BSTR* urlString)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    if (!urlString)
+        return E_POINTER;
+
+    if (!m_mainFrame)
+        return E_FAIL;
+
+    COMPtr<IWebDataSource> dataSource;
+
+    if (FAILED(m_mainFrame->provisionalDataSource(&dataSource))) {
+        if (FAILED(m_mainFrame->dataSource(&dataSource)))
+            return E_FAIL;
+    }
+
+    if (!dataSource) {
+        *urlString = 0;
+        return S_OK;
+    }
+    
+    COMPtr<IWebMutableURLRequest> request;
+    if (FAILED(dataSource->request(&request)) || !request)
+        return E_FAIL;
+
+    if (FAILED(request->URL(urlString)))
+        return E_FAIL;
+
+    return S_OK;
 }
     
 HRESULT STDMETHODCALLTYPE WebView::mainFrameDocument( 
@@ -5586,6 +5611,33 @@ HRESULT WebView::resetOriginAccessWhiteLists()
     SecurityOrigin::resetOriginAccessWhiteLists();
     return S_OK;
 }
+ 
+HRESULT WebView::setHistoryDelegate(IWebHistoryDelegate* historyDelegate)
+{
+    m_historyDelegate = historyDelegate;
+    return S_OK;
+}
+
+HRESULT WebView::historyDelegate(IWebHistoryDelegate** historyDelegate)
+{
+    if (!historyDelegate)
+        return E_POINTER;
+
+    return m_historyDelegate.copyRefTo(historyDelegate);
+}
+
+HRESULT WebView::addVisitedLinks(BSTR* visitedURLs, unsigned visitedURLCount)
+{
+    PageGroup& group = core(this)->group();
+    
+    for (unsigned i = 0; i < visitedURLCount; ++i) {
+        BSTR url = visitedURLs[i];
+        unsigned length = SysStringLen(url);
+        group.addVisitedLink(url, length);
+    }
+
+    return S_OK;
+}
 
 void WebView::downloadURL(const KURL& url)
 {
diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h
index 7670d2f..f4459fd 100644
--- a/WebKit/win/WebView.h
+++ b/WebKit/win/WebView.h
@@ -11,7 +11,7 @@
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * EXPRESS OR IMPLIED WARRANTIES, INCfLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
@@ -761,6 +761,11 @@ public:
     virtual HRESULT STDMETHODCALLTYPE whiteListAccessFromOrigin(BSTR sourceOrigin, BSTR destinationProtocol, BSTR destinationHost, BOOL allowDestinationSubdomains);
     virtual HRESULT STDMETHODCALLTYPE resetOriginAccessWhiteLists();
 
+
+    virtual HRESULT STDMETHODCALLTYPE setHistoryDelegate(IWebHistoryDelegate* historyDelegate);
+    virtual HRESULT STDMETHODCALLTYPE historyDelegate(IWebHistoryDelegate** historyDelegate);
+    virtual HRESULT STDMETHODCALLTYPE addVisitedLinks(BSTR* visitedURLs, unsigned visitedURLCount);
+
     // WebView
     bool shouldUseEmbeddedView(const WebCore::String& mimeType) const;
 
@@ -906,6 +911,7 @@ protected:
     COMPtr<IWebPolicyDelegate> m_policyDelegate;
     COMPtr<IWebResourceLoadDelegate> m_resourceLoadDelegate;
     COMPtr<IWebDownloadDelegate> m_downloadDelegate;
+    COMPtr<IWebHistoryDelegate> m_historyDelegate;
     COMPtr<WebPreferences> m_preferences;
     COMPtr<WebInspector> m_webInspector;
     COMPtr<IWebPluginHalterDelegate> m_pluginHalterDelegate;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e3db6c8..92fa959 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,41 @@
+2009-10-14  Brady Eidson  <beidson at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKit Win API should provide a delegate interface for global history.
+        https://bugs.webkit.org/show_bug.cgi?id=29905
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        * DumpRenderTree/LayoutTestController.h:
+        (LayoutTestController::dumpHistoryDelegateCallbacks):
+        (LayoutTestController::setDumpHistoryDelegateCallbacks):
+                
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (shouldLogHistoryDelegates):
+        (runTest):
+        (createWebViewAndOffscreenWindow):
+        (main):
+        * DumpRenderTree/win/DumpRenderTree.vcproj:
+        
+        Add the IWebHistoryDelegate to DRT Windows:
+        * DumpRenderTree/win/HistoryDelegate.cpp: Added.
+        (wstringFromBSTR):
+        (HistoryDelegate::HistoryDelegate):
+        (HistoryDelegate::~HistoryDelegate):
+        (HistoryDelegate::QueryInterface):
+        (HistoryDelegate::AddRef):
+        (HistoryDelegate::Release):
+        (HistoryDelegate::didNavigateWithNavigationData):
+        (HistoryDelegate::didPerformClientRedirectFromURL):
+        (HistoryDelegate::didPerformServerRedirectFromURL):
+        (HistoryDelegate::updateHistoryTitle):
+        (HistoryDelegate::populateVisitedLinksForWebView):
+        * DumpRenderTree/win/HistoryDelegate.h: Added.
+
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::removeAllVisitedLinks):
+
 2009-10-14  Shu Chang  <Chang.Shu at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index c2e4e64..4b8f43e 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -48,6 +48,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con
     , m_dumpDatabaseCallbacks(false)
     , m_dumpEditingCallbacks(false)
     , m_dumpFrameLoadCallbacks(false)
+    , m_dumpHistoryDelegateCallbacks(false)
     , m_dumpResourceLoadCallbacks(false)
     , m_dumpResourceResponseMIMETypes(false)
     , m_dumpSelectionRect(false)
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index f5f340f..e73215b 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -121,6 +121,9 @@ public:
     bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; }
     void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; }
 
+    bool dumpHistoryDelegateCallbacks() const { return m_dumpHistoryDelegateCallbacks; }
+    void setDumpHistoryDelegateCallbacks(bool dumpHistoryDelegateCallbacks) { m_dumpHistoryDelegateCallbacks = dumpHistoryDelegateCallbacks; }
+    
     bool dumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
     void setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks) { m_dumpResourceLoadCallbacks = dumpResourceLoadCallbacks; }
     
@@ -223,6 +226,7 @@ private:
     bool m_dumpDatabaseCallbacks;
     bool m_dumpEditingCallbacks;
     bool m_dumpFrameLoadCallbacks;
+    bool m_dumpHistoryDelegateCallbacks;
     bool m_dumpResourceLoadCallbacks;
     bool m_dumpResourceResponseMIMETypes;
     bool m_dumpSelectionRect;
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
index 1ad4f4f..f2b6220 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
@@ -31,6 +31,7 @@
 
 #include "EditingDelegate.h"
 #include "FrameLoadDelegate.h"
+#include "HistoryDelegate.h"
 #include "LayoutTestController.h"
 #include "PixelDumpSupport.h"
 #include "PolicyDelegate.h"
@@ -97,6 +98,7 @@ COMPtr<FrameLoadDelegate> sharedFrameLoadDelegate;
 COMPtr<UIDelegate> sharedUIDelegate;
 COMPtr<EditingDelegate> sharedEditingDelegate;
 COMPtr<ResourceLoadDelegate> sharedResourceLoadDelegate;
+COMPtr<HistoryDelegate> sharedHistoryDelegate;
 
 IWebFrame* frame;
 HWND webViewWindow;
@@ -681,6 +683,11 @@ static bool shouldLogFrameLoadDelegates(const char* pathOrURL)
     return strstr(pathOrURL, "/loading/") || strstr(pathOrURL, "\\loading\\");
 }
 
+static bool shouldLogHistoryDelegates(const char* pathOrURL)
+{
+    return strstr(pathOrURL, "/globalhistory/") || strstr(pathOrURL, "\\globalhistory\\");
+}
+
 static void resetDefaultsToConsistentValues(IWebPreferences* preferences)
 {
 #ifdef USE_MAC_FONTS
@@ -836,6 +843,17 @@ static void runTest(const string& testPathOrURL)
     if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))
         gLayoutTestController->setDumpFrameLoadCallbacks(true);
 
+    COMPtr<IWebView> webView;
+    if (SUCCEEDED(frame->webView(&webView))) {
+        COMPtr<IWebViewPrivate> viewPrivate;
+        if (SUCCEEDED(webView->QueryInterface(&viewPrivate))) {
+            if (shouldLogHistoryDelegates(pathOrURL.c_str())) {
+                gLayoutTestController->setDumpHistoryDelegateCallbacks(true);            
+                viewPrivate->setHistoryDelegate(sharedHistoryDelegate.get());
+            } else
+                viewPrivate->setHistoryDelegate(0);
+        }
+    }
     COMPtr<IWebHistory> history;
     if (SUCCEEDED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(history), reinterpret_cast<void**>(&history))))
         history->setOptionalSharedHistory(0);
@@ -843,8 +861,7 @@ static void runTest(const string& testPathOrURL)
     resetWebViewToConsistentStateBeforeTesting();
 
     prevTestBFItem = 0;
-    COMPtr<IWebView> webView;
-    if (SUCCEEDED(frame->webView(&webView))) {
+    if (webView) {
         COMPtr<IWebBackForwardList> bfList;
         if (SUCCEEDED(webView->backForwardList(&bfList)))
             bfList->currentItem(&prevTestBFItem);
@@ -1087,6 +1104,9 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow)
     if (FAILED(webView->setResourceLoadDelegate(sharedResourceLoadDelegate.get())))
         return 0;
 
+    if (FAILED(viewPrivate->setHistoryDelegate(sharedHistoryDelegate.get())))
+        return 0;
+
     openWindows().append(hostWindow);
     windowToWebViewMap().set(hostWindow, webView);
     return webView;
@@ -1153,6 +1173,7 @@ int main(int argc, char* argv[])
     sharedUIDelegate.adoptRef(new UIDelegate);
     sharedEditingDelegate.adoptRef(new EditingDelegate);
     sharedResourceLoadDelegate.adoptRef(new ResourceLoadDelegate);
+    sharedHistoryDelegate.adoptRef(new HistoryDelegate);
 
     // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592>
     COMPtr<IWebPreferences> tmpPreferences;
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj
index dea2467..ced49ef 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj
@@ -456,6 +456,14 @@
 				>
 			</File>
 			<File
+				RelativePath=".\HistoryDelegate.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\HistoryDelegate.h"
+				>
+			</File>
+			<File
 				RelativePath=".\PolicyDelegate.cpp"
 				>
 			</File>
diff --git a/WebKitTools/DumpRenderTree/win/HistoryDelegate.cpp b/WebKitTools/DumpRenderTree/win/HistoryDelegate.cpp
new file mode 100644
index 0000000..8a41fac
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/win/HistoryDelegate.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "HistoryDelegate.h"
+
+#include "DumpRenderTree.h"
+#include "DumpRenderTreeWin.h"
+#include "LayoutTestController.h"
+#include <string>
+#include <WebKit/WebKit.h>
+
+using std::wstring;
+
+static inline wstring wstringFromBSTR(BSTR str)
+{
+    return wstring(str, ::SysStringLen(str));
+}
+
+HistoryDelegate::HistoryDelegate()
+    : m_refCount(1)
+{
+}
+
+HistoryDelegate::~HistoryDelegate()
+{
+}
+
+    // IUnknown
+HRESULT HistoryDelegate::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebHistoryDelegate*>(this);
+    else if (IsEqualGUID(riid, IID_IWebHistoryDelegate))
+        *ppvObject = static_cast<IWebHistoryDelegate*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG HistoryDelegate::AddRef(void)
+{
+    return ++m_refCount;
+}
+
+ULONG HistoryDelegate::Release(void)
+{
+    ULONG newRef = --m_refCount;
+    if (!newRef)
+        delete(this);
+
+    return newRef;
+}
+
+// IWebHistoryDelegate
+HRESULT HistoryDelegate::didNavigateWithNavigationData(IWebView* webView, IWebNavigationData* navigationData, IWebFrame* webFrame)
+{
+    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
+        return S_OK;
+
+    BSTR urlBSTR;
+    if (FAILED(navigationData->url(&urlBSTR)))
+        return E_FAIL;
+    wstring url;
+    if (urlBSTR)
+        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
+    SysFreeString(urlBSTR);
+
+    BSTR titleBSTR;
+    if (FAILED(navigationData->title(&titleBSTR)))
+        return E_FAIL;
+    wstring title;
+    if (titleBSTR)
+        title = wstringFromBSTR(titleBSTR);
+    SysFreeString(titleBSTR);
+
+    COMPtr<IWebURLRequest> request;
+    if (FAILED(navigationData->originalRequest(&request)))
+        return E_FAIL;
+
+    BSTR httpMethodBSTR;
+    if (FAILED(request->HTTPMethod(&httpMethodBSTR)))
+        return E_FAIL;
+    wstring httpMethod;
+    if (httpMethodBSTR)
+        httpMethod = wstringFromBSTR(httpMethodBSTR);
+    SysFreeString(httpMethodBSTR);
+
+    COMPtr<IWebURLResponse> response;
+    if (FAILED(navigationData->response(&response)))
+        return E_FAIL;
+
+    COMPtr<IWebHTTPURLResponse> httpResponse;
+    if (FAILED(response->QueryInterface(&httpResponse)))
+        return E_FAIL;
+
+    int statusCode = 0;
+    if (FAILED(httpResponse->statusCode(&statusCode)))
+        return E_FAIL;
+
+    BOOL hasSubstituteData;
+    if (FAILED(navigationData->hasSubstituteData(&hasSubstituteData)))
+        return E_FAIL;
+
+    BSTR clientRedirectSourceBSTR;
+    if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR)))
+        return E_FAIL;
+    bool hasClientRedirect = clientRedirectSourceBSTR && SysStringLen(clientRedirectSourceBSTR);
+    wstring redirectSource;
+    if (clientRedirectSourceBSTR)
+        redirectSource = urlSuitableForTestResult(wstringFromBSTR(clientRedirectSourceBSTR));
+    SysFreeString(clientRedirectSourceBSTR);
+
+    bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400);
+        
+    printf("WebView navigated to url \"%S\" with title \"%S\" with HTTP equivalent method \"%S\".  The navigation was %s and was %s%S.\n", 
+        url.c_str(), 
+        title.c_str(), 
+        httpMethod.c_str(),
+        wasFailure ? "a failure" : "successful", 
+        hasClientRedirect ? "a client redirect from " : "not a client redirect", 
+        redirectSource.c_str());
+
+    return S_OK;
+}
+
+HRESULT HistoryDelegate::didPerformClientRedirectFromURL(IWebView*, BSTR sourceURL, BSTR destinationURL, IWebFrame*)
+{
+    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
+        return S_OK;
+
+    wstring source;
+    if (sourceURL)
+        source = urlSuitableForTestResult(wstringFromBSTR(sourceURL));
+    
+    wstring destination;
+    if (destinationURL)
+        destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
+
+    printf("WebView performed a client redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
+    return S_OK;
+}
+    
+HRESULT HistoryDelegate::didPerformServerRedirectFromURL(IWebView* webView, BSTR sourceURL, BSTR destinationURL, IWebFrame* webFrame)
+{
+    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
+        return S_OK;
+
+    wstring source;
+    if (sourceURL)
+        source = urlSuitableForTestResult(wstringFromBSTR(sourceURL));
+    
+    wstring destination;
+    if (destinationURL)
+        destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
+
+    printf("WebView performed a server redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
+    return S_OK;
+}
+
+HRESULT HistoryDelegate::updateHistoryTitle(IWebView* webView, BSTR titleBSTR, BSTR urlBSTR)
+{
+    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
+        return S_OK;
+    
+    wstring url;
+    if (urlBSTR)
+        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
+
+    wstring title;
+    if (titleBSTR)
+        title = wstringFromBSTR(titleBSTR);
+
+    printf("WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), title.c_str());
+    return S_OK;
+}
+    
+HRESULT HistoryDelegate::populateVisitedLinksForWebView(IWebView* webView)
+{
+    if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
+        return S_OK;
+
+    BSTR urlBSTR;
+    if (FAILED(webView->mainFrameURL(&urlBSTR)))
+        return E_FAIL;
+
+    wstring url;
+    if (urlBSTR)
+        url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
+    SysFreeString(urlBSTR);
+
+    if (gLayoutTestController->dumpVisitedLinksCallback())
+        printf("Asked to populate visited links for WebView \"%S\"\n", url.c_str());
+
+    return S_OK;
+}
diff --git a/WebKitTools/DumpRenderTree/win/HistoryDelegate.h b/WebKitTools/DumpRenderTree/win/HistoryDelegate.h
new file mode 100644
index 0000000..41be670
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/win/HistoryDelegate.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef HistoryDelegate_h
+#define HistoryDelegate_h
+
+#include <WebKit/WebKit.h>
+#include <wtf/OwnPtr.h>
+
+class HistoryDelegate : public IWebHistoryDelegate {
+public:
+    HistoryDelegate();
+    virtual ~HistoryDelegate();
+
+    // IUnknown
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef(void);
+    virtual ULONG STDMETHODCALLTYPE Release(void);
+
+    // IWebHistoryDelegate
+    virtual HRESULT STDMETHODCALLTYPE didNavigateWithNavigationData(
+        /* [in] */ IWebView* webView, 
+        /* [in] */ IWebNavigationData* navigationData, 
+        /* [in] */ IWebFrame* webFrame);
+
+    virtual HRESULT STDMETHODCALLTYPE didPerformClientRedirectFromURL(
+        /* [in] */ IWebView* webView, 
+        /* [in] */ BSTR sourceURL, 
+        /* [in] */ BSTR destinationURL, 
+        /* [in] */ IWebFrame* webFrame);
+    
+    virtual HRESULT STDMETHODCALLTYPE didPerformServerRedirectFromURL(
+        /* [in] */ IWebView* webView, 
+        /* [in] */ BSTR sourceURL, 
+        /* [in] */ BSTR destinationURL, 
+        /* [in] */ IWebFrame* webFrame);
+    
+    virtual HRESULT STDMETHODCALLTYPE updateHistoryTitle(
+        /* [in] */ IWebView* webView, 
+        /* [in] */ BSTR title, 
+        /* [in] */ BSTR url);
+    
+    virtual HRESULT STDMETHODCALLTYPE populateVisitedLinksForWebView(
+        /* [in] */ IWebView* webView);
+
+private:
+    ULONG m_refCount;
+};
+
+#endif // HistoryDelegate_h
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index a230fb0..c15dd49 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -927,5 +927,17 @@ void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef scrip
 
 void LayoutTestController::removeAllVisitedLinks()
 {
-    // FIXME: Implement this.
+    COMPtr<IWebHistory> history;
+    if (FAILED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(history), reinterpret_cast<void**>(&history))))
+        return;
+
+    COMPtr<IWebHistory> sharedHistory;
+    if (FAILED(history->optionalSharedHistory(&sharedHistory)) || !sharedHistory)
+        return;
+
+    COMPtr<IWebHistoryPrivate> sharedHistoryPrivate;
+    if (FAILED(sharedHistory->QueryInterface(&sharedHistoryPrivate)))
+        return;
+
+    sharedHistoryPrivate->removeAllVisitedLinks();
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list