eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 1 | /* |
bfulgham@apple.com | 3137b82 | 2016-09-16 21:20:23 +0000 | [diff] [blame] | 2 | * Copyright (C) 2012-2016 Apple Inc. All rights reserved. |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
bfulgham@apple.com | 3137b82 | 2016-09-16 21:20:23 +0000 | [diff] [blame] | 26 | #pragma once |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 27 | |
| 28 | #if ENABLE(VIDEO_TRACK) |
| 29 | |
jer.noble@apple.com | 8cadb6f | 2014-10-07 19:11:53 +0000 | [diff] [blame] | 30 | #include "AudioTrack.h" |
eric.carlson@apple.com | f02a61a | 2013-02-04 19:39:31 +0000 | [diff] [blame] | 31 | #include "Language.h" |
dino@apple.com | 53a29d4 | 2013-02-05 08:03:22 +0000 | [diff] [blame] | 32 | #include "LocalizedStrings.h" |
| 33 | #include "TextTrack.h" |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 34 | #include "Timer.h" |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 35 | #include <wtf/text/AtomicString.h> |
| 36 | |
| 37 | namespace WebCore { |
| 38 | |
eric.carlson@apple.com | 92907e1 | 2013-03-27 18:45:29 +0000 | [diff] [blame] | 39 | class HTMLMediaElement; |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 40 | class PageGroup; |
jer.noble@apple.com | 8cadb6f | 2014-10-07 19:11:53 +0000 | [diff] [blame] | 41 | class AudioTrackList; |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 42 | class TextTrackList; |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 43 | |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 44 | class CaptionUserPreferences { |
| 45 | public: |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 46 | CaptionUserPreferences(PageGroup&); |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 47 | virtual ~CaptionUserPreferences(); |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 48 | |
eric.carlson@apple.com | 44f8c68 | 2013-04-04 22:23:47 +0000 | [diff] [blame] | 49 | enum CaptionDisplayMode { |
| 50 | Automatic, |
| 51 | ForcedOnly, |
eric.carlson@apple.com | 6fde4d4 | 2016-02-02 16:38:02 +0000 | [diff] [blame] | 52 | AlwaysOn, |
| 53 | Manual, |
eric.carlson@apple.com | 44f8c68 | 2013-04-04 22:23:47 +0000 | [diff] [blame] | 54 | }; |
| 55 | virtual CaptionDisplayMode captionDisplayMode() const; |
| 56 | virtual void setCaptionDisplayMode(CaptionDisplayMode); |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 57 | |
eric.carlson@apple.com | 92907e1 | 2013-03-27 18:45:29 +0000 | [diff] [blame] | 58 | virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const; |
eric.carlson@apple.com | 44f8c68 | 2013-04-04 22:23:47 +0000 | [diff] [blame] | 59 | virtual int textTrackLanguageSelectionScore(TextTrack*, const Vector<String>&) const; |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 60 | |
| 61 | virtual bool userPrefersCaptions() const; |
| 62 | virtual void setUserPrefersCaptions(bool); |
| 63 | |
| 64 | virtual bool userPrefersSubtitles() const; |
| 65 | virtual void setUserPrefersSubtitles(bool preference); |
| 66 | |
| 67 | virtual bool userPrefersTextDescriptions() const; |
| 68 | virtual void setUserPrefersTextDescriptions(bool preference); |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 69 | |
eric.carlson@apple.com | c1ce91d | 2013-04-09 20:56:27 +0000 | [diff] [blame] | 70 | virtual float captionFontSizeScaleAndImportance(bool& important) const { important = false; return 0.05f; } |
| 71 | |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 72 | virtual String captionsStyleSheetOverride() const { return m_captionsStyleSheetOverride; } |
| 73 | virtual void setCaptionsStyleSheetOverride(const String&); |
| 74 | |
| 75 | virtual void setInterestedInCaptionPreferenceChanges() { } |
| 76 | |
| 77 | virtual void captionPreferencesChanged(); |
| 78 | |
eric.carlson@apple.com | 44f8c68 | 2013-04-04 22:23:47 +0000 | [diff] [blame] | 79 | virtual void setPreferredLanguage(const String&); |
eric.carlson@apple.com | 7010950 | 2013-02-13 22:57:11 +0000 | [diff] [blame] | 80 | virtual Vector<String> preferredLanguages() const; |
| 81 | |
jer.noble@apple.com | aac3830 | 2015-05-22 23:15:37 +0000 | [diff] [blame] | 82 | virtual void setPreferredAudioCharacteristic(const String&); |
| 83 | virtual Vector<String> preferredAudioCharacteristics() const; |
| 84 | |
eric.carlson@apple.com | 7010950 | 2013-02-13 22:57:11 +0000 | [diff] [blame] | 85 | virtual String displayNameForTrack(TextTrack*) const; |
andersca@apple.com | 64f1b5a | 2013-09-08 03:17:30 +0000 | [diff] [blame] | 86 | virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*); |
dino@apple.com | 53a29d4 | 2013-02-05 08:03:22 +0000 | [diff] [blame] | 87 | |
jer.noble@apple.com | 8cadb6f | 2014-10-07 19:11:53 +0000 | [diff] [blame] | 88 | virtual String displayNameForTrack(AudioTrack*) const; |
| 89 | virtual Vector<RefPtr<AudioTrack>> sortedTrackListForMenu(AudioTrackList*); |
| 90 | |
eric.carlson@apple.com | 502400b | 2013-04-12 17:23:42 +0000 | [diff] [blame] | 91 | void setPrimaryAudioTrackLanguageOverride(const String& language) { m_primaryAudioTrackLanguageOverride = language; } |
| 92 | String primaryAudioTrackLanguageOverride() const; |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 93 | |
| 94 | virtual bool testingMode() const { return m_testingMode; } |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 95 | void setTestingMode(bool override) { m_testingMode = override; } |
eric.carlson@apple.com | 44f8c68 | 2013-04-04 22:23:47 +0000 | [diff] [blame] | 96 | |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 97 | PageGroup& pageGroup() const { return m_pageGroup; } |
| 98 | |
| 99 | protected: |
commit-queue@webkit.org | 54e3e40 | 2016-05-11 05:03:30 +0000 | [diff] [blame] | 100 | void updateCaptionStyleSheetOverride(); |
eric.carlson@apple.com | 6fde4d4 | 2016-02-02 16:38:02 +0000 | [diff] [blame] | 101 | void beginBlockingNotifications(); |
| 102 | void endBlockingNotifications(); |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 103 | |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 104 | private: |
andersca@apple.com | 574a745 | 2014-11-21 20:10:13 +0000 | [diff] [blame] | 105 | void timerFired(); |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 106 | void notify(); |
bfulgham@apple.com | 3137b82 | 2016-09-16 21:20:23 +0000 | [diff] [blame] | 107 | Page* currentPage() const; |
eric.carlson@apple.com | 62bb7dc | 2013-03-20 20:13:36 +0000 | [diff] [blame] | 108 | |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 109 | PageGroup& m_pageGroup; |
eric.carlson@apple.com | 6fde4d4 | 2016-02-02 16:38:02 +0000 | [diff] [blame] | 110 | mutable CaptionDisplayMode m_displayMode; |
jer.noble@apple.com | 50862fe | 2014-11-06 23:06:03 +0000 | [diff] [blame] | 111 | Timer m_timer; |
eric.carlson@apple.com | b54d1c8 | 2013-02-12 06:30:19 +0000 | [diff] [blame] | 112 | String m_userPreferredLanguage; |
jer.noble@apple.com | aac3830 | 2015-05-22 23:15:37 +0000 | [diff] [blame] | 113 | String m_userPreferredAudioCharacteristic; |
eric.carlson@apple.com | c1ce91d | 2013-04-09 20:56:27 +0000 | [diff] [blame] | 114 | String m_captionsStyleSheetOverride; |
eric.carlson@apple.com | 502400b | 2013-04-12 17:23:42 +0000 | [diff] [blame] | 115 | String m_primaryAudioTrackLanguageOverride; |
eric.carlson@apple.com | 6fde4d4 | 2016-02-02 16:38:02 +0000 | [diff] [blame] | 116 | unsigned m_blockNotificationsCounter { 0 }; |
bfulgham@apple.com | 3137b82 | 2016-09-16 21:20:23 +0000 | [diff] [blame] | 117 | bool m_testingMode { false }; |
| 118 | bool m_havePreferences { false }; |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 119 | }; |
commit-queue@webkit.org | 88e62d5 | 2014-01-30 07:42:07 +0000 | [diff] [blame] | 120 | |
eric.carlson@apple.com | 68e8da7 | 2012-10-24 14:24:43 +0000 | [diff] [blame] | 121 | } |
| 122 | #endif |