Title: [164258] trunk/Source/WebKit2
Revision
164258
Author
ander...@apple.com
Date
2014-02-17 16:44:31 -0800 (Mon, 17 Feb 2014)

Log Message

Add history delegate to WKWebView
https://bugs.webkit.org/show_bug.cgi?id=128930

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
* UIProcess/API/Cocoa/WKProcessClass.mm:
(-[WKProcessClass initWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _historyDelegate]):
(-[WKWebView _setHistoryDelegate:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/HistoryClient.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
* UIProcess/Cocoa/HistoryClient.mm: Added.
(WebKit::HistoryClient::HistoryClient):
(WebKit::HistoryClient::~HistoryClient):
(WebKit::HistoryClient::didNavigateWithNavigationData):
(WebKit::HistoryClient::didPerformClientRedirect):
(WebKit::HistoryClient::didPerformServerRedirect):
(WebKit::HistoryClient::didUpdateHistoryTitle):
(WebKit::HistoryClient::populateVisitedLinks):
(WebKit::HistoryClient::shouldTrackVisitedLinks):
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::navigationStates):
(WebKit::NavigationState::NavigationState):
(WebKit::NavigationState::~NavigationState):
(WebKit::NavigationState::fromWebPage):
(WebKit::NavigationState::historyDelegate):
(WebKit::NavigationState::setHistoryDelegate):
(WebKit::NavigationState::didNavigateWithNavigationData):
(WebKit::NavigationState::didPerformClientRedirect):
(WebKit::NavigationState::didPerformServerRedirect):
(WebKit::NavigationState::didUpdateHistoryTitle):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (164257 => 164258)


--- trunk/Source/WebKit2/ChangeLog	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-18 00:44:31 UTC (rev 164258)
@@ -1,3 +1,41 @@
+2014-02-17  Anders Carlsson  <ander...@apple.com>
+
+        Add history delegate to WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=128930
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
+        * UIProcess/API/Cocoa/WKProcessClass.mm:
+        (-[WKProcessClass initWithConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _historyDelegate]):
+        (-[WKWebView _setHistoryDelegate:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/Cocoa/HistoryClient.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
+        * UIProcess/Cocoa/HistoryClient.mm: Added.
+        (WebKit::HistoryClient::HistoryClient):
+        (WebKit::HistoryClient::~HistoryClient):
+        (WebKit::HistoryClient::didNavigateWithNavigationData):
+        (WebKit::HistoryClient::didPerformClientRedirect):
+        (WebKit::HistoryClient::didPerformServerRedirect):
+        (WebKit::HistoryClient::didUpdateHistoryTitle):
+        (WebKit::HistoryClient::populateVisitedLinks):
+        (WebKit::HistoryClient::shouldTrackVisitedLinks):
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::navigationStates):
+        (WebKit::NavigationState::NavigationState):
+        (WebKit::NavigationState::~NavigationState):
+        (WebKit::NavigationState::fromWebPage):
+        (WebKit::NavigationState::historyDelegate):
+        (WebKit::NavigationState::setHistoryDelegate):
+        (WebKit::NavigationState::didNavigateWithNavigationData):
+        (WebKit::NavigationState::didPerformClientRedirect):
+        (WebKit::NavigationState::didPerformServerRedirect):
+        (WebKit::NavigationState::didUpdateHistoryTitle):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2014-02-17  Sam Weinig  <s...@webkit.org>
 
         [WebKit2] Merge WebProcessMac and WebProcessIOS into WebProcessCocoa

Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h (from rev 164257, trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h) (0 => 164258)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h	2014-02-18 00:44:31 UTC (rev 164258)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#import <WebKit2/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+#import <Foundation/Foundation.h>
+
+@class WKNavigationData;
+@class WKWebView;
+
+@protocol WKHistoryDelegatePrivate <NSObject>
+
+- (void)_webView:(WKWebView *)webView didNavigateWithNavigationData:(WKNavigationData *)navigationData;
+- (void)_webView:(WKWebView *)webView didPerformClientRedirectFromURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL;
+- (void)_webView:(WKWebView *)webView didPerformServerRedirectFromURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL;
+- (void)_webView:(WKWebView *)webView didUpdateHistoryTitle:(NSString *)title forURL:(NSURL *)URL;
+
+@end
+
+#endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessClass.mm (164257 => 164258)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessClass.mm	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessClass.mm	2014-02-18 00:44:31 UTC (rev 164258)
@@ -28,6 +28,7 @@
 
 #if WK_API_ENABLED
 
+#import "HistoryClient.h"
 #import "WKObject.h"
 #import "WKProcessClassConfigurationPrivate.h"
 #import "WebContext.h"
@@ -65,6 +66,7 @@
     }
 
     API::Object::constructInWrapper<WebKit::WebContext>(self, bundlePath);
+    _context->setHistoryClient(std::make_unique<WebKit::HistoryClient>());
 
     return self;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (164257 => 164258)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-02-18 00:44:31 UTC (rev 164258)
@@ -35,6 +35,7 @@
 #import "WKBackForwardListInternal.h"
 #import "WKBackForwardListItemInternal.h"
 #import "WKBrowsingContextHandleInternal.h"
+#import "WKHistoryDelegatePrivate.h"
 #import "WKNavigationDelegate.h"
 #import "WKNavigationInternal.h"
 #import "WKPreferencesInternal.h"
@@ -461,6 +462,16 @@
     return _observedRenderingProgressEvents;
 }
 
