Home | History | Annotate | Download | only in loader
      1 /*
      2  * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
      3  * Copyright (C) 2012 Google Inc. All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *
      9  * 1.  Redistributions of source code must retain the above copyright
     10  *     notice, this list of conditions and the following disclaimer.
     11  * 2.  Redistributions in binary form must reproduce the above copyright
     12  *     notice, this list of conditions and the following disclaimer in the
     13  *     documentation and/or other materials provided with the distribution.
     14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     15  *     its contributors may be used to endorse or promote products derived
     16  *     from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #ifndef FrameLoaderClient_h
     31 #define FrameLoaderClient_h
     32 
     33 #include "core/dom/IconURL.h"
     34 #include "core/loader/FrameLoaderTypes.h"
     35 #include "core/loader/NavigationPolicy.h"
     36 #include "core/page/LayoutMilestones.h"
     37 #include "core/platform/network/ResourceLoadPriority.h"
     38 #include "wtf/Forward.h"
     39 #include "wtf/Vector.h"
     40 
     41 typedef class _jobject* jobject;
     42 
     43 namespace v8 {
     44 class Context;
     45 template<class T> class Handle;
     46 }
     47 
     48 namespace WebKit {
     49 class WebCookieJar;
     50 }
     51 
     52 namespace WebCore {
     53 
     54     class Color;
     55     class DOMWindowExtension;
     56     class DOMWrapperWorld;
     57     class DocumentLoader;
     58     class Element;
     59 class FetchRequest;
     60     class FormState;
     61     class Frame;
     62     class FrameLoader;
     63     class FrameNetworkingContext;
     64     class HistoryItem;
     65     class HTMLAppletElement;
     66     class HTMLFormElement;
     67     class HTMLFrameOwnerElement;
     68     class HTMLPlugInElement;
     69     class IntSize;
     70     class KURL;
     71     class MessageEvent;
     72     class Page;
     73     class PluginView;
     74     class ResourceError;
     75     class ResourceHandle;
     76     class ResourceRequest;
     77     class ResourceResponse;
     78     class RTCPeerConnectionHandler;
     79     class SecurityOrigin;
     80     class SharedBuffer;
     81     class SocketStreamHandle;
     82     class StringWithDirection;
     83     class SubstituteData;
     84     class Widget;
     85 
     86     class FrameLoaderClient {
     87     public:
     88         virtual ~FrameLoaderClient() { }
     89 
     90         virtual void frameLoaderDestroyed() = 0;
     91 
     92         virtual bool hasWebView() const = 0; // mainly for assertions
     93 
     94         virtual void detachedFromParent() = 0;
     95 
     96         virtual void dispatchWillRequestAfterPreconnect(ResourceRequest&) { }
     97         virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
     98         virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0;
     99         virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0;
    100         virtual void dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0;
    101 
    102         virtual void dispatchDidHandleOnloadEvents() = 0;
    103         virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
    104         virtual void dispatchDidNavigateWithinPage() { }
    105         virtual void dispatchWillClose() = 0;
    106         virtual void dispatchDidStartProvisionalLoad() = 0;
    107         virtual void dispatchDidReceiveTitle(const StringWithDirection&) = 0;
    108         virtual void dispatchDidChangeIcons(IconType) = 0;
    109         virtual void dispatchDidCommitLoad() = 0;
    110         virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0;
    111         virtual void dispatchDidFailLoad(const ResourceError&) = 0;
    112         virtual void dispatchDidFinishDocumentLoad() = 0;
    113         virtual void dispatchDidFinishLoad() = 0;
    114 
    115         virtual void dispatchDidLayout(LayoutMilestones) { }
    116 
    117         virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) = 0;
    118         virtual bool shouldAbortNavigationAfterUrlResolve(const KURL& base, const String& fragment, const KURL& result) = 0;
    119 
    120         virtual void dispatchWillRequestResource(FetchRequest*) { }
    121 
    122         virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) = 0;
    123         virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) = 0;
    124 
    125         // Maybe these should go into a ProgressTrackerClient some day
    126         virtual void postProgressStartedNotification() = 0;
    127         virtual void postProgressEstimateChangedNotification() = 0;
    128         virtual void postProgressFinishedNotification() = 0;
    129 
    130         virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& suggestedName = String()) = 0;
    131 
    132         virtual bool shouldGoToHistoryItem(HistoryItem*) const = 0;
    133         virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const = 0;
    134 
    135         // Another page has accessed the initial empty document of this frame.
    136         // It is no longer safe to display a provisional URL, since a URL spoof
    137         // is now possible.
    138         virtual void didAccessInitialDocument() { }
    139 
    140         // This frame has set its opener to null, disowning it for the lifetime of the frame.
    141         // See http://html.spec.whatwg.org/#dom-opener.
    142         // FIXME: JSC should allow disowning opener. - <https://bugs.webkit.org/show_bug.cgi?id=103913>.
    143         virtual void didDisownOpener() { }
    144 
    145         // This frame has displayed inactive content (such as an image) from an
    146         // insecure source.  Inactive content cannot spread to other frames.
    147         virtual void didDisplayInsecureContent() = 0;
    148 
    149         // The indicated security origin has run active content (such as a
    150         // script) from an insecure source.  Note that the insecure content can
    151         // spread to other frames in the same origin.
    152         virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0;
    153         virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0;
    154         virtual void didDispatchPingLoader(const KURL&) = 0;
    155 
    156         virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) = 0;
    157 
    158         virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0;
    159 
    160         virtual String userAgent(const KURL&) = 0;
    161 
    162         virtual String doNotTrackValue() = 0;
    163 
    164         virtual void transitionToCommittedForNewPage() = 0;
    165 
    166         virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
    167         virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
    168 
    169         virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;
    170 
    171         virtual ObjectContentType objectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages) = 0;
    172 
    173         virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0;
    174         virtual void documentElementAvailable() = 0;
    175 
    176         virtual void didExhaustMemoryAvailableForScript() { };
    177 
    178         virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) = 0;
    179         virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) = 0;
    180         virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) = 0;
    181 
    182         virtual void didChangeScrollOffset() { }
    183 
    184         virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
    185         virtual bool allowScriptFromSource(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
    186         virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
    187         virtual bool allowImage(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
    188         virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
    189         virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
    190 
    191         // This callback notifies the client that the frame was about to run
    192         // JavaScript but did not because allowScript returned false. We
    193         // have a separate callback here because there are a number of places
    194         // that need to know if JavaScript is enabled but are not necessarily
    195         // preparing to execute script.
    196         virtual void didNotAllowScript() { }
    197         // This callback is similar, but for plugins.
    198         virtual void didNotAllowPlugins() { }
    199 
    200         virtual WebKit::WebCookieJar* cookieJar() const = 0;
    201 
    202         // Returns true if the embedder intercepted the postMessage call
    203         virtual bool willCheckAndDispatchMessageEvent(SecurityOrigin* /*target*/, MessageEvent*) const { return false; }
    204 
    205         virtual void didChangeName(const String&) { }
    206 
    207         virtual void dispatchWillOpenSocketStream(SocketStreamHandle*) { }
    208 
    209         virtual void dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler*) { }
    210 
    211         virtual void didRequestAutocomplete(PassRefPtr<FormState>) = 0;
    212 
    213         virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; }
    214         // Informs the embedder that a WebGL canvas inside this frame received a lost context
    215         // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
    216         virtual void didLoseWebGLContext(int) { }
    217 
    218         // If an HTML document is being loaded, informs the embedder that the document will have its <body> attached soon.
    219         virtual void dispatchWillInsertBody() { }
    220 
    221         virtual void dispatchDidChangeResourcePriority(unsigned long /*identifier*/, ResourceLoadPriority) { }
    222     };
    223 
    224 } // namespace WebCore
    225 
    226 #endif // FrameLoaderClient_h
    227