#ifndef HTMLMediaElementEncryptedMedia_h
#define HTMLMediaElementEncryptedMedia_h
#include "core/events/EventTarget.h"
#include "heap/Handle.h"
#include "platform/Supplementable.h"
#include "platform/graphics/media/MediaPlayer.h"
#include "public/platform/WebMediaPlayerClient.h"
#include "wtf/Forward.h"
namespace WebCore {
class ExceptionState;
class HTMLMediaElement;
class MediaKeys;
class HTMLMediaElementEncryptedMedia : public Supplement<HTMLMediaElement> {
public:
static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionState&);
static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySystem, ExceptionState&);
static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&);
static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionState&);
static void webkitCancelKeyRequest(HTMLMediaElement&, const String& keySystem, const String& sessionId, ExceptionState&);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitneedkey);
static MediaKeys* mediaKeys(HTMLMediaElement&);
static void setMediaKeys(HTMLMediaElement&, MediaKeys*, ExceptionState&);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(needkey);
static void keyAdded(HTMLMediaElement&, const String& keySystem, const String& sessionId);
static void keyError(HTMLMediaElement&, const String& keySystem, const String& sessionId, blink::WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode);
static void keyMessage(HTMLMediaElement&, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const blink::WebURL& defaultURL);
static void keyNeeded(HTMLMediaElement&, const String& contentType, const unsigned char* initData, unsigned initDataLength);
static void playerDestroyed(HTMLMediaElement&);
static blink::WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement&);
virtual ~HTMLMediaElementEncryptedMedia();
static HTMLMediaElementEncryptedMedia& from(HTMLMediaElement&);
static const char* supplementName();
private:
HTMLMediaElementEncryptedMedia();
void generateKeyRequest(blink::WebMediaPlayer*, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionState&);
void addKey(blink::WebMediaPlayer*, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&);
void cancelKeyRequest(blink::WebMediaPlayer*, const String& keySystem, const String& sessionId, ExceptionState&);
bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
EventListener* getAttributeEventListener(const AtomicString& eventType);
enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed };
bool setEmeMode(EmeMode, ExceptionState&);
blink::WebContentDecryptionModule* contentDecryptionModule();
void setMediaKeysInternal(HTMLMediaElement&, MediaKeys*);
EmeMode m_emeMode;
RefPtrWillBePersistent<MediaKeys> m_mediaKeys;
};
}
#endif