/*
 * Copyright (C) 2006, 2007, 2008, 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 "IWebScriptObject.idl";
import "IWebView.idl";
import "IWebFrame.idl";
import "JavaScriptCoreAPITypes.idl";
#endif

interface IWebError;
interface IWebFrame;
interface IWebScriptObject;
interface IWebView;

/*!
    @category WebFrameLoadDelegate
    @discussion A WebView's WebFrameLoadDelegate tracks the loading progress of its frames.
    When a data source of a frame starts to load, the data source is considered "provisional".
    Once at least one byte is received, the data source is considered "committed". This is done
    so the contents of the frame will not be lost if the new data source fails to successfully load.
    @interface NSObject (WebFrameLoadDelegate)
*/

[
    object,
    oleautomation,
    uuid(3354665B-84BA-4fdf-B35E-BF5CF9D96026),
    pointer_default(unique)
]
interface IWebFrameLoadDelegate : IUnknown
{
    /*!
        @method webView:didStartProvisionalLoadForFrame:
        @abstract Notifies the delegate that the provisional load of a frame has started
        @param webView The WebView sending the message
        @param frame The frame for which the provisional load has started
        @discussion This method is called after the provisional data source of a frame
        has started to load.
        - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame;
    */
    HRESULT didStartProvisionalLoadForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:didReceiveServerRedirectForProvisionalLoadForFrame:
        @abstract Notifies the delegate that a server redirect occurred during the provisional load
        @param webView The WebView sending the message
        @param frame The frame for which the redirect occurred
        - (void)webView:(WebView *)sender didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame;
    */
    HRESULT didReceiveServerRedirectForProvisionalLoadForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:didFailProvisionalLoadWithError:forFrame:
        @abstract Notifies the delegate that the provisional load has failed
        @param webView The WebView sending the message
        @param error The error that occurred
        @param frame The frame for which the error occurred
        @discussion This method is called after the provisional data source has failed to load.
        The frame will continue to display the contents of the committed data source if there is one.
        - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
    */
    HRESULT didFailProvisionalLoadWithError([in] IWebView* webView, [in] IWebError* error, [in] IWebFrame* frame);

    /*!
        @method webView:didCommitLoadForFrame:
        @abstract Notifies the delegate that the load has changed from provisional to committed
        @param webView The WebView sending the message
        @param frame The frame for which the load has committed
        @discussion This method is called after the provisional data source has become the
        committed data source.

        In some cases, a single load may be committed more than once. This happens
        in the case of multipart/x-mixed-replace, also known as "server push". In this case,
        a single location change leads to multiple documents that are loaded in sequence. When
        this happens, a new commit will be sent for each document.
        - (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame;
    */
    HRESULT didCommitLoadForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:didReceiveTitle:forFrame:
        @abstract Notifies the delegate that the page title for a frame has been received
        @param webView The WebView sending the message
        @param title The new page title
        @param frame The frame for which the title has been received
        @discussion The title may update during loading; clients should be prepared for this.
        - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame;
    */
    HRESULT didReceiveTitle([in] IWebView* webView, [in] BSTR title, [in] IWebFrame* frame);

    /*!
        @method webView:didReceiveIcon:forFrame:
        @abstract Notifies the delegate that a page icon image for a frame has been received
        @param webView The WebView sending the message
        @param image The icon image. Also known as a "favicon".
        @param frame The frame for which a page icon has been received
        - (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame;
    */
    HRESULT didReceiveIcon([in] IWebView* webView, [in] OLE_HANDLE hBitmap, [in] IWebFrame* frame);

    /*!
        @method webView:didFinishLoadForFrame:
        @abstract Notifies the delegate that the committed load of a frame has completed
        @param webView The WebView sending the message
        @param frame The frame that finished loading
        @discussion This method is called after the committed data source of a frame has successfully loaded
        and will only be called when all subresources such as images and stylesheets are done loading.
        Plug-In content and JavaScript-requested loads may occur after this method is called.
        - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
    */
    HRESULT didFinishLoadForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:didFailLoadWithError:forFrame:
        @abstract Notifies the delegate that the committed load of a frame has failed
        @param webView The WebView sending the message
        @param error The error that occurred
        @param frame The frame that failed to load
        @discussion This method is called after a data source has committed but failed to completely load.
        - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
    */
    HRESULT didFailLoadWithError([in] IWebView* webView, [in] IWebError* error, [in] IWebFrame* forFrame);

    /*!
        @method webView:didChangeLocationWithinPageForFrame:
        @abstract Notifies the delegate that the scroll position in a frame has changed
        @param webView The WebView sending the message
        @param frame The frame that scrolled
        @discussion This method is called when anchors within a page have been clicked.
        - (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame;
    */
    HRESULT didChangeLocationWithinPageForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:
        @abstract Notifies the delegate that a frame will perform a client-side redirect
        @param webView The WebView sending the message
        @param URL The URL to be redirected to
        @param seconds Seconds in which the redirect will happen
        @param date The fire date
        @param frame The frame on which the redirect will occur
        @discussion This method can be used to continue progress feedback while a client-side
        redirect is pending.
        - (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame;
    */
    HRESULT willPerformClientRedirectToURL([in] IWebView* webView, [in] BSTR url, [in] double delaySeconds, [in] DATE fireDate, [in] IWebFrame* frame);

    /*!
        @method webView:didCancelClientRedirectForFrame:
        @abstract Notifies the delegate that a pending client-side redirect has been cancelled
        @param webView The WebView sending the message
        @param frame The frame for which the pending redirect was cancelled
        @discussion A client-side redirect can be cancelled if a frame changes location before the timeout.
        - (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame;
    */
    HRESULT didCancelClientRedirectForFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:willCloseFrame:
        @abstract Notifies the delegate that a frame will be closed
        @param webView The WebView sending the message
        @param frame The frame that will be closed
        @discussion This method is called right before WebKit is done with the frame
        and the objects that it contains.
        - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame;
    */
    HRESULT willCloseFrame([in] IWebView* webView, [in] IWebFrame* frame);

    /*!
        @method webView:windowScriptObjectAvailable:
        @abstract Notifies the delegate that the scripting object for a page is available.  This is called
        before the page is loaded.  It may be useful to allow delegates to bind native objects to the window.
        @param webView The webView sending the message.
        @param windowScriptObject The WebScriptObject for the window in the scripting environment.
        - (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject;
    */
    [local] HRESULT windowScriptObjectAvailable([in] IWebView* webView, [in] JSContextRef context, [in] JSObjectRef windowScriptObject);

    [local] HRESULT didClearWindowObject([in] IWebView* webView, [in] JSContextRef context, [in] JSObjectRef windowScriptObject, [in] IWebFrame* frame);
}