+- (id <WKHistoryDelegatePrivate>)_historyDelegate
+{
+    return [_navigationState->historyDelegate().leakRef() autorelease];
+}
+
+- (void)_setHistoryDelegate:(id <WKHistoryDelegatePrivate>)historyDelegate
+{
+    _navigationState->setHistoryDelegate(historyDelegate);
+}
+
 static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEvents events)
 {
     WebCore::LayoutMilestones milestones = 0;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (164257 => 164258)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-02-18 00:44:31 UTC (rev 164258)
@@ -34,6 +34,7 @@
 
 @class WKBrowsingContextHandle;
 @class WKRemoteObjectRegistry;
+@protocol WKHistoryDelegatePrivate;
 
 @interface WKWebView (WKPrivate)
 
@@ -42,6 +43,8 @@
 
 @property (nonatomic, setter=_setObservedRenderingProgressEvents:) _WKRenderingProgressEvents _observedRenderingProgressEvents;
 
+@property (nonatomic, weak, setter=_setHistoryDelegate:) id <WKHistoryDelegatePrivate> _historyDelegate;
+
 #if TARGET_OS_IPHONE
 @property (nonatomic, setter=_setMinimumLayoutSizeOverride:) CGSize _minimumLayoutSizeOverride;
 

Copied: trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.h (from rev 164257, trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h) (0 => 164258)


--- trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.h	2014-02-18 00:44:31 UTC (rev 164258)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 HistoryClient_h
+#define HistoryClient_h
+
+#import "WKFoundation.h"
+
+#if WK_API_ENABLED
+
+#import "APIHistoryClient.h"
+
+namespace WebKit {
+
+class HistoryClient : public API::HistoryClient {
+public:
+    HistoryClient();
+    ~HistoryClient();
+
+private:
+    // API::HistoryClient
+    virtual void didNavigateWithNavigationData(WebContext*, WebPageProxy*, const WebNavigationDataStore&, WebFrameProxy*) override;
+    virtual void didPerformClientRedirect(WebContext*, WebPageProxy*, const WTF::String& sourceURL, const WTF::String& destinationURL, WebFrameProxy*) override;
+    virtual void didPerformServerRedirect(WebContext*, WebPageProxy*, const WTF::String& sourceURL, const WTF::String& destinationURL, WebFrameProxy*) override;
+    virtual void didUpdateHistoryTitle(WebContext*, WebPageProxy*, const WTF::String& title, const WTF::String& url, WebFrameProxy*) override;
+    virtual void populateVisitedLinks(WebContext*) override;
+    virtual bool shouldTrackVisitedLinks() const override;
+};
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED
+
+#endif // HistoryClient_h

Added: trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.mm (0 => 164258)


--- trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/HistoryClient.mm	2014-02-18 00:44:31 UTC (rev 164258)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#import "config.h"
+#import "HistoryClient.h"
+
+#if WK_API_ENABLED
+
+#import "NavigationState.h"
+#import "WKHistoryDelegatePrivate.h"
+#import "WebFrameProxy.h"
+
+namespace WebKit {
+
+HistoryClient::HistoryClient()
+{
+}
+
+HistoryClient::~HistoryClient()
+{
+}
+
+void HistoryClient::didNavigateWithNavigationData(WebContext*, WebPageProxy* webPageProxy, const WebNavigationDataStore& navigationDataStore, WebFrameProxy* webFrameProxy)
+{
+    auto& navigationState = NavigationState::fromWebPage(*webPageProxy);
+
+    navigationState.didNavigateWithNavigationData(navigationDataStore);
+}
+
+void HistoryClient::didPerformClientRedirect(WebContext*, WebPageProxy* webPageProxy, const WTF::String& sourceURL, const WTF::String& destinationURL, WebFrameProxy* webFrameProxy)
+{
+    auto& navigationState = NavigationState::fromWebPage(*webPageProxy);
+
+    navigationState.didPerformClientRedirect(sourceURL, destinationURL);
+}
+
+void HistoryClient::didPerformServerRedirect(WebContext*, WebPageProxy* webPageProxy, const WTF::String& sourceURL, const WTF::String& destinationURL, WebFrameProxy* webFrameProxy)
+{
+    auto& navigationState = NavigationState::fromWebPage(*webPageProxy);
+
+    navigationState.didPerformServerRedirect(sourceURL, destinationURL);
+}
+
+void HistoryClient::didUpdateHistoryTitle(WebContext*, WebPageProxy* webPageProxy, const WTF::String& title, const WTF::String& url, WebFrameProxy* webFrameProxy)
+{
+    auto& navigationState = NavigationState::fromWebPage(*webPageProxy);
+
+    navigationState.didUpdateHistoryTitle(title, url);
+}
+
+void HistoryClient::populateVisitedLinks(WebContext*)
+{
+}
+
+bool HistoryClient::shouldTrackVisitedLinks() const
+{
+    return false;
+}
+
+} // namespace webKit
+
+#endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h (164257 => 164258)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-02-18 00:44:31 UTC (rev 164258)
@@ -39,23 +39,37 @@
 
 @class WKNavigation;
 @class WKWebView;
+@protocol WKHistoryDelegatePrivate;
 @protocol WKNavigationDelegate;
 
 namespace WebKit {
 
+struct WebNavigationDataStore;
+
 class NavigationState : private PageLoadState::Observer {
 public:
     explicit NavigationState(WKWebView *);
     ~NavigationState();
 
+    static NavigationState& fromWebPage(WebPageProxy&);
+
     std::unique_ptr<API::PolicyClient> createPolicyClient();
     std::unique_ptr<API::LoaderClient> createLoaderClient();
 
     RetainPtr<id <WKNavigationDelegate> > navigationDelegate();
     void setNavigationDelegate(id <WKNavigationDelegate>);
 
+    RetainPtr<id <WKHistoryDelegatePrivate> > historyDelegate();
+    void setHistoryDelegate(id <WKHistoryDelegatePrivate>);
+
     RetainPtr<WKNavigation> createLoadRequestNavigation(uint64_t navigationID, NSURLRequest *);
 
+    // Called by the history client.
+    void didNavigateWithNavigationData(const WebKit::WebNavigationDataStore&);
+    void didPerformClientRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL);
+    void didPerformServerRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL);
+    void didUpdateHistoryTitle(const WTF::String& title, const WTF::String& url);
+
 private:
     class PolicyClient : public API::PolicyClient {
     public:
@@ -125,6 +139,14 @@
     } m_navigationDelegateMethods;
 
     HashMap<uint64_t, RetainPtr<WKNavigation>> m_navigations;
+
+    WeakObjCPtr<id <WKHistoryDelegatePrivate> > m_historyDelegate;
+    struct {
+        bool webViewDidNavigateWithNavigationData : 1;
+        bool webViewDidPerformClientRedirectFromURLToURL : 1;
+        bool webViewDidPerformServerRedirectFromURLToURL : 1;
+        bool webViewDidUpdateHistoryTitleForURL : 1;
+    } m_historyDelegateMethods;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm (164257 => 164258)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-02-18 00:44:31 UTC (rev 164258)
@@ -28,37 +28,64 @@
 
 #if WK_API_ENABLED
 
+#import "APINavigationData.h"
+#import "APIURL.h"
+#import "APIString.h"
 #import "NavigationActionData.h"
 #import "PageLoadState.h"
 #import "WKBackForwardListInternal.h"
 #import "WKBackForwardListItemInternal.h"
 #import "WKFrameInfoInternal.h"
+#import "WKHistoryDelegatePrivate.h"
 #import "WKNSURLAuthenticationChallenge.h"
+#import "WKNSURLExtras.h"
 #import "WKNSURLProtectionSpace.h"
 #import "WKNavigationActionInternal.h"
+#import "WKNavigationDataInternal.h"
 #import "WKNavigationDelegatePrivate.h"
 #import "WKNavigationInternal.h"
 #import "WKNavigationResponseInternal.h"
 #import "WKWebViewInternal.h"
 #import "WebFrameProxy.h"
 #import "WebPageProxy.h"
+#import <wtf/NeverDestroyed.h>
 
 namespace WebKit {
 
+static HashMap<WebPageProxy*, NavigationState*>& navigationStates()
+{
+    static NeverDestroyed<HashMap<WebPageProxy*, NavigationState*>> navigationStates;
+
+    return navigationStates;
+}
+
 NavigationState::NavigationState(WKWebView *webView)
     : m_webView(webView)
     , m_navigationDelegateMethods()
+    , m_historyDelegateMethods()
 {
     ASSERT(m_webView->_page);
+    ASSERT(!navigationStates().contains(m_webView->_page.get()));
 
+    navigationStates().add(m_webView->_page.get(), this);
     m_webView->_page->pageLoadState().addObserver(*this);
 }
 
 NavigationState::~NavigationState()
 {
+    ASSERT(navigationStates().get(m_webView->_page.get()) == this);
+
+    navigationStates().remove(m_webView->_page.get());
     m_webView->_page->pageLoadState().removeObserver(*this);
 }
 
+NavigationState& NavigationState::fromWebPage(WebPageProxy& webPageProxy)
+{
+    ASSERT(navigationStates().contains(&webPageProxy));
+
+    return *navigationStates().get(&webPageProxy);
+}
+
 std::unique_ptr<API::LoaderClient> NavigationState::createLoaderClient()
 {
     return std::make_unique<LoaderClient>(*this);
@@ -94,6 +121,21 @@
     m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
 }
 
+RetainPtr<id <WKHistoryDelegatePrivate> > NavigationState::historyDelegate()
+{
+    return m_historyDelegate.get();
+}
+
+void NavigationState::setHistoryDelegate(id <WKHistoryDelegatePrivate> historyDelegate)
+{
+    m_historyDelegate = historyDelegate;
+
+    m_historyDelegateMethods.webViewDidNavigateWithNavigationData = [historyDelegate respondsToSelector:@selector(_webView:didNavigateWithNavigationData:)];
+    m_historyDelegateMethods.webViewDidPerformClientRedirectFromURLToURL = [historyDelegate respondsToSelector:@selector(_webView:didPerformClientRedirectFromURL:toURL:)];
+    m_historyDelegateMethods.webViewDidPerformServerRedirectFromURLToURL = [historyDelegate respondsToSelector:@selector(_webView:didPerformServerRedirectFromURL:toURL:)];
+    m_historyDelegateMethods.webViewDidUpdateHistoryTitleForURL = [historyDelegate respondsToSelector:@selector(_webView:didUpdateHistoryTitle:forURL:)];
+}
+
 RetainPtr<WKNavigation> NavigationState::createLoadRequestNavigation(uint64_t navigationID, NSURLRequest *request)
 {
     ASSERT(!m_navigations.contains(navigationID));
@@ -107,6 +149,54 @@
     return navigation;
 }
 
+void NavigationState::didNavigateWithNavigationData(const WebKit::WebNavigationDataStore& navigationDataStore)
+{
+    if (!m_historyDelegateMethods.webViewDidNavigateWithNavigationData)
+        return;
+
+    auto historyDelegate = m_historyDelegate.get();
+    if (!historyDelegate)
+        return;
+
+    [historyDelegate _webView:m_webView didNavigateWithNavigationData:wrapper(*API::NavigationData::create(navigationDataStore))];
+}
+
+void NavigationState::didPerformClientRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL)
+{
+    if (!m_historyDelegateMethods.webViewDidPerformClientRedirectFromURLToURL)
+        return;
+
+    auto historyDelegate = m_historyDelegate.get();
+    if (!historyDelegate)
+        return;
+
+    [historyDelegate _webView:m_webView didPerformClientRedirectFromURL:[NSURL _web_URLWithWTFString:sourceURL] toURL:[NSURL _web_URLWithWTFString:destinationURL]];
+}
+
+void NavigationState::didPerformServerRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL)
+{
+    if (!m_historyDelegateMethods.webViewDidPerformServerRedirectFromURLToURL)
+        return;
+
+    auto historyDelegate = m_historyDelegate.get();
+    if (!historyDelegate)
+        return;
+
+    [historyDelegate _webView:m_webView didPerformServerRedirectFromURL:[NSURL _web_URLWithWTFString:sourceURL] toURL:[NSURL _web_URLWithWTFString:destinationURL]];
+}
+
+void NavigationState::didUpdateHistoryTitle(const WTF::String& title, const WTF::String& url)
+{
+    if (!m_historyDelegateMethods.webViewDidUpdateHistoryTitleForURL)
+        return;
+
+    auto historyDelegate = m_historyDelegate.get();
+    if (!historyDelegate)
+        return;
+
+    [historyDelegate _webView:m_webView didUpdateHistoryTitle:title forURL:[NSURL _web_URLWithWTFString:url]];
+}
+
 NavigationState::PolicyClient::PolicyClient(NavigationState& navigationState)
     : m_navigationState(navigationState)
 {

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (164257 => 164258)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-18 00:30:50 UTC (rev 164257)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-18 00:44:31 UTC (rev 164258)
@@ -164,6 +164,9 @@
 		1A3EED0E161A535400AEB4F5 /* MessageReceiverMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3EED0C161A535300AEB4F5 /* MessageReceiverMap.cpp */; };
 		1A3EED0F161A535400AEB4F5 /* MessageReceiverMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3EED0D161A535300AEB4F5 /* MessageReceiverMap.h */; };
 		1A3EED12161A53D600AEB4F5 /* MessageReceiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3EED11161A53D600AEB4F5 /* MessageReceiver.h */; };
