/** @file PluginViewMOM.cpp
 *
 * Copyright (C) Espial Limited 2014 - Company confidential - All rights reserved.
 *
 */

#ifndef PLUGINVIEWMOM_H_
#define PLUGINVIEWMOM_H_

#include "Widget.h"

#if ENABLE(RMAI)

#include "MOMPlayer.h"

namespace WebCore
{

class PluginViewMOM : public Widget
{
public:
    static PassRefPtr<Widget> create(Frame* parentFrame, const IntSize& pluginSize, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
    {
        return adoptRef(new PluginViewMOM(parentFrame, pluginSize, element, url, paramNames, paramValues, mimeType, loadManually));
    }

    virtual ~PluginViewMOM();
    virtual void paint(GraphicsContext*, const IntRect&);
    void invalidateRect(const IntRect& r);
    void show();
    void hide();

    bool active() const { return m_active; }
    void setActive(bool active);

    MOMPlayer* player() const { return m_player.get(); }
    void setPlayer(PassRefPtr<MOMPlayer> player);

    bool master() const { return m_master; }
    String name() const { return m_name; }

protected:
    void deactivate() { m_active = false; invalidate(); }
    
private:
    PluginViewMOM(Frame* parentFrame, const IntSize& pluginSize, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);

    void updateMOMPlayer(bool force);

    virtual void frameRectsChanged();

    virtual void setFrameRect(const IntRect&);

private:
    Element* m_element;
    bool m_active;
    bool m_master;
    String m_name;
    mutable RefPtr<MOMPlayer> m_player;
    IntRect m_windowRect;
};

} //namespace WebEspial

#endif // ENABLE(RMAI)

#endif // PLUGINVIEWMOM_H_
