Home | History | Annotate | Download | only in web
      1 /*
      2  * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
      3  * Copyright (C) 2011 Apple 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 are
      7  * met:
      8  *
      9  *     * Redistributions of source code must retain the above copyright
     10  * notice, this list of conditions and the following disclaimer.
     11  *     * Redistributions in binary form must reproduce the above
     12  * copyright notice, this list of conditions and the following disclaimer
     13  * in the documentation and/or other materials provided with the
     14  * distribution.
     15  *     * Neither the name of Google Inc. nor the names of its
     16  * contributors may be used to endorse or promote products derived from
     17  * this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef FrameLoaderClientImpl_h
     33 #define FrameLoaderClientImpl_h
     34 
     35 #include "core/loader/FrameLoaderClient.h"
     36 #include "weborigin/KURL.h"
     37 #include "wtf/PassOwnPtr.h"
     38 #include "wtf/RefPtr.h"
     39 
     40 namespace WebKit {
     41 
     42 class WebFrameImpl;
     43 class WebPluginContainerImpl;
     44 class WebPluginLoadObserver;
     45 
     46 class FrameLoaderClientImpl : public WebCore::FrameLoaderClient {
     47 public:
     48     FrameLoaderClientImpl(WebFrameImpl* webFrame);
     49     ~FrameLoaderClientImpl();
     50 
     51     WebFrameImpl* webFrame() const { return m_webFrame; }
     52 
     53     // WebCore::FrameLoaderClient ----------------------------------------------
     54 
     55     virtual void frameLoaderDestroyed();
     56 
     57     // Notifies the WebView delegate that the JS window object has been cleared,
     58     // giving it a chance to bind native objects to the window before script
     59     // parsing begins.
     60     virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
     61     virtual void documentElementAvailable();
     62 
     63     // Script in the page tried to allocate too much memory.
     64     virtual void didExhaustMemoryAvailableForScript();
     65 
     66     virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId);
     67     virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId);
     68 
     69     // Returns true if we should allow the given V8 extension to be added to
     70     // the script context at the currently loading page and given extension group.
     71     virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId);
     72 
     73     virtual bool hasWebView() const;
     74     virtual bool hasFrameView() const;
     75     virtual void detachedFromParent();
     76     virtual void dispatchWillRequestAfterPreconnect(WebCore::ResourceRequest&);
     77     virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
     78     virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
     79     virtual void dispatchDidChangeResourcePriority(unsigned long identifier, WebCore::ResourceLoadPriority);
     80     virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
     81     virtual void dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
     82     virtual void dispatchDidHandleOnloadEvents();
     83     virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
     84     virtual void dispatchDidNavigateWithinPage();
     85     virtual void dispatchWillClose();
     86     virtual void dispatchDidStartProvisionalLoad();
     87     virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
     88     virtual void dispatchDidChangeIcons(WebCore::IconType);
     89     virtual void dispatchDidCommitLoad();
     90     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
     91     virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
     92     virtual void dispatchDidFinishDocumentLoad();
     93     virtual void dispatchDidFinishLoad();
     94     virtual void dispatchDidLayout(WebCore::LayoutMilestones);
     95     virtual WebCore::NavigationPolicy decidePolicyForNavigation(const WebCore::ResourceRequest&, WebCore::DocumentLoader*, WebCore::NavigationPolicy);
     96     virtual bool shouldAbortNavigationAfterUrlResolve(const WebCore::KURL&, const String&, const WebCore::KURL&);
     97     virtual void dispatchWillRequestResource(WebCore::FetchRequest*);
     98     virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>);
     99     virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>);
    100     virtual void postProgressStartedNotification();
    101     virtual void postProgressEstimateChangedNotification();
    102     virtual void postProgressFinishedNotification();
    103     virtual void loadURLExternally(const WebCore::ResourceRequest&, WebCore::NavigationPolicy, const String& suggestedName = String());
    104     virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
    105     virtual bool shouldStopLoadingForHistoryItem(WebCore::HistoryItem*) const;
    106     virtual void didAccessInitialDocument();
    107     virtual void didDisownOpener();
    108     virtual void didDisplayInsecureContent();
    109     virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL& insecureURL);
    110     virtual void didDetectXSS(const WebCore::KURL&, bool didBlockEntirePage);
    111     virtual void didDispatchPingLoader(const WebCore::KURL&);
    112     virtual WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&);
    113     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(
    114         const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
    115     virtual WTF::String userAgent(const WebCore::KURL&);
    116     virtual WTF::String doNotTrackValue();
    117     virtual void transitionToCommittedForNewPage();
    118     virtual PassRefPtr<WebCore::Frame> createFrame(
    119         const WebCore::KURL& url, const WTF::String& name,
    120         WebCore::HTMLFrameOwnerElement* ownerElement,
    121         const WTF::String& referrer, bool allowsScrolling,
    122         int marginWidth, int marginHeight);
    123     virtual PassRefPtr<WebCore::Widget> createPlugin(
    124         const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&,
    125         const Vector<WTF::String>&, const Vector<WTF::String>&,
    126         const WTF::String&, bool loadManually);
    127     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
    128         const WebCore::IntSize&,
    129         WebCore::HTMLAppletElement*,
    130         const WebCore::KURL& /* base_url */,
    131         const Vector<WTF::String>& paramNames,
    132         const Vector<WTF::String>& paramValues);
    133     virtual WebCore::ObjectContentType objectContentType(
    134         const WebCore::KURL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages);
    135     virtual void didChangeScrollOffset();
    136     virtual bool allowScript(bool enabledPerSettings);
    137     virtual bool allowScriptFromSource(bool enabledPerSettings, const WebCore::KURL& scriptURL);
    138     virtual bool allowPlugins(bool enabledPerSettings);
    139     virtual bool allowImage(bool enabledPerSettings, const WebCore::KURL& imageURL);
    140     virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&);
    141     virtual bool allowRunningInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&);
    142     virtual void didNotAllowScript();
    143     virtual void didNotAllowPlugins();
    144 
    145     virtual WebCookieJar* cookieJar() const;
    146     virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const;
    147     virtual void didChangeName(const String&);
    148 
    149     virtual void dispatchWillOpenSocketStream(WebCore::SocketStreamHandle*) OVERRIDE;
    150 
    151     virtual void dispatchWillStartUsingPeerConnectionHandler(WebCore::RTCPeerConnectionHandler*) OVERRIDE;
    152 
    153     virtual void didRequestAutocomplete(PassRefPtr<WebCore::FormState>) OVERRIDE;
    154 
    155     virtual bool allowWebGL(bool enabledPerSettings) OVERRIDE;
    156     virtual void didLoseWebGLContext(int arbRobustnessContextLostReason) OVERRIDE;
    157 
    158     virtual void dispatchWillInsertBody() OVERRIDE;
    159 
    160 private:
    161     PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver();
    162 
    163     // The WebFrame that owns this object and manages its lifetime. Therefore,
    164     // the web frame object is guaranteed to exist.
    165     WebFrameImpl* m_webFrame;
    166 };
    167 
    168 } // namespace WebKit
    169 
    170 #endif
    171