+		1A422F8B18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A422F8A18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1A422F8E18B29C6400D8CD96 /* HistoryClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */; };
+		1A422F8F18B29C6400D8CD96 /* HistoryClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A422F8D18B29C6400D8CD96 /* HistoryClient.h */; };
 		1A433F0D113C53DD00FACDE9 /* WebErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A433F0C113C53DD00FACDE9 /* WebErrors.h */; };
 		1A43E829188F3CDC009E4D30 /* WKProcessClassConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A43E827188F3CDC009E4D30 /* WKProcessClassConfiguration.mm */; };
 		1A43E82A188F3CDC009E4D30 /* WKProcessClassConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A43E828188F3CDC009E4D30 /* WKProcessClassConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1828,6 +1831,9 @@
 		1A3EED0C161A535300AEB4F5 /* MessageReceiverMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageReceiverMap.cpp; sourceTree = "<group>"; };
 		1A3EED0D161A535300AEB4F5 /* MessageReceiverMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageReceiverMap.h; sourceTree = "<group>"; };
 		1A3EED11161A53D600AEB4F5 /* MessageReceiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageReceiver.h; sourceTree = "<group>"; };
+		1A422F8A18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHistoryDelegatePrivate.h; sourceTree = "<group>"; };
+		1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HistoryClient.mm; sourceTree = "<group>"; };
+		1A422F8D18B29C6400D8CD96 /* HistoryClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryClient.h; sourceTree = "<group>"; };
 		1A433F0C113C53DD00FACDE9 /* WebErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebErrors.h; sourceTree = "<group>"; };
 		1A43E827188F3CDC009E4D30 /* WKProcessClassConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKProcessClassConfiguration.mm; sourceTree = "<group>"; };
 		1A43E828188F3CDC009E4D30 /* WKProcessClassConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKProcessClassConfiguration.h; sourceTree = "<group>"; };
@@ -4023,6 +4029,8 @@
 		1ABC3DF21899E415004F0626 /* Cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				1A422F8D18B29C6400D8CD96 /* HistoryClient.h */,
