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

#ifndef MOMDRMAgent_h
#define MOMDRMAgent_h

#if ENABLE(RMAI)

#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/AtomicString.h>

#include "ActiveDOMObject.h"
#include "EventTarget.h"

#include "MOMStringCollection.h"

namespace WebCore {

class ScriptExecutionContext;

class MOMDRMAgent : public RefCounted<MOMDRMAgent>, public ActiveDOMObject, public EventTarget {
public:
    static PassRefPtr<MOMDRMAgent> create(ScriptExecutionContext* context);

    virtual ~MOMDRMAgent();

    MOMStringCollection* drmSystems() const;

    String sendDRMMessage( const String & msgType, const String & msg, const String & DRMSystemID );
    String getProperty( const String & propName, const String & DRMSystemID );

    // ActiveDOMObject interface
    bool hasPendingActivity() const /*OVERRIDE*/ { return const_cast<MOMDRMAgent*>(this)->hasEventListeners(); }
    void stop() /*OVERRIDE*/ {};
    virtual const char* activeDOMObjectName() const OVERRIDE { return "MOMDRMAgent"; }

    // EventTarget interface
    MOMDRMAgent* toMOMDRMAgent() { return this; }
    ScriptExecutionContext* scriptExecutionContext() const /*OVERRIDE*/ { return ActiveDOMObject::scriptExecutionContext(); }
    EventTargetData* eventTargetData() /*OVERRIDE*/ { return &m_eventTargetData; }
    EventTargetData* ensureEventTargetData() /*OVERRIDE*/ { return &m_eventTargetData; }
    void refEventTarget() /*OVERRIDE*/ { ref(); }
    void derefEventTarget() /*OVERRIDE*/ { deref(); }

    virtual EventTargetInterface eventTargetInterface() const;

    using RefCounted<MOMDRMAgent>::ref;
    using RefCounted<MOMDRMAgent>::deref;

protected:
    MOMDRMAgent(ScriptExecutionContext* context);

private:
    EventTargetData m_eventTargetData;
    mutable RefPtr<MOMStringCollection> m_drmSystems;
};

} // namespace WebCore

#endif // ENABLE(RMAI)

#endif // MOMDRMAgent_h
