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 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 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) override;
49
50private:
51    MediaControlsAppleEventListener(MediaControlsApple* mediaControls)
52        : EventListener(MediaControlsAppleEventListenerType)
53        , m_mediaControls(mediaControls)
54    {
55    }
56
57    virtual void handleEvent(ScriptExecutionContext*, Event*) override;
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    void setFullscreenSliderVolume();
103
104    MediaControlRewindButtonElement* m_rewindButton;
105    MediaControlReturnToRealtimeButtonElement* m_returnToRealTimeButton;
106    MediaControlStatusDisplayElement* m_statusDisplay;
107    MediaControlTimeRemainingDisplayElement* m_timeRemainingDisplay;
108    MediaControlTimelineContainerElement* m_timelineContainer;
109    MediaControlSeekBackButtonElement* m_seekBackButton;
110    MediaControlSeekForwardButtonElement* m_seekForwardButton;
111    MediaControlClosedCaptionsTrackListElement* m_closedCaptionsTrackList;
112    MediaControlClosedCaptionsContainerElement* m_closedCaptionsContainer;
113    MediaControlVolumeSliderMuteButtonElement* m_volumeSliderMuteButton;
114    MediaControlVolumeSliderContainerElement* m_volumeSliderContainer;
115    MediaControlFullscreenVolumeMinButtonElement* m_fullScreenMinVolumeButton;
116    MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider;
117    MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton;
118    RefPtr<MediaControlsAppleEventListener> m_eventListener;
119};
120
121}
122
123#endif
124#endif
125