1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef InjectedBundlePageLoaderClient_h
27#define InjectedBundlePageLoaderClient_h
28
29#include "APIClient.h"
30#include "APIString.h"
31#include "APIURL.h"
32#include "SameDocumentNavigationType.h"
33#include "WKBundlePage.h"
34#include <JavaScriptCore/JSBase.h>
35#include <WebCore/LayoutMilestones.h>
36#include <wtf/Forward.h>
37#include <wtf/Vector.h>
38
39namespace API {
40class Object;
41
42template<> struct ClientTraits<WKBundlePageLoaderClientBase> {
43    typedef std::tuple<WKBundlePageLoaderClientV0, WKBundlePageLoaderClientV1, WKBundlePageLoaderClientV2, WKBundlePageLoaderClientV3, WKBundlePageLoaderClientV4, WKBundlePageLoaderClientV5, WKBundlePageLoaderClientV6, WKBundlePageLoaderClientV7, WKBundlePageLoaderClientV8> Versions;
44};
45}
46
47namespace WebCore {
48class DOMWindowExtension;
49class DOMWrapperWorld;
50class URL;
51class ResourceError;
52class ResourceRequest;
53class ResourceResponse;
54class SharedBuffer;
55}
56
57namespace WebKit {
58
59class InjectedBundleBackForwardListItem;
60class WebPage;
61class WebFrame;
62
63class InjectedBundlePageLoaderClient : public API::Client<WKBundlePageLoaderClientBase> {
64public:
65    void willLoadURLRequest(WebPage*, const WebCore::ResourceRequest&, API::Object*);
66    void willLoadDataRequest(WebPage*, const WebCore::ResourceRequest&, WebCore::SharedBuffer*, const String&, const String&, const WebCore::URL&, API::Object*);
67
68    bool shouldGoToBackForwardListItem(WebPage*, InjectedBundleBackForwardListItem*, RefPtr<API::Object>& userData);
69    void didStartProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
70    void didReceiveServerRedirectForProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
71    void didFailProvisionalLoadWithErrorForFrame(WebPage*, WebFrame*, const WebCore::ResourceError&, RefPtr<API::Object>& userData);
72    void didCommitLoadForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
73    void didFinishDocumentLoadForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
74    void didFinishLoadForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
75    void didFinishProgress(WebPage*);
76    void didFailLoadWithErrorForFrame(WebPage*, WebFrame*, const WebCore::ResourceError&, RefPtr<API::Object>& userData);
77    void didSameDocumentNavigationForFrame(WebPage*, WebFrame*, SameDocumentNavigationType, RefPtr<API::Object>& userData);
78    void didReceiveTitleForFrame(WebPage*, const String&, WebFrame*, RefPtr<API::Object>& userData);
79    void didRemoveFrameFromHierarchy(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
80    void didDisplayInsecureContentForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
81    void didRunInsecureContentForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
82    void didDetectXSSForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
83
84    void didFirstLayoutForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
85    void didFirstVisuallyNonEmptyLayoutForFrame(WebPage*, WebFrame*, RefPtr<API::Object>& userData);
86    void didLayoutForFrame(WebPage*, WebFrame*);
87    void didLayout(WebPage*, WebCore::LayoutMilestones, RefPtr<API::Object>& userData);
88
89    void didClearWindowObjectForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld&);
90    void didCancelClientRedirectForFrame(WebPage*, WebFrame*);
91    void willPerformClientRedirectForFrame(WebPage*, WebFrame*, const String& url, double delay, double date);
92    void didHandleOnloadEventsForFrame(WebPage*, WebFrame*);
93
94    void globalObjectIsAvailableForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld&);
95    void willDisconnectDOMWindowExtensionFromGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
96    void didReconnectDOMWindowExtensionToGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
97    void willDestroyGlobalObjectForDOMWindowExtension(WebPage*, WebCore::DOMWindowExtension*);
98
99    bool shouldForceUniversalAccessFromLocalURL(WebPage*, const String& url);
100
101    void featuresUsedInPage(WebPage*, const Vector<String>&);
102
103    void willDestroyFrame(WebPage*, WebFrame*);
104    API::String* userAgentForURL(WebFrame*, API::URL*) const;
105};
106
107} // namespace WebKit
108
109#endif // InjectedBundlePageLoaderClient_h
110