/*
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef webkitwebpageprivate_h
#define webkitwebpageprivate_h

/*
 * This file knows the secrets of WebKitWebPage.
 * They are using WebCore which musn't be exposed to the outer world.
 */

#include <webkit/webkitdefines.h>
#include <webkit/webkitgwebframe.h>
#include <webkit/webkitwebpage.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebbackforwardlist.h>
#include <webkit/webkitsecurityorigin.h>

#include "Frame.h"
#include "MediaPlayer.h"
#include "Page.h"
#include <wtf/OwnPtr.h>
#include <wtf/gobject/GOwnPtr.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
#include <glib.h>

namespace WebCore {
    class GraphicsLayerClutter;
}

namespace WebKit {

    WebCore::Page*  core(WebKitWebPage*);
    WebKitWebPage* kit(WebCore::Page*);

}

extern "C" {
    typedef struct _WebKitWebView WebKitWebView;
    typedef struct _WebKitIWebView WebKitIWebView;

    #define WEBKIT_WEB_PAGE_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_PAGE, WebKitWebPagePrivate))
    typedef struct _WebKitWebPagePrivate WebKitWebPagePrivate;
    struct _WebKitWebPagePrivate {
        gboolean disposing;

#if USE(ACCELERATED_COMPOSITING)
        WebCore::GraphicsLayerClutter* rootLayer;
#endif

        WebCore::Page* corePage;
        GRefPtr<WebKitWebSettings> webSettings;
        GRefPtr<WebKitWebInspector> webInspector;

        GRefPtr<WebKitWebWindowFeatures> webWindowFeatures;

#if PLATFORM(GTK)
        WebKitWebView* webView;
#elif PLATFORM(CLUTTER)
        WebKitIWebView* view;
#endif

        CString encoding;
        CString customEncoding;

        CString iconURI;

        guint viewportWidth;
        guint viewportHeight;

        WebKitWebFrame* mainFrame;
        GRefPtr<WebKitWebBackForwardList> backForwardList;

        WebKitLoadStatus loadStatus;

        gboolean editable;

        gboolean useFixedLayout;
        guint fixedLayoutWidth;
        guint fixedLayoutHeight;

        // These are hosted here because the DataSource object is created too late in the frame loading
        // process.
        GRefPtr<WebKitWebResource> mainResource;
        CString mainResourceIdentifier;
        GRefPtr<GHashTable> subResources;
    };

    void webkit_web_page_request_exit_fullscreen_media (WebKitWebPage*);

    WEBKIT_API ClutterActor*
    webkit_web_page_get_root_layer_actor               (WebKitWebPage*);

    WEBKIT_API WebCore::GraphicsLayerClutter*
    webkit_web_page_get_root_layer                     (WebKitWebPage*);

    WEBKIT_API void
    webkit_web_page_set_root_layer                     (WebKitWebPage*,
                                                        WebCore::GraphicsLayerClutter*);

    WEBKIT_API void webkit_web_page_set_scroll_layers  (WebKitWebPage*,
                                                        gint x, gint y);


}

#endif