+				1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */,
 				1ABC3DF41899E437004F0626 /* NavigationState.h */,
 				1ABC3DF31899E437004F0626 /* NavigationState.mm */,
 			);
@@ -4357,6 +4365,7 @@
 				1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */,
 				1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
 				1A4D664D18A3031B00D82E21 /* WKFrameInfoInternal.h */,
+				1A422F8A18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h */,
 				1A5B1C4F1898606F004FCF9B /* WKNavigation.h */,
 				1A5B1C4E1898606F004FCF9B /* WKNavigation.mm */,
 				1A256E3618A1A788006FB922 /* WKNavigationAction.h */,
@@ -6289,6 +6298,7 @@
 				37DFA7001810BB92001F4A9F /* WKFoundation.h in Headers */,
 				1ABC3DF11899C6B6004F0626 /* WKNavigationInternal.h in Headers */,
 				1F604BA81889FA7400EE0395 /* WKRenderingProgressEvents.h in Headers */,
+				1A422F8F18B29C6400D8CD96 /* HistoryClient.h in Headers */,
 				BCBAACEB145225E30053F82F /* WKProcessGroup.h in Headers */,
 				377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */,
 				BC8699B5116AADAA002A925B /* WKView.h in Headers */,
@@ -6533,6 +6543,7 @@
 				1QQ417CB12C00CCA002BE67B /* TextCheckerCompletion.h in Headers */,
 				1A5E4DA412D3BD3D0099A2BB /* TextCheckerState.h in Headers */,
 				1AAF263914687C39004A1E8A /* TiledCoreAnimationDrawingArea.h in Headers */,
+				1A422F8B18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h in Headers */,
 				370F34A71829CFF3009027C8 /* WKBrowsingContextHistoryDelegate.h in Headers */,
 				1AF05D8714688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h in Headers */,
 				1A64245E12DE29A100CAAE2C /* UpdateInfo.h in Headers */,
@@ -8032,6 +8043,7 @@
 				CD73BA53131B645B00EEDED2 /* WebFullScreenManager.cpp in Sources */,
 				755422BD18062BB20046F6A8 /* WKOriginDataManager.cpp in Sources */,
 				CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */,
+				1A422F8E18B29C6400D8CD96 /* HistoryClient.mm in Sources */,
 				1FB00AC8185F76460019142E /* WKWebProcessPlugInPageGroup.mm in Sources */,
 				CD6F75F4131B66D000D6B21E /* WebFullScreenManagerProxy.cpp in Sources */,
 				CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to