1/*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef MediaControlsApple_h
28#define MediaControlsApple_h
29
30#if ENABLE(VIDEO)
31
32#include "MediaControls.h"
33
34namespace WebCore {
35
36class MediaControlsApple;
37
38class MediaControlsAppleEventListener : public EventListener {
39public:
40    static PassRefPtr<MediaControlsAppleEventListener> create(MediaControlsApple* mediaControls) { return adoptRef(new MediaControlsAppleEventListener(mediaControls)); }
41    static const MediaControlsAppleEventListener* cast(const EventListener* listener)
42    {
43        return listener->type() == MediaControlsAppleEventListenerType
44            ? static_cast<const MediaControlsAppleEventListener*>(listener)
45            : 0;
46    }
47
48    virtual bool operator==(const EventListener& other);
49
50private:
51    MediaControlsAppleEventListener(MediaControlsApple* mediaControls)
52        : EventListener(MediaControlsAppleEventListenerType)
53        , m_mediaControls(mediaControls)
54    {
55    }
56
57    virtual void handleEvent(ScriptExecutionContext*, Event*);
58
59    MediaControlsApple* m_mediaControls;
60};
61
62class MediaControlsApple : public MediaControls {
63public:
64    static PassRefPtr<MediaControlsApple> createControls(Document*);
65
66    // MediaControls implementation.
67    virtual void setMediaController(MediaControllerInterface*) OVERRIDE;
68
69    virtual void hide() OVERRIDE;
70    virtual void makeTransparent() OVERRIDE;
71
72    virtual void reset() OVERRIDE;
73
74    virtual void changedMute() OVERRIDE;
75    virtual void changedVolume() OVERRIDE;
76
77    virtual void enteredFullscreen() OVERRIDE;
78    virtual void exitedFullscreen() OVERRIDE;
79
80    virtual void reportedError() OVERRIDE;
81    virtual void loadedMetadata() OVERRIDE;
82
83    virtual void showVolumeSlider() OVERRIDE;
84    virtual void updateCurrentTimeDisplay() OVERRIDE;
85    virtual void updateStatusDisplay() OVERRIDE;
86
87    virtual void changedClosedCaptionsVisibility() OVERRIDE;
88    virtual void toggleClosedCaptionTrackList() OVERRIDE;
89    virtual void closedCaptionTracksChanged() OVERRIDE;
90
91    bool shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY);
92    void handleClickEvent(Event*);
93
94private:
95    MediaControlsApple(Document*);
96
97    virtual void defaultEventHandler(Event*) OVERRIDE;
98    PassRefPtr<MediaControlsAppleEventListener> eventListener();
99
100    void showClosedCaptionTrackList();
101    void hideClosedCaptionTrackList();
102
103    MediaControlRewindButtonElement* m_rewindButton;
104    MediaControlReturnToRealtimeButtonElement* m_returnToRealTimeButton;
105    MediaControlStatusDisplayElement* m_statusDisplay;
106    MediaControlTimeRemainingDisplayElement* m_timeRemainingDisplay;
107    MediaControlTimelineContainerElement* m_timelineContainer;
108    MediaControlSeekBackButtonElement* m_seekBackButton;
109    MediaControlSeekForwardButtonElement* m_seekForwardButton;
110    MediaControlClosedCaptionsTrackListElement* m_closedCaptionsTrackList;
111    MediaControlClosedCaptionsContainerElement* m_closedCaptionsContainer;
112    MediaControlVolumeSliderMuteButtonElement* m_volumeSliderMuteButton;
113    MediaControlVolumeSliderContainerElement* m_volumeSliderContainer;
114    MediaControlFullscreenVolumeMinButtonElement* m_fullScreenMinVolumeButton;
115    MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider;
116    MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton;
117    RefPtr<MediaControlsAppleEventListener> m_eventListener;
118};
119
120}
121
122#endif
123#endif
124