/*
 * Copyright (C) 2006, 2007 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. 
 */

cpp_quote("/*")
cpp_quote(" * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.")
cpp_quote(" *")
cpp_quote(" * Redistribution and use in source and binary forms, with or without")
cpp_quote(" * modification, are permitted provided that the following conditions")
cpp_quote(" * are met:")
cpp_quote(" * 1. Redistributions of source code must retain the above copyright")
cpp_quote(" *    notice, this list of conditions and the following disclaimer.")
cpp_quote(" * 2. Redistributions in binary form must reproduce the above copyright")
cpp_quote(" *    notice, this list of conditions and the following disclaimer in the")
cpp_quote(" *    documentation and/or other materials provided with the distribution.")
cpp_quote(" *")
cpp_quote(" * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY")
cpp_quote(" * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE")
cpp_quote(" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR")
cpp_quote(" * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR")
cpp_quote(" * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")
cpp_quote(" * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,")
cpp_quote(" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR")
cpp_quote(" * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY")
cpp_quote(" * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT")
cpp_quote(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE")
cpp_quote(" * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ")
cpp_quote(" */")

import "oaidl.idl";
import "ocidl.idl";
import "IWebScriptObject.idl";
import "IWebView.idl";
import "IWebFrame.idl";

cpp_quote("// this is done to get midl to treat the JavaScriptCore API types as pointer types")
cpp_quote("#if 0")
typedef void* JSContextRef;
typedef void* JSObjectRef;
cpp_quote("#else")
cpp_quote("typedef struct OpaqueJSValue* JSObjectRef;")
cpp_quote("typedef const struct OpaqueJSContext* JSContextRef;")
cpp_quote("#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(4CD809C2-73A5-44ee-B0D7-D1863DFE9F57),
    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);
}
